1 | /*
|
---|
2 | * GMLDocument.java
|
---|
3 | * Copyright (C) 2001 New Zealand Digital Library Project
|
---|
4 | *
|
---|
5 | * This program is free software; you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation; either version 2 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program; if not, write to the Free Software
|
---|
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
18 | */
|
---|
19 | package org.nzdl.gsdl.SimpleGraphicalClient;
|
---|
20 |
|
---|
21 | import java.util.*;
|
---|
22 | import javax.swing.text.*;
|
---|
23 | import javax.swing.text.html.*;
|
---|
24 |
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Class GMLDocument
|
---|
28 | *
|
---|
29 | * A class to represent GML Documents
|
---|
30 | *
|
---|
31 | * @author Dave Nichols ([email protected])
|
---|
32 | * @see org.nzdl.gsdl.service.SimpleGraphicalClient.SimpleGraphicalClient
|
---|
33 | */
|
---|
34 |
|
---|
35 | public class GMLDocument extends HTMLDocument
|
---|
36 | {
|
---|
37 |
|
---|
38 | GMLDocument(){
|
---|
39 | super();
|
---|
40 | }
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 | public void getImageData() {
|
---|
45 | // display image data
|
---|
46 | System.err.println("about to get iterator ...");
|
---|
47 | HTML.Tag tag = HTML.Tag.A;
|
---|
48 |
|
---|
49 | HTMLDocument.Iterator it = getIterator(tag);
|
---|
50 | if (it.getTag() == null) System.err.println("iterator is null");
|
---|
51 | System.err.println("got iterator for tag type:" + it.getTag());
|
---|
52 | System.err.println("about to loop over " + it.getTag() + " tags...");
|
---|
53 | while (it.isValid()) {
|
---|
54 | System.err.println("Found tag: " + it.getTag());
|
---|
55 | System.err.println("Start offset = " + it.getStartOffset() + " End Offset = " + it.getEndOffset());
|
---|
56 | int length = it.getEndOffset() - it.getStartOffset();
|
---|
57 | AttributeSet attributeSet = it.getAttributes();
|
---|
58 |
|
---|
59 | for (Enumeration i = attributeSet.getAttributeNames(); i.hasMoreElements();) {
|
---|
60 | System.err.println(i.nextElement());
|
---|
61 | }
|
---|
62 |
|
---|
63 | System.err.println("extracted Document contents = ...");
|
---|
64 | try {
|
---|
65 | System.err.println(getText(it.getStartOffset(), length));
|
---|
66 | }
|
---|
67 | catch (BadLocationException e) {
|
---|
68 | System.err.println(e);
|
---|
69 | }
|
---|
70 |
|
---|
71 | System.err.println("attr count =" + attributeSet.getAttributeCount());
|
---|
72 | it.next();
|
---|
73 | }
|
---|
74 | System.err.println("no more " + it.getTag() + " tags");
|
---|
75 | System.err.println("tag " + tag + " has block status " + tag.isBlock());
|
---|
76 |
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 |
|
---|
81 | } //end GMLDocument class
|
---|