Revision 2765
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/Values.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* Values.java |
|
4 |
* |
|
5 |
* Created on 27 de enero de 2005, 21:03 |
|
6 |
*/ |
|
7 |
import java.util.*; |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
* @author jaume |
|
12 |
*/ |
|
13 |
public class Values{ |
|
14 |
private String semantic; |
|
15 |
private String type; |
|
16 |
private ArrayList singleValueList = new ArrayList(); |
|
17 |
private Interval interval; |
|
18 |
private String Default; |
|
19 |
|
|
20 |
private String miValuesType; |
|
21 |
|
|
22 |
public Values(XMLNode node){ |
|
23 |
semantic = node.getAttribute("semantic"); |
|
24 |
type = node.getAttribute("type"); |
|
25 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
26 |
XMLNode subnode = node.getSubNode(i); |
|
27 |
if (WCSToolkit.isWCSTab(subnode, "default")) Default = subnode.getText(); |
|
28 |
if (WCSToolkit.isWCSTab(subnode, "interval")) { |
|
29 |
interval = new Interval(subnode); |
|
30 |
miValuesType = "interval"; |
|
31 |
} |
|
32 |
if (WCSToolkit.isWCSTab(subnode, "singleValue")) { |
|
33 |
singleValueList.add(new SingleValue(subnode)); |
|
34 |
miValuesType = "singleValue"; |
|
35 |
} |
|
36 |
} |
|
37 |
} |
|
38 |
|
|
39 |
public String getSemantic(){ |
|
40 |
return semantic; |
|
41 |
} |
|
42 |
|
|
43 |
public String getType(){ |
|
44 |
return type; |
|
45 |
} |
|
46 |
|
|
47 |
public String getValuesType(){ |
|
48 |
return miValuesType; |
|
49 |
} |
|
50 |
|
|
51 |
public ArrayList getSingleValueList(){ |
|
52 |
return singleValueList; |
|
53 |
} |
|
54 |
|
|
55 |
public Interval getInterval(){ |
|
56 |
return interval; |
|
57 |
} |
|
58 |
|
|
59 |
public String toString(){ |
|
60 |
String s = ""; |
|
61 |
|
|
62 |
if (getType().equals("singleValue")){ |
|
63 |
Iterator it = singleValueList.iterator(); |
|
64 |
while (it.hasNext()){ |
|
65 |
s += it.next(); |
|
66 |
if (it.hasNext()) s += ", "; |
|
67 |
} |
|
68 |
} |
|
69 |
else{ |
|
70 |
s = "max="+interval.getMax()+", min="+interval.getMin()+", res="+interval.getRes(); |
|
71 |
} |
|
72 |
return "\nSemantic: "+semantic+ |
|
73 |
"\nType: "+type+ |
|
74 |
"\nDefault: "+Default+ |
|
75 |
|
|
76 |
"\nValueEnum: "+s; |
|
77 |
} |
|
78 |
} |
|
0 | 79 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/Service.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* Service.java |
|
4 |
* |
|
5 |
* Created on 21 de diciembre de 2004, 1:02 |
|
6 |
*/ |
|
7 |
/** |
|
8 |
* |
|
9 |
* @author jaume |
|
10 |
*/ |
|
11 |
public class Service { |
|
12 |
private String description; // A description of the server. (optional) |
|
13 |
private String name; // A name the service provider assigns to the server. (required) |
|
14 |
private String label; // A human-readable label for this server, for use in menus and other displays. (required) |
|
15 |
private String metadataLink; // A link to external metadata (of type "FGDC", "TC211", or "other"). (optional) |
|
16 |
private String keywords; // Short words to aid catalog searching. (optional) |
|
17 |
private String responsibleParty; // A tree of elements that identify the service provider and provide contact details. (optional) |
|
18 |
private String fees; // A text string indicating any fees imposed by the service provider. The keyword NONE is reserved to mean no fees. (required) |
|
19 |
private String accessConstraints; // A list of codes describing any access constraints imposed by the service provider. The keyword NONE is reserved to mean no access constraints are imposed. (required) |
|
20 |
|
|
21 |
/** Creates a new instance of Service */ |
|
22 |
public Service(XMLNode node) { |
|
23 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
24 |
XMLNode subnode = node.getSubNode(i); |
|
25 |
if (WCSToolkit.isWCSTab(subnode, "description")) setDescription(subnode.getText()); |
|
26 |
if (WCSToolkit.isWCSTab(subnode, "name")) setName(subnode.getText()); |
|
27 |
if (WCSToolkit.isWCSTab(subnode, "label")) setLabel(subnode.getText()); |
|
28 |
if (WCSToolkit.isWCSTab(subnode, "metadataLink")) setMetadataLink(subnode.getText()); |
|
29 |
if (WCSToolkit.isWCSTab(subnode, "keywords")) setKeywords(subnode); |
|
30 |
if (WCSToolkit.isWCSTab(subnode, "responsibleParty")) setResponsibleParty(subnode); |
|
31 |
if (WCSToolkit.isWCSTab(subnode, "fees")) setFees(subnode.getText()); |
|
32 |
if (WCSToolkit.isWCSTab(subnode, "accessConstraints")) setAccessConstraints(subnode.getText()); |
|
33 |
} |
|
34 |
} |
|
35 |
|
|
36 |
public String getDescription(){ |
|
37 |
return description; |
|
38 |
} |
|
39 |
|
|
40 |
public String getName(){ |
|
41 |
return name; |
|
42 |
} |
|
43 |
|
|
44 |
public String getLabel(){ |
|
45 |
return label; |
|
46 |
} |
|
47 |
|
|
48 |
public String getMetadataLink(){ |
|
49 |
return metadataLink; |
|
50 |
} |
|
51 |
|
|
52 |
public String getKeywords(){ |
|
53 |
return keywords; |
|
54 |
} |
|
55 |
|
|
56 |
public String getResponsibleParty(){ |
|
57 |
return responsibleParty; |
|
58 |
} |
|
59 |
|
|
60 |
public String getFees(){ |
|
61 |
return fees; |
|
62 |
} |
|
63 |
|
|
64 |
public String getAccessConstraints(){ |
|
65 |
return accessConstraints; |
|
66 |
} |
|
67 |
|
|
68 |
public void setDescription(String s){ |
|
69 |
description = s; |
|
70 |
} |
|
71 |
|
|
72 |
public void setName(String s){ |
|
73 |
name = s; |
|
74 |
} |
|
75 |
|
|
76 |
public void setLabel(String s){ |
|
77 |
label = s; |
|
78 |
} |
|
79 |
|
|
80 |
public void setMetadataLink(String s){ |
|
81 |
metadataLink = s; |
|
82 |
} |
|
83 |
|
|
84 |
public void setKeywords(XMLNode node){ |
|
85 |
keywords = ""; |
|
86 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
87 |
keywords += node.getSubNode(i).getText()+";"; |
|
88 |
} |
|
89 |
|
|
90 |
// for (int i=0; i<node.getNumSubNodes(); i++){ |
|
91 |
// keywords.add(node.getSubNode(i).getText()); |
|
92 |
// } |
|
93 |
} |
|
94 |
|
|
95 |
public void setResponsibleParty(XMLNode node){ |
|
96 |
responsibleParty = ""; |
|
97 |
for (int j=0; j<node.getNumSubNodes(); j++){ |
|
98 |
responsibleParty += node.getSubNode(j).getName()+"="+node.getSubNode(j).getText()+";"; |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
public void setFees(String s){ |
|
103 |
fees = s; |
|
104 |
} |
|
105 |
|
|
106 |
public void setAccessConstraints(String s){ |
|
107 |
accessConstraints = s; |
|
108 |
} |
|
109 |
|
|
110 |
public String toString(){ |
|
111 |
return "\nDescription: "+getDescription()+ |
|
112 |
"\nName: "+getName()+ |
|
113 |
"\nLabel: "+getLabel()+ |
|
114 |
"\nMetadata Link: "+getMetadataLink()+ |
|
115 |
"\nKeywords: "+getKeywords()+ |
|
116 |
"\nResponsible party: "+getResponsibleParty()+ |
|
117 |
"\nFees: "+getFees()+ |
|
118 |
"\nAccess Constraints: "+getAccessConstraints(); |
|
119 |
} |
|
120 |
} |
|
0 | 121 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/ValueEnum.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* ValueEnum.java |
|
4 |
* |
|
5 |
* Created on 8 de enero de 2005, 14:44 |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* |
|
10 |
* @author jaume |
|
11 |
*/ |
|
12 |
public class ValueEnum { |
|
13 |
|
|
14 |
private Interval interval; |
|
15 |
private String singleValue; |
|
16 |
|
|
17 |
public ValueEnum(XMLNode node){ |
|
18 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
19 |
XMLNode subnode = node.getSubNode(i); |
|
20 |
if (WCSToolkit.isWCSTab(subnode, "interval")) interval = new Interval(subnode); |
|
21 |
if (WCSToolkit.isWCSTab(subnode, "singleValue")) singleValue = subnode.getText(); |
|
22 |
} |
|
23 |
} |
|
24 |
|
|
25 |
public Interval getInterval(){ |
|
26 |
return interval; |
|
27 |
} |
|
28 |
|
|
29 |
public String getSingleValue(){ |
|
30 |
return singleValue; |
|
31 |
} |
|
32 |
|
|
33 |
public String toString(){ |
|
34 |
return "\nValue Enum: "+ |
|
35 |
getInterval()+ |
|
36 |
"\nSingle Value: "+getSingleValue(); |
|
37 |
} |
|
38 |
} |
|
0 | 39 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/TimePeriod.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* TimePeriod.java |
|
4 |
* |
|
5 |
* Created on 3 de enero de 2005, 16:15 |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* |
|
10 |
* @author jaume |
|
11 |
*/ |
|
12 |
public class TimePeriod { |
|
13 |
private double beginPosition; |
|
14 |
private String beginPositionFrame; |
|
15 |
|
|
16 |
private double endPosition; |
|
17 |
private String endPositionFrame; |
|
18 |
|
|
19 |
private double timeResolution; |
|
20 |
private String timeResolutionFrame; |
|
21 |
|
|
22 |
/** Creates a new instance of TimePeriod */ |
|
23 |
public TimePeriod(XMLNode node) { |
|
24 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
25 |
XMLNode subnode = node.getSubNode(i); |
|
26 |
if (WCSToolkit.isWCSTab(subnode, "beginPosition")) { |
|
27 |
beginPosition = Double.parseDouble(subnode.getText()); |
|
28 |
if (subnode.getAttribute("frame") == null) beginPositionFrame = "ISO-8601"; |
|
29 |
else beginPositionFrame = subnode.getAttribute("frame"); |
|
30 |
} |
|
31 |
if (WCSToolkit.isWCSTab(subnode, "endPosition")) { |
|
32 |
endPosition = Double.parseDouble(subnode.getText()); |
|
33 |
if (subnode.getAttribute("frame") == null) endPositionFrame = "ISO-8601"; |
|
34 |
else endPositionFrame = subnode.getAttribute("frame"); |
|
35 |
} |
|
36 |
if (WCSToolkit.isWCSTab(subnode, "timeResolution")) { |
|
37 |
timeResolution = Double.parseDouble(subnode.getText()); |
|
38 |
if (subnode.getAttribute("frame") == null) timeResolutionFrame = "ISO-8601"; |
|
39 |
else timeResolutionFrame = subnode.getAttribute("frame"); |
|
40 |
} |
|
41 |
} |
|
42 |
} |
|
43 |
public double getBeginPosition(){ |
|
44 |
return beginPosition; |
|
45 |
} |
|
46 |
|
|
47 |
public String getBeginPositionFrame(){ |
|
48 |
return beginPositionFrame; |
|
49 |
} |
|
50 |
|
|
51 |
public double getEndPosition(){ |
|
52 |
return endPosition; |
|
53 |
} |
|
54 |
|
|
55 |
public String getEndPositionFrame(){ |
|
56 |
return endPositionFrame; |
|
57 |
} |
|
58 |
|
|
59 |
public double getTimeResolution(){ |
|
60 |
return timeResolution; |
|
61 |
} |
|
62 |
|
|
63 |
public String getTimeResolutionFrame(){ |
|
64 |
return timeResolutionFrame; |
|
65 |
} |
|
66 |
|
|
67 |
public String toString(){ |
|
68 |
return "\nTIME PERIOD: "+ |
|
69 |
"\nBegin position: "+getBeginPosition()+ |
|
70 |
"\nBegin Position: "+getBeginPositionFrame()+ |
|
71 |
"\nEnd Position: "+getEndPosition()+ |
|
72 |
"\nEnd Position Frame: "+getEndPositionFrame()+ |
|
73 |
"\nTime Resolution: "+getTimeResolution()+ |
|
74 |
"\nTime Resolution Frame: "+getTimeResolutionFrame(); |
|
75 |
} |
|
76 |
} |
|
0 | 77 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/GMLLimits.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* GMLLimits.java |
|
4 |
* |
|
5 |
* Created on 3 de enero de 2005, 15:24 |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* |
|
10 |
* @author jaume |
|
11 |
*/ |
|
12 |
public class GMLLimits { |
|
13 |
private GMLGridEnvelope gmlGridEnvelope; |
|
14 |
/** Creates a new instance of GMLLimits */ |
|
15 |
public GMLLimits(XMLNode node, int dimension) { |
|
16 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
17 |
XMLNode subnode = node.getSubNode(i); |
|
18 |
if (WCSToolkit.isWCSTab(subnode, "gml:GridEnvelope")) gmlGridEnvelope = new GMLGridEnvelope(subnode, dimension); |
|
19 |
} |
|
20 |
} |
|
21 |
|
|
22 |
public GMLGridEnvelope getGMLGridEnvelope(){ |
|
23 |
return gmlGridEnvelope; |
|
24 |
} |
|
25 |
|
|
26 |
public String toString(){ |
|
27 |
return gmlGridEnvelope.toString(); |
|
28 |
} |
|
29 |
} |
|
0 | 30 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/WCSToolkit.java | ||
---|---|---|
1 |
/* |
|
2 |
* WCSToolkit.java |
|
3 |
* |
|
4 |
* Created on 14 de febrero de 2005, 16:01 |
|
5 |
*/ |
|
6 |
|
|
7 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
* @author jaume |
|
12 |
*/ |
|
13 |
public class WCSToolkit { |
|
14 |
|
|
15 |
/** Creates a new instance of WCSToolkit */ |
|
16 |
public WCSToolkit() { |
|
17 |
} |
|
18 |
|
|
19 |
public static boolean isWCSTab(XMLNode node, String text){ |
|
20 |
return (node.getName().equals(text) || node.getName().equals("wcs:"+text)); |
|
21 |
} |
|
22 |
} |
|
0 | 23 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/GMLRectifiedGrid.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* GMLRectifiedGrid.java |
|
4 |
* |
|
5 |
* Created on 3 de enero de 2005, 15:10 |
|
6 |
*/ |
|
7 |
import java.util.*; |
|
8 |
/** |
|
9 |
* |
|
10 |
* @author jaume |
|
11 |
*/ |
|
12 |
public class GMLRectifiedGrid { |
|
13 |
private int dimension; |
|
14 |
private GMLLimits gmlLimits; |
|
15 |
private ArrayList axisNames = new ArrayList(); |
|
16 |
private double[] origin; |
|
17 |
private ArrayList offsetVectorList = new ArrayList(); |
|
18 |
|
|
19 |
/** Creates a new instance of GMLRectifiedGrid */ |
|
20 |
public GMLRectifiedGrid(XMLNode node) { |
|
21 |
dimension = Integer.parseInt(node.getAttribute("dimension")); |
|
22 |
for (int i=0; i<node.getNumSubNodes();i++){ |
|
23 |
XMLNode subnode = node.getSubNode(i); |
|
24 |
if (WCSToolkit.isWCSTab(subnode, "gml:limits")) gmlLimits = new GMLLimits(subnode, dimension); |
|
25 |
if (WCSToolkit.isWCSTab(subnode, "gml:axisName")) axisNames.add(subnode.getText()); |
|
26 |
if (WCSToolkit.isWCSTab(subnode, "gml:origin")) setOrigin(subnode, dimension); |
|
27 |
if (WCSToolkit.isWCSTab(subnode, "gml:offsetVector")) { |
|
28 |
String[] s = subnode.getText().split(" "); |
|
29 |
int [] aux = new int[dimension]; |
|
30 |
for (int j=0; j<dimension; j++){ |
|
31 |
aux[j] = new Integer(s[j]).intValue(); |
|
32 |
} |
|
33 |
offsetVectorList.add(aux); |
|
34 |
} |
|
35 |
|
|
36 |
} |
|
37 |
|
|
38 |
} |
|
39 |
|
|
40 |
public void setOrigin(XMLNode node, int dimension){ |
|
41 |
origin = new double[dimension]; |
|
42 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
43 |
XMLNode subnode = node.getSubNode(i); |
|
44 |
if (WCSToolkit.isWCSTab(subnode, "gml:pos")){ |
|
45 |
String[] s = subnode.getText().split(" "); |
|
46 |
for (int j=0; j<dimension; j++){ |
|
47 |
origin[j] = new Double(s[j]).doubleValue(); |
|
48 |
} |
|
49 |
} |
|
50 |
} |
|
51 |
} |
|
52 |
|
|
53 |
public int getDimension(){ |
|
54 |
return dimension; |
|
55 |
} |
|
56 |
|
|
57 |
public GMLLimits getGMLLimits(){ |
|
58 |
return gmlLimits; |
|
59 |
} |
|
60 |
|
|
61 |
public ArrayList getAxisNames(){ |
|
62 |
return axisNames; |
|
63 |
} |
|
64 |
|
|
65 |
public String getAxisName(int index){ |
|
66 |
return (String) axisNames.get(index); |
|
67 |
} |
|
68 |
|
|
69 |
public int[] getOffsetVector(int index){ |
|
70 |
return (int[]) offsetVectorList.get(index); |
|
71 |
} |
|
72 |
|
|
73 |
public ArrayList getOffsetVectorList(){ |
|
74 |
return offsetVectorList; |
|
75 |
} |
|
76 |
|
|
77 |
public double[] getOrigin(){ |
|
78 |
return origin; |
|
79 |
} |
|
80 |
|
|
81 |
public String toString(){ |
|
82 |
Iterator it ; |
|
83 |
String s, s2, s3; |
|
84 |
s =""; |
|
85 |
s2 =""; |
|
86 |
s3 =""; |
|
87 |
if (axisNames !=null){ |
|
88 |
it = axisNames.iterator(); |
|
89 |
while (it.hasNext()){ |
|
90 |
s += it.next()+" "; |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
if (origin != null){ |
|
95 |
for (int i=0; i<origin.length; i++){ |
|
96 |
s3 += origin[i]+" "; |
|
97 |
} |
|
98 |
} |
|
99 |
return "\nGML Rectified Grid"+ |
|
100 |
"\ndimension: "+dimension+ |
|
101 |
"\ngml limits: "+gmlLimits+ |
|
102 |
"\nAxis names: "+s |
|
103 |
+"\nOffset vector: ["+s2+"]"+ |
|
104 |
"\nOrigin: ("+s3+")"; |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
0 | 108 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/XMLNode.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.FileWriter; |
|
5 |
import java.io.InputStream; |
|
6 |
import java.io.StringWriter; |
|
7 |
import java.io.Writer; |
|
8 |
import java.util.Hashtable; |
|
9 |
import java.util.Vector; |
|
10 |
|
|
11 |
import javax.xml.parsers.DocumentBuilderFactory; |
|
12 |
|
|
13 |
import org.w3c.dom.Document; |
|
14 |
import org.w3c.dom.Element; |
|
15 |
import org.w3c.dom.NamedNodeMap; |
|
16 |
import org.w3c.dom.Node; |
|
17 |
import org.w3c.dom.NodeList; |
|
18 |
|
|
19 |
/* Esta clase representa un XMLNode simplificado |
|
20 |
* Contiene una lista de subnodos y una lista de atributos. |
|
21 |
* Tambi?n tiene una cadena. |
|
22 |
* |
|
23 |
* Soporta la lectura y escritura de y desde un fichero XML. |
|
24 |
* Tambi?n soporta la lectura desde Internet |
|
25 |
* |
|
26 |
* Modificado por jaume |
|
27 |
*/ |
|
28 |
|
|
29 |
public class XMLNode { |
|
30 |
|
|
31 |
// subnodos |
|
32 |
private Vector subNodes = new Vector(); |
|
33 |
// atributos |
|
34 |
private Hashtable attr = new Hashtable(); |
|
35 |
private String nodeName; |
|
36 |
private String text = null; |
|
37 |
// los nombres de los atributos |
|
38 |
private Vector attrKeys = new Vector(); |
|
39 |
// cabecera XML |
|
40 |
private String header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
|
41 |
|
|
42 |
// Constructor, lee de un fichero |
|
43 |
public XMLNode(File file) throws Exception { |
|
44 |
this(factory.newDocumentBuilder().parse(file)); |
|
45 |
} |
|
46 |
|
|
47 |
// Constructor, usando url.openStream() puedo leer de internet |
|
48 |
public XMLNode(InputStream inputstream) throws Exception{ |
|
49 |
this(factory.newDocumentBuilder().parse(inputstream)); |
|
50 |
} |
|
51 |
|
|
52 |
// Contructor, constructor desde un documento DOM |
|
53 |
public XMLNode(Document dom) throws Exception { |
|
54 |
this((Element)dom.getFirstChild()); |
|
55 |
} |
|
56 |
|
|
57 |
// Contructor, crea un nodo con su nombre |
|
58 |
public XMLNode(String name) throws Exception { |
|
59 |
nodeName = name; |
|
60 |
} |
|
61 |
|
|
62 |
// Contructor, crea un nodo con su nombre y el texto |
|
63 |
public XMLNode(String name, String text) throws Exception { |
|
64 |
nodeName = name; |
|
65 |
this.text = text; |
|
66 |
} |
|
67 |
|
|
68 |
// Contructor, desde un elemento DOM |
|
69 |
public XMLNode(Element dom) throws Exception { |
|
70 |
nodeName = dom.getNodeName(); |
|
71 |
NamedNodeMap map = dom.getAttributes(); |
|
72 |
for (int i = 0; i < map.getLength(); i++) { |
|
73 |
Node att = map.item(i); |
|
74 |
addAtrribute(att.getNodeName(), att.getNodeValue()); |
|
75 |
} |
|
76 |
NodeList nodeList = dom.getChildNodes(); |
|
77 |
for (int i = 0; i < nodeList.getLength(); i++) { |
|
78 |
Node sub = nodeList.item(i); |
|
79 |
if (sub.getNodeType() == Node.ELEMENT_NODE) { |
|
80 |
addSubNode(new XMLNode((Element)sub)); |
|
81 |
} |
|
82 |
else if (sub.getNodeType() == Node.TEXT_NODE) { |
|
83 |
String s = sub.getNodeValue().trim(); |
|
84 |
if (s.length() > 0) { |
|
85 |
if (text != null) { |
|
86 |
throw new Exception("XMLNode '" + nodeName + "' has 2 Textblocks"); |
|
87 |
} |
|
88 |
text = s; |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
public void setText(String s) { |
|
95 |
text = s; |
|
96 |
} |
|
97 |
|
|
98 |
public void addSubNode(XMLNode s) { |
|
99 |
subNodes.add(s); |
|
100 |
} |
|
101 |
|
|
102 |
public void addAtrribute(String name, String value) throws Exception { |
|
103 |
if (attr.containsKey(name)) { |
|
104 |
throw new Exception( |
|
105 |
"XMLNode '" + nodeName + "' already contains Attribute '" + name + "'"); |
|
106 |
} |
|
107 |
attr.put(name, value); |
|
108 |
attrKeys.add(name); |
|
109 |
} |
|
110 |
|
|
111 |
public int getNumSubNodes() { |
|
112 |
return subNodes.size(); |
|
113 |
} |
|
114 |
|
|
115 |
public String getName() { |
|
116 |
return nodeName; |
|
117 |
} |
|
118 |
|
|
119 |
public String getText() { |
|
120 |
return text; |
|
121 |
} |
|
122 |
|
|
123 |
public XMLNode getSubNode(int index) { |
|
124 |
return (XMLNode)subNodes.get(index); |
|
125 |
} |
|
126 |
|
|
127 |
public Vector getAttributeNames() { |
|
128 |
return attrKeys; |
|
129 |
} |
|
130 |
|
|
131 |
public void write(Writer wr) throws Exception { |
|
132 |
wwrite("", wr); |
|
133 |
} |
|
134 |
|
|
135 |
// escribe el c?digo XML de este objeto con su identaci?n |
|
136 |
private void wwrite(String pre, Writer wr) throws Exception { |
|
137 |
wr.write(pre + "<" + nodeName); |
|
138 |
for (int i = 0; i < attrKeys.size(); i++) { |
|
139 |
String name = (String)attrKeys.get(i); |
|
140 |
String val = (String)attr.get(name); |
|
141 |
wr.write(" " + name + "='" + val + "'"); |
|
142 |
} |
|
143 |
if (getNumSubNodes() == 0 && text == null) { |
|
144 |
wr.write("/>\n"); |
|
145 |
} |
|
146 |
else { |
|
147 |
wr.write(">"); |
|
148 |
if (text != null) { |
|
149 |
wr.write(text); |
|
150 |
} |
|
151 |
if (getNumSubNodes() > 0) { |
|
152 |
wr.write("\n"); |
|
153 |
for (int i = 0; i < subNodes.size(); i++) { |
|
154 |
if (getSubNode(i) != null) { |
|
155 |
getSubNode(i).wwrite(pre + " ", wr); |
|
156 |
} |
|
157 |
} |
|
158 |
wr.write(pre + "</" + nodeName + ">\n"); |
|
159 |
} |
|
160 |
else { |
|
161 |
wr.write("</" + nodeName + ">\n"); |
|
162 |
} |
|
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
public String getAttribute(String key) { |
|
170 |
return (String)attr.get(key); |
|
171 |
} |
|
172 |
|
|
173 |
public double getDoubleAttribute(String key) { |
|
174 |
return Double.parseDouble((String)attr.get(key)); |
|
175 |
} |
|
176 |
|
|
177 |
public boolean getBoolAttribute(String key) { |
|
178 |
if (!hasAttribute(key)) { |
|
179 |
return false; |
|
180 |
} |
|
181 |
return new Boolean((String)attr.get(key)).booleanValue(); |
|
182 |
} |
|
183 |
|
|
184 |
public int getIntAttribute(String key) { |
|
185 |
return Integer.parseInt((String)attr.get(key)); |
|
186 |
} |
|
187 |
|
|
188 |
public boolean hasAttribute(String key) { |
|
189 |
return attr.containsKey(key); |
|
190 |
} |
|
191 |
|
|
192 |
// escribe al fichero |
|
193 |
public void write(File f) throws Exception { |
|
194 |
FileWriter fw = new FileWriter(f); |
|
195 |
fw.write(header); |
|
196 |
write(fw); |
|
197 |
fw.flush(); |
|
198 |
fw.close(); |
|
199 |
} |
|
200 |
|
|
201 |
|
|
202 |
public String toString() { |
|
203 |
StringWriter wr = new StringWriter(); |
|
204 |
try { |
|
205 |
write(wr); |
|
206 |
} |
|
207 |
catch (Exception e) { |
|
208 |
System.err.println("Exception in StringWriter " + e); |
|
209 |
e.printStackTrace(); |
|
210 |
System.exit(1); |
|
211 |
} |
|
212 |
return wr.toString(); |
|
213 |
} |
|
214 |
|
|
215 |
static DocumentBuilderFactory factory; |
|
216 |
static { |
|
217 |
factory = DocumentBuilderFactory.newInstance(); |
|
218 |
factory.setValidating(false); |
|
219 |
factory.setNamespaceAware(false); |
|
220 |
factory.setIgnoringComments(true); |
|
221 |
} |
|
222 |
|
|
223 |
public void setHeader(String header) { |
|
224 |
this.header = header; |
|
225 |
} |
|
226 |
|
|
227 |
public static void main(String []args) throws Exception { |
|
228 |
XMLNode node=new XMLNode(new File(args[0])); |
|
229 |
System.out.println(node); |
|
230 |
} |
|
231 |
} |
|
0 | 232 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/RangeSet.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* RangeSet.java |
|
4 |
* |
|
5 |
* Created on 8 de enero de 2005, 13:39 |
|
6 |
*/ |
|
7 |
import java.util.*; |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
* @author jaume |
|
12 |
*/ |
|
13 |
public class RangeSet { |
|
14 |
private String metadataLink; |
|
15 |
private String description; |
|
16 |
private String name; |
|
17 |
|
|
18 |
private String label; |
|
19 |
private ArrayList axisDescriptionList = new ArrayList(); |
|
20 |
private ArrayList nullValuesList = new ArrayList(); |
|
21 |
|
|
22 |
/** Creates a new instance of RangeSet */ |
|
23 |
public RangeSet(XMLNode node) { |
|
24 |
if (WCSToolkit.isWCSTab(node.getSubNode(0), "RangeSet")) node = node.getSubNode(0); |
|
25 |
for (int i=0; i<node.getNumSubNodes();i++){ |
|
26 |
XMLNode subnode = node.getSubNode(i); |
|
27 |
|
|
28 |
if (WCSToolkit.isWCSTab(subnode, "metadataLink")) metadataLink = subnode.getText(); |
|
29 |
if (WCSToolkit.isWCSTab(subnode, "description")) description = subnode.getText(); |
|
30 |
if (WCSToolkit.isWCSTab(subnode, "name")) name = subnode.getText(); |
|
31 |
if (WCSToolkit.isWCSTab(subnode, "label")) label = subnode.getText(); |
|
32 |
if (WCSToolkit.isWCSTab(subnode, "axisDescription")) axisDescriptionList.add(new AxisDescription(subnode)); |
|
33 |
if (WCSToolkit.isWCSTab(subnode, "nullValues")) nullValuesList.add(new NullValues(subnode)); |
|
34 |
} |
|
35 |
} |
|
36 |
|
|
37 |
public String getMetadataLink(){ |
|
38 |
return metadataLink; |
|
39 |
} |
|
40 |
|
|
41 |
public String getDescription(){ |
|
42 |
return description; |
|
43 |
} |
|
44 |
|
|
45 |
public String getName(){ |
|
46 |
return name; |
|
47 |
} |
|
48 |
|
|
49 |
public String getLabel(){ |
|
50 |
return label; |
|
51 |
} |
|
52 |
|
|
53 |
public ArrayList getAxisDescriptionList(){ |
|
54 |
return axisDescriptionList; |
|
55 |
} |
|
56 |
|
|
57 |
public AxisDescription getAxisDescription(String name){ |
|
58 |
ArrayList al = getAxisDescriptionList(); |
|
59 |
Iterator it = al.iterator(); |
|
60 |
while (it.hasNext()){ |
|
61 |
AxisDescription ad = (AxisDescription) it.next(); |
|
62 |
if (ad.getName().equals(name)) |
|
63 |
return ad; |
|
64 |
} |
|
65 |
return null; |
|
66 |
} |
|
67 |
|
|
68 |
public ArrayList getNullValuesList(){ |
|
69 |
return nullValuesList; |
|
70 |
} |
|
71 |
public String toString(){ |
|
72 |
String s, s2; |
|
73 |
s = ""; |
|
74 |
s2 = ""; |
|
75 |
Iterator it = axisDescriptionList.iterator(); |
|
76 |
while (it.hasNext()) |
|
77 |
s += it.next().toString(); |
|
78 |
|
|
79 |
it = nullValuesList.iterator(); |
|
80 |
while (it.hasNext()) |
|
81 |
s2 += it.next().toString(); |
|
82 |
|
|
83 |
return "\nRANGE SET\nname: "+getName()+"\ndescription: "+getDescription()+ |
|
84 |
"\nlabel: "+getLabel()+"\nmetadata link: "+getMetadataLink()+ |
|
85 |
"\nAxisDescriptions: "+s+"\nNull Values: "+s2; |
|
86 |
|
|
87 |
} |
|
88 |
} |
|
0 | 89 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/AxisDescription.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* AxisDescription.java |
|
4 |
* |
|
5 |
* Created on 8 de enero de 2005, 13:57 |
|
6 |
*/ |
|
7 |
import java.util.*; |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
* @author jaume |
|
12 |
*/ |
|
13 |
public class AxisDescription { |
|
14 |
private String semantic; |
|
15 |
private String refSys; |
|
16 |
private String refSysLabel; |
|
17 |
private String metadataLink; |
|
18 |
private String description; |
|
19 |
private String name; |
|
20 |
private String Default; |
|
21 |
|
|
22 |
private String label; |
|
23 |
private Values values; |
|
24 |
|
|
25 |
/** Creates a new instance of AxisDescription */ |
|
26 |
public AxisDescription(XMLNode node) { |
|
27 |
if (WCSToolkit.isWCSTab(node.getSubNode(0), "AxisDescription")) node = node.getSubNode(0); |
|
28 |
//if (node.getSubNode(0).getName().equals("AxisDescription")) node = node.getSubNode(0); |
|
29 |
semantic = node.getAttribute("semantic"); |
|
30 |
refSys = node.getAttribute("refSys"); |
|
31 |
refSysLabel = node.getAttribute("refSysLabel"); |
|
32 |
for (int i=0; i<node.getNumSubNodes();i++){ |
|
33 |
XMLNode subnode = node.getSubNode(i); |
|
34 |
if (WCSToolkit.isWCSTab(subnode, "metadatalink")) metadataLink = subnode.getText(); |
|
35 |
//if (subnode.getName().equals("metadataLink")) metadataLink = subnode.getText(); |
|
36 |
if (WCSToolkit.isWCSTab(subnode, "description")) description = subnode.getText(); |
|
37 |
//if (subnode.getName().equals("description")) description = subnode.getText(); |
|
38 |
if (WCSToolkit.isWCSTab(subnode, "name")) name = subnode.getText(); |
|
39 |
//if (subnode.getName().equals("name")) name = subnode.getText(); |
|
40 |
if (WCSToolkit.isWCSTab(subnode, "label")) label = subnode.getText(); |
|
41 |
// if (subnode.getName().equals("label")) label = subnode.getText(); |
|
42 |
if (WCSToolkit.isWCSTab(subnode, "values")) values = new Values(subnode); |
|
43 |
//if (subnode.getName().equals("values")) values = new Values(subnode); |
|
44 |
} |
|
45 |
} |
|
46 |
|
|
47 |
public String getSemantic(){ |
|
48 |
return semantic; |
|
49 |
} |
|
50 |
|
|
51 |
public String getRefSys(){ |
|
52 |
return refSys; |
|
53 |
} |
|
54 |
|
|
55 |
public String getRefSysLabel(){ |
|
56 |
return refSysLabel; |
|
57 |
} |
|
58 |
|
|
59 |
public String getMetadataLink(){ |
|
60 |
return metadataLink; |
|
61 |
} |
|
62 |
|
|
63 |
public String getDescription(){ |
|
64 |
return description; |
|
65 |
} |
|
66 |
|
|
67 |
public String getName(){ |
|
68 |
return name; |
|
69 |
} |
|
70 |
|
|
71 |
public String getLabel(){ |
|
72 |
return label; |
|
73 |
} |
|
74 |
|
|
75 |
public ArrayList getSingleValues(){ |
|
76 |
if (!values.getSingleValueList().isEmpty()) return values.getSingleValueList(); |
|
77 |
return null; |
|
78 |
} |
|
79 |
|
|
80 |
|
|
81 |
public String getValuesType(){ |
|
82 |
return values.getValuesType(); |
|
83 |
|
|
84 |
} |
|
85 |
|
|
86 |
public Interval getInterval(){ |
|
87 |
return values.getInterval(); |
|
88 |
} |
|
89 |
|
|
90 |
public String getDefault(){ |
|
91 |
return Default; |
|
92 |
} |
|
93 |
|
|
94 |
public String toString(){ |
|
95 |
return "\nName: "+name+ |
|
96 |
"\nLabel: "+label+ |
|
97 |
"\nDescription: "+description+ |
|
98 |
"\nReference system: "+refSys+ |
|
99 |
"\nReference system label: "+refSysLabel+ |
|
100 |
"\nSemantic: "+semantic+ |
|
101 |
"\nMetadata Link: "+metadataLink; |
|
102 |
//+ |
|
103 |
// "\nValues: "+getValues(); |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
|
|
108 |
|
|
0 | 109 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/DCPType.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* DCPType.java |
|
4 |
* |
|
5 |
* Created on 26 de diciembre de 2004, 19:36 |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* This file implements the DCPType class. For the moment, HTTP is the only DCP |
|
10 |
* defined and for now, a server may list either a GET or POST access point, or |
|
11 |
* both, for each operation. |
|
12 |
* @author jaume |
|
13 |
*/ |
|
14 |
|
|
15 |
|
|
16 |
public class DCPType { |
|
17 |
private AccessPoint httpGetOperationAccessPoint; |
|
18 |
private AccessPoint httpPostOperationAccessPoint; |
|
19 |
/** Creates a new instance of DCPType */ |
|
20 |
public DCPType(XMLNode node) { |
|
21 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
22 |
|
|
23 |
// This is the only DCP defined until this version was released. You are welcomed |
|
24 |
// to upgrade this file for further future DCPs, just add more attributes to the |
|
25 |
// class and more cases to this loop. |
|
26 |
if (node.getSubNode(i).getName().equals("HTTP")){ |
|
27 |
XMLNode subNode = node.getSubNode(i); |
|
28 |
for (int j=0; j<subNode.getNumSubNodes(); j++){ |
|
29 |
if (WCSToolkit.isWCSTab(subNode.getSubNode(j), "Get")) |
|
30 |
httpGetOperationAccessPoint = new AccessPoint(subNode.getSubNode(j)); |
|
31 |
if (WCSToolkit.isWCSTab(subNode.getSubNode(j), "Post")) |
|
32 |
httpGetOperationAccessPoint = new AccessPoint(subNode.getSubNode(j)); |
|
33 |
} |
|
34 |
} |
|
35 |
} |
|
36 |
} |
|
37 |
|
|
38 |
public String toString(){ |
|
39 |
return "\nGet access point: "+httpGetOperationAccessPoint+ |
|
40 |
"\nPost access point: "+httpPostOperationAccessPoint; |
|
41 |
} |
|
42 |
} |
|
43 |
|
|
44 |
class AccessPoint { |
|
45 |
private String xlink_href; |
|
46 |
private String xlink_type; |
|
47 |
|
|
48 |
public AccessPoint(XMLNode node){ |
|
49 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
50 |
if (WCSToolkit.isWCSTab(node.getSubNode(i), "OnlineResource")){ |
|
51 |
xlink_href = node.getSubNode(i).getAttribute("xlink:href"); |
|
52 |
xlink_type = node.getSubNode(i).getAttribute("xlink:type"); |
|
53 |
} |
|
54 |
} |
|
55 |
} |
|
56 |
|
|
57 |
public String toString(){ |
|
58 |
return "(href="+xlink_href+", "+xlink_type+")"; |
|
59 |
} |
|
60 |
} |
|
0 | 61 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/TemporalDomain.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* TemporalDomain.java |
|
4 |
* |
|
5 |
* Created on 3 de enero de 2005, 16:09 |
|
6 |
*/ |
|
7 |
import java.util.*; |
|
8 |
/** |
|
9 |
* |
|
10 |
* @author jaume |
|
11 |
*/ |
|
12 |
public class TemporalDomain { |
|
13 |
private ArrayList gmlTimePositionList = new ArrayList(); |
|
14 |
private ArrayList timePeriodList = new ArrayList(); |
|
15 |
/** Creates a new instance of TemporalDomain */ |
|
16 |
public TemporalDomain(XMLNode node) { |
|
17 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
18 |
XMLNode subnode = node.getSubNode(i); |
|
19 |
if (WCSToolkit.isWCSTab(subnode, "gml:timePosition")) gmlTimePositionList.add(subnode.getText()); |
|
20 |
if (WCSToolkit.isWCSTab(subnode, "timePeriod")) timePeriodList.add(new TimePeriod(subnode)); |
|
21 |
} |
|
22 |
} |
|
23 |
public ArrayList getGMLTimePositionList(){ |
|
24 |
return gmlTimePositionList; |
|
25 |
} |
|
26 |
|
|
27 |
public ArrayList getTimePeriodList(){ |
|
28 |
return timePeriodList; |
|
29 |
} |
|
30 |
|
|
31 |
public String toString(){ |
|
32 |
Iterator it = gmlTimePositionList.iterator(); |
|
33 |
String s = "\nTIME PERIOD\ngml:timePosition(s): "; |
|
34 |
while (it.hasNext()){ |
|
35 |
s += it.next(); |
|
36 |
if (it.hasNext()) s += ", "; |
|
37 |
} |
|
38 |
it = timePeriodList.iterator(); |
|
39 |
s += "\ntimePeriod(s): "; |
|
40 |
while (it.hasNext()){ |
|
41 |
s += it.next(); |
|
42 |
if (it.hasNext()) s += ", "; |
|
43 |
} |
|
44 |
return s; |
|
45 |
} |
|
46 |
} |
|
0 | 47 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/ContentMetadata.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* ContentMetadata.java |
|
4 |
* |
|
5 |
* Created on 27 de diciembre de 2004, 12:45 |
|
6 |
*/ |
|
7 |
import java.util.*; |
|
8 |
/** |
|
9 |
* |
|
10 |
* @author jaume |
|
11 |
*/ |
|
12 |
public class ContentMetadata { |
|
13 |
private ArrayList coverageOfferingBriefList = new ArrayList(); |
|
14 |
private int numLayers; |
|
15 |
|
|
16 |
/** Creates a new instance of ContentMetadata */ |
|
17 |
public ContentMetadata(XMLNode node){ |
|
18 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
19 |
if (WCSToolkit.isWCSTab(node.getSubNode(i), "CoverageOfferingBrief")){ |
|
20 |
coverageOfferingBriefList.add(new CoverageOfferingBrief(node.getSubNode(i))); |
|
21 |
numLayers++; |
|
22 |
} |
|
23 |
} |
|
24 |
} |
|
25 |
|
|
26 |
public String toString(){ |
|
27 |
Iterator i = coverageOfferingBriefList.iterator(); |
|
28 |
String s = "\nNum layers: "+numLayers; |
|
29 |
while (i.hasNext()){ |
|
30 |
CoverageOfferingBrief aux = (CoverageOfferingBrief) i.next(); |
|
31 |
s += aux.toString(); |
|
32 |
} |
|
33 |
return s; |
|
34 |
} |
|
35 |
|
|
36 |
public int getNumLayers(){ |
|
37 |
return numLayers; |
|
38 |
} |
|
39 |
|
|
40 |
public CoverageOfferingBrief getCoverageOfferingBrief(String name){ |
|
41 |
// Tryes to get the brief description of the coverage named name |
|
42 |
// from the list. If it does not exist then returns null. |
|
43 |
|
|
44 |
Iterator i = coverageOfferingBriefList.iterator(); |
|
45 |
while (i.hasNext()){ |
|
46 |
CoverageOfferingBrief aux = (CoverageOfferingBrief) i.next(); |
|
47 |
if (aux.getName().equals(name)) return aux; |
|
48 |
} |
|
49 |
return null; |
|
50 |
} |
|
51 |
|
|
52 |
public ArrayList getCoverageOfferingBriefList(){ |
|
53 |
return coverageOfferingBriefList; |
|
54 |
} |
|
55 |
|
|
56 |
/* public ArrayList getLayerNames(){ |
|
57 |
ArrayList names; |
|
58 |
Iterator i = coverageOfferingBriefList.listIterator(); |
|
59 |
while (i.hasNext()){ |
|
60 |
names.add(((CoverageOfferingBrief) i.next()).getName()); |
|
61 |
} |
|
62 |
return names; |
|
63 |
}*/ |
|
64 |
} |
|
0 | 65 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/CoverageOffering.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
|
|
3 |
|
|
4 |
/* |
|
5 |
* CoverageOffering.java |
|
6 |
* |
|
7 |
* Created on 31 de diciembre de 2004, 15:25 |
|
8 |
*/ |
|
9 |
|
|
10 |
/** |
|
11 |
* |
|
12 |
* @author jaume |
|
13 |
*/ |
|
14 |
public class CoverageOffering { |
|
15 |
private CoverageOfferingBrief coverageOfferingBrief; |
|
16 |
private DomainSet domainSet; |
|
17 |
private RangeSet rangeSet; |
|
18 |
private SupportedCRSs supportedCRSs; |
|
19 |
private SupportedFormats supportedFormats; |
|
20 |
private SupportedInterpolations supportedInterpolations; |
|
21 |
|
|
22 |
/** Creates a new instance of CoverageOffering */ |
|
23 |
public CoverageOffering(XMLNode node, Capabilities capabilities) { |
|
24 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
25 |
XMLNode subnode = node.getSubNode(i); |
|
26 |
if (WCSToolkit.isWCSTab(subnode, "name")){ |
|
27 |
// CoverageOffering type is composed from the already known |
|
28 |
// CoverageOfferingBrief and others. Don't need to read the |
|
29 |
// CoverageOfferingBrief again, just use the previous loaded |
|
30 |
// one when GetCapabilities operation was performed. |
|
31 |
coverageOfferingBrief = capabilities.getContentMetadata().getCoverageOfferingBrief(subnode.getText()); |
|
32 |
} |
|
33 |
if (WCSToolkit.isWCSTab(subnode, "domainSet")) domainSet = new DomainSet(subnode); |
|
34 |
if (WCSToolkit.isWCSTab(subnode, "rangeSet")) rangeSet = new RangeSet(subnode); |
|
35 |
if (WCSToolkit.isWCSTab(subnode, "supportedCRSs")) supportedCRSs = new SupportedCRSs(subnode); |
|
36 |
if (WCSToolkit.isWCSTab(subnode, "supportedFormats")) supportedFormats = new SupportedFormats(subnode); |
|
37 |
if (WCSToolkit.isWCSTab(subnode, "supportedInterpolations")) supportedInterpolations = new SupportedInterpolations(subnode); |
|
38 |
} |
|
39 |
|
|
40 |
} |
|
41 |
|
|
42 |
public DomainSet getDomainSet(){ |
|
43 |
return domainSet; |
|
44 |
} |
|
45 |
|
|
46 |
public RangeSet getRangeSet(){ |
|
47 |
return rangeSet; |
|
48 |
} |
|
49 |
|
|
50 |
public SupportedCRSs getSupportedCRSs(){ |
|
51 |
return supportedCRSs; |
|
52 |
} |
|
53 |
|
|
54 |
public SupportedFormats getSupportedFormats(){ |
|
55 |
return supportedFormats; |
|
56 |
} |
|
57 |
|
|
58 |
public SupportedInterpolations getSupportedInterpolations(){ |
|
59 |
return supportedInterpolations; |
|
60 |
} |
|
61 |
|
|
62 |
public CoverageOfferingBrief getCoverageOfferingBrief(){ |
|
63 |
return coverageOfferingBrief; |
|
64 |
} |
|
65 |
|
|
66 |
public String toString(){ |
|
67 |
String s = "\nCOVERAGE OFFERING"; |
|
68 |
|
|
69 |
return "\n"+getCoverageOfferingBrief()+ |
|
70 |
"\n"+getDomainSet()+ |
|
71 |
"\n"+getRangeSet()+ |
|
72 |
"\n"+getRangeSet()+ |
|
73 |
"\n"+getSupportedCRSs()+ |
|
74 |
"\n"+getSupportedFormats()+ |
|
75 |
"\n"+getSupportedInterpolations(); |
|
76 |
} |
|
77 |
} |
|
0 | 78 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/DescribeCoverageResponse.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* DescribeCoverage.java |
|
4 |
* |
|
5 |
* Created on 31 de diciembre de 2004, 15:03 |
|
6 |
*/ |
|
7 |
import java.util.*; |
|
8 |
import java.io.*; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* @author jaume |
|
14 |
*/ |
|
15 |
public class DescribeCoverageResponse { |
|
16 |
private String version; |
|
17 |
private String updateSequence; |
|
18 |
private ArrayList coverageOfferingList = new ArrayList(); |
|
19 |
|
|
20 |
/** Creates a new instance of DescribeCoverage */ |
|
21 |
public DescribeCoverageResponse(XMLNode node, Capabilities capabilities) { |
|
22 |
fillupDescribeCoverage(node, capabilities); |
|
23 |
} |
|
24 |
|
|
25 |
public DescribeCoverageResponse(File file, Capabilities capabilities){ |
|
26 |
// for debugging purposes only |
|
27 |
try { |
|
28 |
XMLNode node = new XMLNode(file); |
|
29 |
fillupDescribeCoverage(node, capabilities); |
|
30 |
} catch (Exception e){ |
|
31 |
System.out.println("Exception: " + e.getMessage()); |
|
32 |
} |
|
33 |
} |
|
34 |
|
|
35 |
public void fillupDescribeCoverage(XMLNode node, Capabilities capabilities){ |
|
36 |
try{ |
|
37 |
checkDescribeCoverageDocument(node); |
|
38 |
for (int i=0; i<node.getNumSubNodes(); i++){ |
|
39 |
XMLNode subnode = node.getSubNode(i); |
|
40 |
|
|
41 |
if (WCSToolkit.isWCSTab(subnode, "CoverageOffering")) coverageOfferingList.add(new CoverageOffering(subnode, capabilities)); |
|
42 |
} |
|
43 |
} catch (NotAnDescribeCoverageXmlDocumentException e){ |
|
44 |
new Error("Unrecognized DescribeCapabilities format"); |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
48 |
public boolean checkDescribeCoverageDocument(XMLNode node) throws NotAnDescribeCoverageXmlDocumentException{ |
|
49 |
if (WCSToolkit.isWCSTab(node, "CoverageDescription")){ |
|
50 |
version = node.getAttribute("version"); |
|
51 |
updateSequence = node.getAttribute("updateSequence"); |
|
52 |
return true; |
|
53 |
} else throw new NotAnDescribeCoverageXmlDocumentException(); |
|
54 |
} |
|
55 |
|
|
56 |
public String getVersion(){ |
|
57 |
return version; |
|
58 |
} |
|
59 |
|
|
60 |
public String getUpdateSequence(){ |
|
61 |
return updateSequence; |
|
62 |
} |
|
63 |
|
|
64 |
public ArrayList getCoverageOfferingList(){ |
|
65 |
return coverageOfferingList; |
|
66 |
} |
|
67 |
|
|
68 |
public CoverageOffering getCoverageOffering(String coverage_name){ |
|
69 |
// returns the coverage named coverage_name from the list |
|
70 |
Iterator it = coverageOfferingList.iterator(); |
|
71 |
while (it.hasNext()){ |
|
72 |
CoverageOffering co = (CoverageOffering) it.next(); |
|
73 |
if (co.getCoverageOfferingBrief().getName().equals(coverage_name)){ |
|
74 |
return co; |
|
75 |
} |
|
76 |
} |
|
77 |
return null; |
|
78 |
} |
|
79 |
|
|
80 |
public String toString(){ |
|
81 |
Iterator it = coverageOfferingList.iterator(); |
|
82 |
String s = ""; |
|
83 |
while (it.hasNext()){ |
|
84 |
s += "\nNext item: "+it.next(); |
|
85 |
} |
|
86 |
return "\nDESCRIBE COVERAGE"+ |
|
87 |
"\nVersion: "+version+ |
|
88 |
"\nUpdate Sequence: "+updateSequence+ |
|
89 |
"\nCoverage Offering list: "+s; |
|
90 |
} |
|
91 |
|
|
92 |
} |
|
93 |
|
|
94 |
class NotAnDescribeCoverageXmlDocumentException extends Exception{ |
|
95 |
public NotAnDescribeCoverageXmlDocumentException(){ |
|
96 |
super(); |
|
97 |
} |
|
98 |
|
|
99 |
public NotAnDescribeCoverageXmlDocumentException(String s){ |
|
100 |
super(s); |
|
101 |
} |
|
102 |
} |
|
0 | 103 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/SingleValue.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* SingleValue.java |
|
4 |
* |
|
5 |
* Created on 27 de enero de 2005, 21:03 |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* |
|
10 |
* @author jaume |
|
11 |
*/ |
|
12 |
public class SingleValue{ |
|
13 |
private String semantic; |
|
14 |
private String type; |
|
15 |
private String value; |
|
16 |
|
|
17 |
public SingleValue(XMLNode node){ |
|
18 |
semantic = node.getAttribute("semantic"); |
|
19 |
type = node.getAttribute("type"); |
|
20 |
value = node.getText(); |
|
21 |
} |
|
22 |
|
|
23 |
public String getSemantic(){ |
|
24 |
return semantic; |
|
25 |
} |
|
26 |
|
|
27 |
public String getType(){ |
|
28 |
return type; |
|
29 |
} |
|
30 |
public String getValue(){ |
|
31 |
return value; |
|
32 |
} |
|
33 |
} |
|
0 | 34 |
tags/Root_gvSIG_WCS04/extensions/extWCS/src4/es/uji/lsi/wcs/XmlWcsParsing/SupportedCRSs.java | ||
---|---|---|
1 |
package es.uji.lsi.wcs.XmlWcsParsing; |
|
2 |
/* |
|
3 |
* SupportedCRCs.java |
|
4 |
* |
|
5 |
* Created on 13 de enero de 2005, 14:21 |
Also available in: Unified diff