Revision 25376
tags/tmp_build/libraries/libGPE/src/javax/xml/namespace/QName.java | ||
---|---|---|
1 |
package javax.xml.namespace; |
|
2 |
|
|
3 |
/* JBoss, the OpenSource WebOS |
|
4 |
* |
|
5 |
* Distributable under LGPL license. |
|
6 |
* See terms of license at gnu.org. |
|
7 |
*/ |
|
8 |
|
|
9 |
// $Id: QName.java,v 1.2.6.8 2005/04/12 03:35:26 starksm Exp $ |
|
10 |
|
|
11 |
import java.io.Serializable; |
|
12 |
import java.util.StringTokenizer; |
|
13 |
|
|
14 |
/** QName represents an immutable qualified name. |
|
15 |
* The value of a QName contains a Namespace URI, local part and prefix. |
|
16 |
* |
|
17 |
* The prefix is included in QName to retain lexical information when present |
|
18 |
* in an XML input source. The prefix is NOT used in QName.equals(Object) or |
|
19 |
* to compute the QName.hashCode(). Equality and the hash code are defined |
|
20 |
* using only the Namespace URI and local part. |
|
21 |
* |
|
22 |
* If not specified, the Namespace URI is set to "" (the empty string). |
|
23 |
* If not specified, the prefix is set to "" (the empty string). |
|
24 |
* |
|
25 |
* @author Scott.Stark@jboss.org |
|
26 |
* @author Thomas.Diesler@jboss.org |
|
27 |
* @author Jeff Suttor (javadoc) |
|
28 |
* @version $Revision: 1.2.6.8 $ |
|
29 |
*/ |
|
30 |
public class QName implements Serializable |
|
31 |
{ |
|
32 |
/** @since 4.0.2, compatible with jdk5 by default */ |
|
33 |
final static long serialVersionUID; |
|
34 |
static |
|
35 |
{ |
|
36 |
serialVersionUID = -3852060120346905000L; |
|
37 |
} |
|
38 |
|
|
39 |
private String namespaceURI; |
|
40 |
private String localPart; |
|
41 |
private String prefix; |
|
42 |
|
|
43 |
/** QName derived from parsing the formatted String. |
|
44 |
* If the String is null or does not conform to QName.toString() formatting, |
|
45 |
* an IllegalArgumentException is thrown. |
|
46 |
* |
|
47 |
* The String MUST be in the form returned by QName.toString(). There is NO |
|
48 |
* standard specification for representing a QName as a String. The String |
|
49 |
* format is NOT portable across implementations and will change when a |
|
50 |
* standard String representation is defined. This implementation currently |
|
51 |
* parses a String formatted as: "{" + Namespace URI + "}" + local part. If |
|
52 |
* the Namespace URI .equals(""), only the local part should be provided. |
|
53 |
* |
|
54 |
* The prefix value CANNOT be represented in the String and will be set to "" |
|
55 |
* |
|
56 |
* This method does not do full validation of the resulting QName. In |
|
57 |
* particular, the local part is not validated as a NCName as specified in |
|
58 |
* Namespaces in XML. |
|
59 |
* |
|
60 |
* @see #toString() |
|
61 |
* @param toStringName - a QName string in the format of toString(). |
|
62 |
* @return QName for the toStringName |
|
63 |
*/ |
|
64 |
public static QName valueOf(String toStringName) |
|
65 |
{ |
|
66 |
String uri = null; |
|
67 |
String localPart = null; |
|
68 |
|
|
69 |
StringTokenizer tokenizer = new StringTokenizer(toStringName, "{}"); |
|
70 |
int tokenCount = tokenizer.countTokens(); |
|
71 |
|
|
72 |
if (tokenCount < 1 || tokenCount > 2) |
|
73 |
throw new IllegalArgumentException("Invalid QName string: " + toStringName); |
|
74 |
|
|
75 |
if (tokenCount > 1) |
|
76 |
uri = tokenizer.nextToken(); |
|
77 |
|
|
78 |
localPart = tokenizer.nextToken(); |
|
79 |
return new QName(uri, localPart); |
|
80 |
} |
|
81 |
|
|
82 |
public QName(String localPart) |
|
83 |
{ |
|
84 |
this(null, localPart); |
|
85 |
} |
|
86 |
|
|
87 |
public QName(String namespaceURI, String localPart) |
|
88 |
{ |
|
89 |
this(namespaceURI, localPart, ""); |
|
90 |
} |
|
91 |
|
|
92 |
/** QName constructor specifying the Namespace URI, local part and prefix. |
|
93 |
* If the Namespace URI is null, it is set to "". This value represents no |
|
94 |
* explicitly defined Namespace as defined by the Namespaces in XML |
|
95 |
* specification. This action preserves compatible behavior with QName 1.0. |
|
96 |
* |
|
97 |
* If the local part is null, an IllegalArgumentException is thrown. |
|
98 |
* |
|
99 |
* If the prefix is null, an IllegalArgumentException is thrown. Use "" to |
|
100 |
* explicitly indicate that no prefix is present or the prefix is not |
|
101 |
* relevant. |
|
102 |
* |
|
103 |
* @param namespaceURI - Namespace URI of the QName |
|
104 |
* @param localPart - local part of the QName |
|
105 |
* @param prefix - prefix of the QName |
|
106 |
*/ |
|
107 |
public QName(String namespaceURI, String localPart, String prefix) |
|
108 |
{ |
|
109 |
this.namespaceURI = namespaceURI; |
|
110 |
if (this.namespaceURI == null) |
|
111 |
this.namespaceURI = ""; |
|
112 |
|
|
113 |
if (localPart == null) |
|
114 |
throw new IllegalArgumentException("localPart cannot be null"); |
|
115 |
|
|
116 |
if (localPart.startsWith(":")) |
|
117 |
throw new IllegalArgumentException("Illegal localPart: " + localPart); |
|
118 |
|
|
119 |
this.localPart = localPart; |
|
120 |
|
|
121 |
this.prefix = prefix; |
|
122 |
if (this.prefix == null) |
|
123 |
this.prefix = ""; |
|
124 |
} |
|
125 |
|
|
126 |
public String getNamespaceURI() |
|
127 |
{ |
|
128 |
return namespaceURI; |
|
129 |
} |
|
130 |
|
|
131 |
public String getLocalPart() |
|
132 |
{ |
|
133 |
return localPart; |
|
134 |
} |
|
135 |
|
|
136 |
public String getPrefix() |
|
137 |
{ |
|
138 |
return prefix; |
|
139 |
} |
|
140 |
|
|
141 |
/** There is NO standard specification for representing a QName as a String. |
|
142 |
* The returned String is not portable across implementations and will change when a standard String representation is defined. |
|
143 |
* This implementation currently represents a QName as: "{" + Namespace URI + "}" + local part. |
|
144 |
* If the Namespace URI .equals(""), only the local part is returned. |
|
145 |
* An appropriate use of this method is for debugging or logging for human consumption. |
|
146 |
* |
|
147 |
* Note the prefix value is NOT returned as part of the String representation. |
|
148 |
* |
|
149 |
* @return '{' + namespaceURI + '}' + localPart |
|
150 |
*/ |
|
151 |
public String toString() |
|
152 |
{ |
|
153 |
if (namespaceURI.equals("")) |
|
154 |
return localPart; |
|
155 |
else |
|
156 |
return '{' + namespaceURI + '}' + localPart; |
|
157 |
} |
|
158 |
|
|
159 |
/** Equality is based on the namespaceURI and localPart |
|
160 |
* @param obj the QName to compare too |
|
161 |
* @return true if both namespaceURI and localPart, false otherwise |
|
162 |
*/ |
|
163 |
public boolean equals(Object obj) |
|
164 |
{ |
|
165 |
if (obj instanceof QName) |
|
166 |
{ |
|
167 |
QName qn = (QName)obj; |
|
168 |
boolean equals = namespaceURI.equals(qn.namespaceURI); |
|
169 |
return equals && localPart.equals(qn.localPart); |
|
170 |
} |
|
171 |
return false; |
|
172 |
} |
|
173 |
|
|
174 |
/** Calculate the hash of namespaceURI and localPart |
|
175 |
* @return namespaceURI.hashCode() + localPart.hashCode() |
|
176 |
*/ |
|
177 |
public int hashCode() |
|
178 |
{ |
|
179 |
int hashCode = namespaceURI.hashCode() + localPart.hashCode(); |
|
180 |
return hashCode; |
|
181 |
} |
|
182 |
|
|
183 |
/** |
|
184 |
* Compares this object with the specified object for order. Returns a |
|
185 |
* negative integer, zero, or a positive integer as this object is less |
|
186 |
* than, equal to, or greater than the specified object.<p> |
|
187 |
*/ |
|
188 |
public int compareTo(Object o) |
|
189 |
{ |
|
190 |
QName other = (QName)o; |
|
191 |
return toString().compareTo(other.toString()); |
|
192 |
} |
|
193 |
} |
|
194 |
|
tags/tmp_build/libraries/libGPE/src/META-INF/services/org.gvsig.gpe.IGPEProperties | ||
---|---|---|
1 |
org.gvsig.gpe.GPEProperties |
tags/tmp_build/libraries/libGPE/src/org/gvsig/gpe/GPEDefaults.java | ||
---|---|---|
1 |
package org.gvsig.gpe; |
|
2 |
|
|
3 |
import java.util.Iterator; |
|
4 |
import java.util.Properties; |
|
5 |
|
|
6 |
import org.gvsig.gpe.parser.GPEParser; |
|
7 |
|
|
8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
9 |
* |
|
10 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or |
|
13 |
* modify it under the terms of the GNU General Public License |
|
14 |
* as published by the Free Software Foundation; either version 2 |
|
15 |
* of the License, or (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
25 |
* |
|
26 |
* For more information, contact: |
|
27 |
* |
|
28 |
* Generalitat Valenciana |
|
29 |
* Conselleria d'Infraestructures i Transport |
|
30 |
* Av. Blasco Ib??ez, 50 |
|
31 |
* 46010 VALENCIA |
|
32 |
* SPAIN |
|
33 |
* |
|
34 |
* +34 963862235 |
|
35 |
* gvsig@gva.es |
|
36 |
* www.gvsig.gva.es |
|
37 |
* |
|
38 |
* or |
|
39 |
* |
|
40 |
* IVER T.I. S.A |
|
41 |
* Salamanca 50 |
|
42 |
* 46005 Valencia |
|
43 |
* Spain |
|
44 |
* |
|
45 |
* +34 963163400 |
|
46 |
* dac@iver.es |
|
47 |
*/ |
|
48 |
/* CVS MESSAGES: |
|
49 |
* |
|
50 |
* $Id: GPEDefaults.java 373 2008-01-10 09:33:05Z jpiera $ |
|
51 |
* $Log$ |
|
52 |
* Revision 1.10 2007/06/20 09:35:37 jorpiell |
|
53 |
* Add the javadoc comments |
|
54 |
* |
|
55 |
* Revision 1.9 2007/06/07 14:52:28 jorpiell |
|
56 |
* Add the schema support |
|
57 |
* |
|
58 |
* Revision 1.8 2007/05/15 10:39:14 jorpiell |
|
59 |
* Add the number of decimals property |
|
60 |
* |
|
61 |
* Revision 1.7 2007/05/15 09:34:39 jorpiell |
|
62 |
* the tag names cant have blanc spaces |
|
63 |
* |
|
64 |
* Revision 1.6 2007/04/26 14:23:16 jorpiell |
|
65 |
* Add a getStringProperty method |
|
66 |
* |
|
67 |
* Revision 1.5 2007/04/19 11:50:20 csanchez |
|
68 |
* Actualizacion protoripo libGPE |
|
69 |
* |
|
70 |
* Revision 1.4 2007/04/18 11:03:36 jorpiell |
|
71 |
* Add the default schema property |
|
72 |
* |
|
73 |
* Revision 1.3 2007/04/14 16:06:13 jorpiell |
|
74 |
* The writer handler has been updated |
|
75 |
* |
|
76 |
* Revision 1.2 2007/04/12 17:06:42 jorpiell |
|
77 |
* First GML writing tests |
|
78 |
* |
|
79 |
* Revision 1.1 2007/04/12 11:39:20 jorpiell |
|
80 |
* Add the GPEDefaults class |
|
81 |
* |
|
82 |
* |
|
83 |
*/ |
|
84 |
/** |
|
85 |
* This class is used to add properties that can be used |
|
86 |
* by the GPE parsers and writers. |
|
87 |
* <p> |
|
88 |
* It is not possible for the consumer application to have any |
|
89 |
* dependence with a concrete parser or writer. But sometimes it |
|
90 |
* is necessary to establish some configuration parameters |
|
91 |
* (principally to write). This class provides a mechanism to |
|
92 |
* set all these parameters using the SPI (Service Provider Interface) |
|
93 |
* mechanism |
|
94 |
* </p> |
|
95 |
* <h2>Implementation Lookup</h2> |
|
96 |
* <p> |
|
97 |
* The SPI provides a mechanism to register a set of properties that |
|
98 |
* both the parsers and the writers need to work. Every parser (or writer) |
|
99 |
* is the responsible to create a set of parameters and register them |
|
100 |
* in this class |
|
101 |
* </p> |
|
102 |
* <p> |
|
103 |
* To register a set of properties a file named <code>org.gvsig.gpe.IGPEProperties</code> |
|
104 |
* shall exist in the class path in the implementation's <code>META-INF/services</code> folder. |
|
105 |
* </p> |
|
106 |
* <p> |
|
107 |
* The content of the files for a given implementation consists of full qualified |
|
108 |
* class names, one per line. For example, an hypotetical <code>MyParserProperties</code> |
|
109 |
* in the package <code>org.gvsi.gpe.format</code> and bundled in a jar file |
|
110 |
* called <code>org.gvsig.gpe.format.jar</code> shall provide the following |
|
111 |
* resources: |
|
112 |
* |
|
113 |
* <pre> |
|
114 |
* <code> |
|
115 |
* $jar tvf org.gvsi.gpe.format.jar |
|
116 |
* META-INF/services/org.gvsig.gpe.IGPEProperties |
|
117 |
* org/gvsig/gpe/MyParserProperties.class |
|
118 |
* </code> |
|
119 |
* </pre> |
|
120 |
* |
|
121 |
* And the content of the file <code>META-INF/services/org.gvsig.gpe.IGPEProperties</code> |
|
122 |
* shall be a single line of text with the <code>org.gpe.gpe.format</code> class name. |
|
123 |
* |
|
124 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
125 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es) |
|
126 |
*/ |
|
127 |
public class GPEDefaults { |
|
128 |
private static Properties properties = new Properties(); |
|
129 |
|
|
130 |
static{ |
|
131 |
Iterator providers = availableProperties(); |
|
132 |
while (providers.hasNext()) { |
|
133 |
IGPEProperties next = (IGPEProperties) providers.next(); |
|
134 |
Properties parserProperties = next.getProperties(); |
|
135 |
Iterator it = parserProperties.keySet().iterator(); |
|
136 |
while (it.hasNext()){ |
|
137 |
String key = (String)it.next(); |
|
138 |
properties.put(key, parserProperties.get(key)); |
|
139 |
} |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 |
/** |
|
144 |
* Returns an iterator over instances of the registered GPE properties. |
|
145 |
* @return all the registered GPE properties |
|
146 |
*/ |
|
147 |
private static Iterator availableProperties() { |
|
148 |
Iterator providers = sun.misc.Service.providers(IGPEProperties.class); |
|
149 |
return providers; |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* Returns an iterator with the name of all the properties that |
|
154 |
* has been established. |
|
155 |
*/ |
|
156 |
public static Iterator getKeys(){ |
|
157 |
return properties.keySet().iterator(); |
|
158 |
} |
|
159 |
|
|
160 |
/** |
|
161 |
* Gets a String property |
|
162 |
* @param key |
|
163 |
* Property name |
|
164 |
* @return |
|
165 |
*/ |
|
166 |
public static String getStringProperty(String key){ |
|
167 |
Object obj = getProperty(key); |
|
168 |
if (obj == null){ |
|
169 |
return null; |
|
170 |
} |
|
171 |
return (String)obj; |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* Gets a int property |
|
176 |
* @param key |
|
177 |
* Property name |
|
178 |
* @return |
|
179 |
* The int property or -1 |
|
180 |
*/ |
|
181 |
public static int getIntPropertyProperty(String key){ |
|
182 |
Object obj = getProperty(key); |
|
183 |
if (obj == null){ |
|
184 |
return -1; |
|
185 |
} |
|
186 |
if (obj instanceof Integer){ |
|
187 |
return ((Integer)obj).intValue(); |
|
188 |
}return -1; |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Gets a boolean property. If the property doesn't exist |
|
193 |
* it returns false. |
|
194 |
* @param key |
|
195 |
* Property name |
|
196 |
* @return |
|
197 |
* The boolean property or false |
|
198 |
*/ |
|
199 |
public static boolean getBooleanProperty(String key){ |
|
200 |
Object obj = getProperty(key); |
|
201 |
if (obj == null){ |
|
202 |
return false; |
|
203 |
} |
|
204 |
if (obj instanceof Boolean){ |
|
205 |
return ((Boolean)obj).booleanValue(); |
|
206 |
}return false; |
|
207 |
} |
|
208 |
|
|
209 |
/** |
|
210 |
* Gets a property |
|
211 |
* @param key |
|
212 |
* Property name |
|
213 |
* @return |
|
214 |
*/ |
|
215 |
public static Object getProperty(String key){ |
|
216 |
return properties.get(key); |
|
217 |
} |
|
218 |
|
|
219 |
/** |
|
220 |
* Sets a property |
|
221 |
* @param key |
|
222 |
* @param value |
|
223 |
*/ |
|
224 |
public static void setProperty(String key, Object value){ |
|
225 |
properties.put(key, value); |
|
226 |
} |
|
227 |
|
|
228 |
|
|
229 |
} |
|
0 | 230 |
tags/tmp_build/libraries/libGPE/src/org/gvsig/gpe/GPEFactory.java | ||
---|---|---|
1 |
package org.gvsig.gpe; |
|
2 |
|
|
3 |
import java.net.URI; |
|
4 |
import java.util.Iterator; |
|
5 |
|
|
6 |
import org.gvsig.gpe.exceptions.ParserCreationException; |
|
7 |
import org.gvsig.gpe.exceptions.ParserFileNotSupportedException; |
|
8 |
import org.gvsig.gpe.exceptions.ParserMimetypeNotSupportedException; |
|
9 |
import org.gvsig.gpe.exceptions.ParserNameNotFoundException; |
|
10 |
import org.gvsig.gpe.exceptions.ParserNotRegisteredException; |
|
11 |
import org.gvsig.gpe.exceptions.WriterHandlerCreationException; |
|
12 |
import org.gvsig.gpe.exceptions.WriterHandlerMimeTypeNotSupportedException; |
|
13 |
import org.gvsig.gpe.exceptions.WriterHandlerNotRegisteredException; |
|
14 |
import org.gvsig.gpe.parser.GPEParser; |
|
15 |
import org.gvsig.gpe.writer.GPEWriterHandler; |
|
16 |
import org.gvsig.gpe.writer.IGPEWriterHandlerImplementor; |
|
17 |
|
|
18 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
19 |
* |
|
20 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
21 |
* |
|
22 |
* This program is free software; you can redistribute it and/or |
|
23 |
* modify it under the terms of the GNU General Public License |
|
24 |
* as published by the Free Software Foundation; either version 2 |
|
25 |
* of the License, or (at your option) any later version. |
|
26 |
* |
|
27 |
* This program is distributed in the hope that it will be useful, |
|
28 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
29 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
30 |
* GNU General Public License for more details. |
|
31 |
* |
|
32 |
* You should have received a copy of the GNU General Public License |
|
33 |
* along with this program; if not, write to the Free Software |
|
34 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
35 |
* |
|
36 |
* For more information, contact: |
|
37 |
* |
|
38 |
* Generalitat Valenciana |
|
39 |
* Conselleria d'Infraestructures i Transport |
|
40 |
* Av. Blasco Ib??ez, 50 |
|
41 |
* 46010 VALENCIA |
|
42 |
* SPAIN |
|
43 |
* |
|
44 |
* +34 963862235 |
|
45 |
* gvsig@gva.es |
|
46 |
* www.gvsig.gva.es |
|
47 |
* |
|
48 |
* or |
|
49 |
* |
|
50 |
* IVER T.I. S.A |
|
51 |
* Salamanca 50 |
|
52 |
* 46005 Valencia |
|
53 |
* Spain |
|
54 |
* |
|
55 |
* +34 963163400 |
|
56 |
* dac@iver.es |
|
57 |
*/ |
|
58 |
/* CVS MESSAGES: |
|
59 |
* |
|
60 |
* $Id: GPERegister.java 282 2007-12-20 11:55:56Z jpiera $ |
|
61 |
* $Log$ |
|
62 |
* Revision 1.16 2007/06/28 13:04:33 jorpiell |
|
63 |
* The Qname has been updated to the 1.5 JVM machine. The schema validation is made in the GPEWriterHandlerImplementor class |
|
64 |
* |
|
65 |
* Revision 1.15 2007/06/20 09:35:37 jorpiell |
|
66 |
* Add the javadoc comments |
|
67 |
* |
|
68 |
* Revision 1.14 2007/05/16 12:34:55 csanchez |
|
69 |
* GPEParser Prototipo final de lectura |
|
70 |
* |
|
71 |
* Revision 1.13 2007/05/09 06:54:07 jorpiell |
|
72 |
* Change the File by URI |
|
73 |
* |
|
74 |
* Revision 1.12 2007/05/08 12:57:14 jorpiell |
|
75 |
* Add the register exceptions |
|
76 |
* |
|
77 |
* Revision 1.11 2007/05/07 07:06:26 jorpiell |
|
78 |
* Add a constructor with the name and the description fields |
|
79 |
* |
|
80 |
* Revision 1.10 2007/04/19 11:50:20 csanchez |
|
81 |
* Actualizacion protoripo libGPE |
|
82 |
* |
|
83 |
* Revision 1.9 2007/04/19 07:23:20 jorpiell |
|
84 |
* Add the add methods to teh contenhandler and change the register mode |
|
85 |
* |
|
86 |
* Revision 1.8 2007/04/18 12:54:45 csanchez |
|
87 |
* Actualizacion protoripo libGPE |
|
88 |
* |
|
89 |
* Revision 1.7 2007/04/17 07:53:55 jorpiell |
|
90 |
* Before to start a new parsing process, the initialize method of the content handlers is throwed |
|
91 |
* |
|
92 |
* Revision 1.6 2007/04/17 06:26:54 jorpiell |
|
93 |
* Fixed one problem with a index |
|
94 |
* |
|
95 |
* Revision 1.5 2007/04/14 16:06:13 jorpiell |
|
96 |
* The writer handler has been updated |
|
97 |
* |
|
98 |
* Revision 1.4 2007/04/12 17:06:42 jorpiell |
|
99 |
* First GML writing tests |
|
100 |
* |
|
101 |
* Revision 1.3 2007/04/11 11:10:27 jorpiell |
|
102 |
* Cambiado el nombre de getDriver a GetParser |
|
103 |
* |
|
104 |
* Revision 1.2 2007/04/11 08:54:24 jorpiell |
|
105 |
* A?adidos algunos comentarios |
|
106 |
* |
|
107 |
* Revision 1.1 2007/04/11 08:52:55 jorpiell |
|
108 |
* Se puede registrar una clase por nombre |
|
109 |
* |
|
110 |
* Revision 1.1 2007/04/11 08:22:41 jorpiell |
|
111 |
* GPE clase para registrar los drivers |
|
112 |
* |
|
113 |
* |
|
114 |
*/ |
|
115 |
/** |
|
116 |
* API entry point to create parsers and writers based on MIME-Type identification. |
|
117 |
* <p> |
|
118 |
* This factory uses a SPI (Service Provider Interface) mechanism to look up for {@link GPEParser} |
|
119 |
* and {@link IGPEWriterHandlerImplementor} implementations that can deal with a requested |
|
120 |
* MIME-Type. |
|
121 |
* </p> |
|
122 |
* <h2>Implementation Lookup</h2> |
|
123 |
* <p> |
|
124 |
* The SPI mechanism keeps parser implementations decoupled from client applications allowing the |
|
125 |
* transparent interchange of implementation, thus defining a format plugin system. |
|
126 |
* </p> |
|
127 |
* <p> |
|
128 |
* Parser and Writer implementations registers themselves lazily by providing a small configuration |
|
129 |
* file bundled together with the rest of the implementation resources. This configuration file |
|
130 |
* consist of a text file at a specific location and with an specific file name, this factory look |
|
131 |
* up mechanism will search for in order to find out the implementation class names. |
|
132 |
* </p> |
|
133 |
* <p> |
|
134 |
* To register a GPEParser implememntation, a file named <code>org.gvsig.gpe.parser.GPEParser</code> |
|
135 |
* shall exist in the class path (hence the ability to have multiple files equally namded budled in |
|
136 |
* different jar files), in the implementation's <code>META-INF/services</code> folder. |
|
137 |
* </p> |
|
138 |
* <p> |
|
139 |
* To register a Writer handler implementation, the same approach shall be followed with a file |
|
140 |
* named <code>META-INF/services/org.gvsig.gpe.writer.IGPEWriterHandlerImplementor</code> |
|
141 |
* </p> |
|
142 |
* <p> |
|
143 |
* The content of both files for a given implementation consists of full qualified class names, one |
|
144 |
* per line. For example, an hypotetical <code>MyFormatParser</code> in the package |
|
145 |
* <code>org.mycompany.gpe</code> and bundled in a jar file called <code>myformat.jar</code> |
|
146 |
* shall provide the following resources: |
|
147 |
* |
|
148 |
* <pre> |
|
149 |
* <code> |
|
150 |
* $jar tvf myformat.jar |
|
151 |
* META-INF/services/org.gvsig.gpe.parser.GPEParser |
|
152 |
* org/mycompany/gpe/MyFormatParser.class |
|
153 |
* </code> |
|
154 |
* </pre> |
|
155 |
* |
|
156 |
* And the content of the file <code>META-INF/services/org.gvsig.gpe.parser.GPEParser</code> shall |
|
157 |
* be a single line of text with the <code>org.mycompany.gpe.MyFormatParser</code> class name. |
|
158 |
* |
|
159 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
160 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es) |
|
161 |
*/ |
|
162 |
public class GPEFactory { |
|
163 |
|
|
164 |
/** |
|
165 |
* Returns an iterator over instances of the registered parsers. |
|
166 |
* <p> |
|
167 |
* NOTE: since GPEParser is an abstract and statefull class rather than an interface, this |
|
168 |
* method shall stay private in order to ensure we return a new instance for the required format |
|
169 |
* every time. |
|
170 |
* </p> |
|
171 |
* |
|
172 |
* @return all the registered parsers |
|
173 |
*/ |
|
174 |
private static Iterator availableParsers() { |
|
175 |
Iterator providers = sun.misc.Service.providers(GPEParser.class); |
|
176 |
return providers; |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* Returns an iterator over instances of the registered writers. |
|
181 |
* <p> |
|
182 |
* NOTE: since GPEWriter is an abstract and statefull class rather than an interface, this |
|
183 |
* method shall stay private in order to ensure we return a new instance for the required format |
|
184 |
* every time. |
|
185 |
* </p> |
|
186 |
* |
|
187 |
* @return all the registered writers |
|
188 |
*/ |
|
189 |
private static Iterator availableWriters() { |
|
190 |
Iterator providers = sun.misc.Service.providers(IGPEWriterHandlerImplementor.class); |
|
191 |
return providers; |
|
192 |
} |
|
193 |
|
|
194 |
/** |
|
195 |
* Create a new parser from a class name. This method can be used |
|
196 |
* if the class name is known but, the common method to get a parser |
|
197 |
* is using the mime type. * |
|
198 |
* @param prefferredImplClassName |
|
199 |
* The name of the class that implements {@link GPEParser} |
|
200 |
* @return |
|
201 |
* A parser for a concrete format |
|
202 |
* @throws ParserCreationException |
|
203 |
* If it is not possible to create a parser |
|
204 |
*/ |
|
205 |
public static GPEParser createParserByClass(String prefferredImplClassName) throws ParserCreationException { |
|
206 |
Class prefferredImplClass = null; |
|
207 |
try { |
|
208 |
prefferredImplClass = Class.forName(prefferredImplClassName); |
|
209 |
} catch (ClassNotFoundException e) { |
|
210 |
throw new ParserCreationException(e); |
|
211 |
} |
|
212 |
|
|
213 |
Iterator providers = availableParsers(); |
|
214 |
while (providers.hasNext()) { |
|
215 |
GPEParser next = (GPEParser) providers.next(); |
|
216 |
if (prefferredImplClass.isInstance(next)) { |
|
217 |
return next; |
|
218 |
} |
|
219 |
} |
|
220 |
throw new ParserNotRegisteredException(prefferredImplClassName) ; |
|
221 |
} |
|
222 |
|
|
223 |
/** |
|
224 |
* Create a new parser from a parser name. This method can be used |
|
225 |
* if the parser name is known but, the common method to get a parser |
|
226 |
* is using the mime type. |
|
227 |
* @param name |
|
228 |
* The name of the parser, that is returned by the {@link GPEParser#getName} |
|
229 |
* method |
|
230 |
* @return |
|
231 |
* A parser for a concrete format |
|
232 |
* @throws ParserCreationException |
|
233 |
* If it is not possible to create a parser |
|
234 |
*/ |
|
235 |
public static GPEParser createParser(String name) throws ParserCreationException { |
|
236 |
Iterator providers = availableParsers(); |
|
237 |
while (providers.hasNext()) { |
|
238 |
GPEParser parser = (GPEParser) providers.next(); |
|
239 |
if (parser.getName().compareTo(name) == 0) { |
|
240 |
return parser; |
|
241 |
} |
|
242 |
} |
|
243 |
throw new ParserNameNotFoundException(name); |
|
244 |
} |
|
245 |
|
|
246 |
/** |
|
247 |
* Create a new parser from a {@link URI}. Each parser has a method |
|
248 |
* named {@link GPEParser#accept(URI)} that return true if the |
|
249 |
* parser can be open the file. |
|
250 |
* <p> |
|
251 |
* This method retrieve all the registered parsers and invoke the |
|
252 |
* <code>accept</code> method. The first parser that retuns true |
|
253 |
* is returned. It means that if there are more that one parser |
|
254 |
* to open a concrete file the first parser found will be returned. |
|
255 |
* </p> |
|
256 |
* @param uri |
|
257 |
* The place where the file is located |
|
258 |
* @return |
|
259 |
* A parser for a concrete format |
|
260 |
* @throws ParserCreationException |
|
261 |
* If it is not possible to create a parser |
|
262 |
*/ |
|
263 |
public static GPEParser createParser(URI uri) throws ParserCreationException { |
|
264 |
Iterator providers = availableParsers(); |
|
265 |
while (providers.hasNext()) { |
|
266 |
GPEParser parser = (GPEParser) providers.next(); |
|
267 |
if (parser.accept(uri)) { |
|
268 |
return parser; |
|
269 |
} |
|
270 |
} |
|
271 |
throw new ParserFileNotSupportedException(uri); |
|
272 |
} |
|
273 |
|
|
274 |
/** |
|
275 |
* Create a new parser from a mime type. Each parser has a method |
|
276 |
* named {@link GPEParser#getFormat()} that returns the mimetype |
|
277 |
* that the parser can read. One parser only supports one mimetype. |
|
278 |
* <p> |
|
279 |
* This method retrieve all the parsers and returns the first |
|
280 |
* parser that is able to read the mimetype. If there are more |
|
281 |
* parsers that can open the file will not be used. |
|
282 |
* </p> |
|
283 |
* @param mimeType |
|
284 |
* The mimetype of the file to open |
|
285 |
* @return |
|
286 |
* A parser that can parse the mimetype. |
|
287 |
* @throws ParserCreationException |
|
288 |
* If it is not possible to create a parser |
|
289 |
* @see |
|
290 |
* <a href="http://www.iana.org/assignments/media-types/">http://www.iana.org/assignments/media-types/</a> |
|
291 |
*/ |
|
292 |
public static GPEParser createParserByMimeType(String mimeType) throws ParserCreationException { |
|
293 |
Iterator providers = availableParsers(); |
|
294 |
while (providers.hasNext()) { |
|
295 |
GPEParser parser = (GPEParser) providers.next(); |
|
296 |
if (parser.getFormat().equals(mimeType)) { |
|
297 |
return parser; |
|
298 |
} |
|
299 |
} |
|
300 |
throw new ParserMimetypeNotSupportedException(mimeType); |
|
301 |
} |
|
302 |
|
|
303 |
/** |
|
304 |
* Create a new writer from a writer name. This method can be used |
|
305 |
* if the writer name is known but, the common method to get a writer |
|
306 |
* is using the mime type. |
|
307 |
* @param name |
|
308 |
* The name of the writer, that is returned by the {@link GPEWriterHandler#getName} |
|
309 |
* method |
|
310 |
* @return |
|
311 |
* A writer for a concrete format |
|
312 |
* @throws WriterHandlerCreationException |
|
313 |
* If it is not possible to create a writer |
|
314 |
*/ |
|
315 |
public static GPEWriterHandler createWriter(String name) |
|
316 |
throws WriterHandlerCreationException { |
|
317 |
Iterator providers = availableWriters(); |
|
318 |
while (providers.hasNext()) { |
|
319 |
IGPEWriterHandlerImplementor implementor = (IGPEWriterHandlerImplementor) providers |
|
320 |
.next(); |
|
321 |
if (implementor.getName().compareTo(name) == 0) { |
|
322 |
return new GPEWriterHandler(implementor); |
|
323 |
} |
|
324 |
} |
|
325 |
return null; |
|
326 |
} |
|
327 |
|
|
328 |
/** |
|
329 |
* Create a new writer from a class name. This method can be used |
|
330 |
* if the class name is known but, the common method to get a writer |
|
331 |
* is using the mime type. * |
|
332 |
* @param prefferredImplClassName |
|
333 |
* The name of the class that implements {@link GPEWriterHandler} |
|
334 |
* @return |
|
335 |
* A writer for a concrete format. |
|
336 |
* @throws WriterHandlerCreationException |
|
337 |
* If it is not possible to create a writer |
|
338 |
*/ |
|
339 |
public static GPEWriterHandler createWriterByClass(String prefferredImplClassName) |
|
340 |
throws WriterHandlerCreationException { |
|
341 |
Class prefferredImplClass = null; |
|
342 |
try { |
|
343 |
prefferredImplClass = Class.forName(prefferredImplClassName); |
|
344 |
} catch (ClassNotFoundException e) { |
|
345 |
throw new WriterHandlerCreationException(e); |
|
346 |
} |
|
347 |
|
|
348 |
Iterator providers = availableWriters(); |
|
349 |
while (providers.hasNext()) { |
|
350 |
IGPEWriterHandlerImplementor next = (IGPEWriterHandlerImplementor) providers.next(); |
|
351 |
if (prefferredImplClass.isInstance(next)) { |
|
352 |
return new GPEWriterHandler(next); |
|
353 |
} |
|
354 |
} |
|
355 |
throw new WriterHandlerNotRegisteredException(prefferredImplClassName); |
|
356 |
} |
|
357 |
|
|
358 |
/** |
|
359 |
* Create a new writer from a mime type. Each writer has a method |
|
360 |
* named {@link GPEWriterHandler#getFormat()} that returns the mimetype |
|
361 |
* that the writer can write. One writer only supports one mimetype. |
|
362 |
* <p> |
|
363 |
* This method retrieve all the writers and returns the first |
|
364 |
* one that is able to write the mimetype. If there are more |
|
365 |
* writer that can write the format will not be used. |
|
366 |
* </p> |
|
367 |
* @param mimeType |
|
368 |
* The mimetype of the file to write |
|
369 |
* @return |
|
370 |
* A writer that can write the mimetype. |
|
371 |
* @throws WriterHandlerCreationException |
|
372 |
* If it is not possible to create a writer |
|
373 |
* @see |
|
374 |
* <a href="http://www.iana.org/assignments/media-types/">http://www.iana.org/assignments/media-types/</a> |
|
375 |
*/ |
|
376 |
public static GPEWriterHandler createWriterByMimeType(String mimeType) |
|
377 |
throws WriterHandlerCreationException { |
|
378 |
Iterator providers = availableWriters(); |
|
379 |
while (providers.hasNext()) { |
|
380 |
IGPEWriterHandlerImplementor implementor = (IGPEWriterHandlerImplementor) providers |
|
381 |
.next(); |
|
382 |
if (implementor.getFormat().equals(mimeType)) { |
|
383 |
return new GPEWriterHandler(implementor); |
|
384 |
} |
|
385 |
} |
|
386 |
throw new WriterHandlerMimeTypeNotSupportedException(mimeType); |
|
387 |
} |
|
388 |
|
|
389 |
/** |
|
390 |
* Return <code>true</code> if there is a parser that is able to |
|
391 |
* open the file or <code>false</code> instead. |
|
392 |
* @param uri |
|
393 |
* The file to open |
|
394 |
* @return |
|
395 |
* <code>true</code> if there is a parser that is able to open the file |
|
396 |
*/ |
|
397 |
public static boolean accept(URI uri) { |
|
398 |
Iterator providers = availableParsers(); |
|
399 |
while (providers.hasNext()) { |
|
400 |
GPEParser parser = (GPEParser) providers.next(); |
|
401 |
if (parser.accept(uri)) { |
|
402 |
return true; |
|
403 |
} |
|
404 |
} |
|
405 |
return false; |
|
406 |
} |
|
407 |
} |
|
0 | 408 |
tags/tmp_build/libraries/libGPE/src/org/gvsig/gpe/GPEProperties.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 Iver T.I. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.gpe; |
|
29 |
|
|
30 |
import java.util.Properties; |
|
31 |
|
|
32 |
/** |
|
33 |
* This class contains the generic properties for all the |
|
34 |
* GPE parsers and writers. This class has been registered using |
|
35 |
* the SPI (Service Provider Interface) and the values of their |
|
36 |
* properties can be configured using {@link GPEDefaults}. |
|
37 |
*/ |
|
38 |
public class GPEProperties implements IGPEProperties{ |
|
39 |
public static Properties properties = null; |
|
40 |
/** |
|
41 |
* Number of decimal digits that both the parser and the writer |
|
42 |
* have to manage. |
|
43 |
*/ |
|
44 |
public static final String DECIMAL_DIGITS = "decimalDigits"; |
|
45 |
private static final Integer DECIMAL_DIGITS_VALUE = new Integer(20); |
|
46 |
|
|
47 |
static{ |
|
48 |
properties = new Properties(); |
|
49 |
properties.put(DECIMAL_DIGITS, DECIMAL_DIGITS_VALUE); |
|
50 |
} |
|
51 |
|
|
52 |
/* |
|
53 |
* (non-Javadoc) |
|
54 |
* @see org.gvsig.gpe.IGPEProperties#getProperties() |
|
55 |
*/ |
|
56 |
public Properties getProperties() { |
|
57 |
return properties; |
|
58 |
} |
|
59 |
|
|
60 |
} |
|
61 |
|
|
62 |
|
tags/tmp_build/libraries/libGPE/src/org/gvsig/gpe/warnings/NotSupportedElementWarning.java | ||
---|---|---|
1 |
package org.gvsig.gpe.warnings; |
|
2 |
|
|
3 |
import java.util.Hashtable; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.gvsig.exceptions.BaseException; |
|
7 |
|
|
8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
9 |
* |
|
10 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or |
|
13 |
* modify it under the terms of the GNU General Public License |
|
14 |
* as published by the Free Software Foundation; either version 2 |
|
15 |
* of the License, or (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
25 |
* |
|
26 |
* For more information, contact: |
|
27 |
* |
|
28 |
* Generalitat Valenciana |
|
29 |
* Conselleria d'Infraestructures i Transport |
|
30 |
* Av. Blasco Ib??ez, 50 |
|
31 |
* 46010 VALENCIA |
|
32 |
* SPAIN |
|
33 |
* |
|
34 |
* +34 963862235 |
|
35 |
* gvsig@gva.es |
|
36 |
* www.gvsig.gva.es |
|
37 |
* |
|
38 |
* or |
|
39 |
* |
|
40 |
* IVER T.I. S.A |
|
41 |
* Salamanca 50 |
|
42 |
* 46005 Valencia |
|
43 |
* Spain |
|
44 |
* |
|
45 |
* +34 963163400 |
|
46 |
* dac@iver.es |
|
47 |
*/ |
|
48 |
/* CVS MESSAGES: |
|
49 |
* |
|
50 |
* $Id: NotSupportedElementWarning.java 162 2007-06-29 12:19:48Z jorpiell $ |
|
51 |
* $Log$ |
|
52 |
* Revision 1.2 2007/06/29 12:19:14 jorpiell |
|
53 |
* The schema validation is made independently of the concrete writer |
|
54 |
* |
|
55 |
* Revision 1.1 2007/06/28 13:04:33 jorpiell |
|
56 |
* The Qname has been updated to the 1.5 JVM machine. The schema validation is made in the GPEWriterHandlerImplementor class |
|
57 |
* |
|
58 |
* Revision 1.1 2007/06/22 12:19:07 jorpiell |
|
59 |
* Add the exception |
|
60 |
* |
|
61 |
* |
|
62 |
*/ |
|
63 |
/** |
|
64 |
* It is thrown when there is an element that can not |
|
65 |
* be validated using the XML Schema |
|
66 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es) |
|
67 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es) |
|
68 |
*/ |
|
69 |
public class NotSupportedElementWarning extends BaseException{ |
|
70 |
private static final long serialVersionUID = -8478703373223856720L; |
|
71 |
private String elementName = null; |
|
72 |
private String xsElementName = null; |
|
73 |
private String parentName = null; |
|
74 |
private String xsParentElementName = null; |
|
75 |
|
|
76 |
public NotSupportedElementWarning(String elementName, String xsElementName, String parentName, String xsParentElementName) { |
|
77 |
this.elementName = elementName; |
|
78 |
this.xsElementName = xsElementName; |
|
79 |
this.parentName = parentName; |
|
80 |
this.xsParentElementName = xsParentElementName; |
|
81 |
initialize(); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Initialize the properties |
|
86 |
*/ |
|
87 |
private void initialize() { |
|
88 |
messageKey = "gpe_not_supported_element_warning"; |
|
89 |
formatString = "The element '%(elementName)' with a XML schema " + |
|
90 |
"type '%(xsElementName)' is not contained in the parent element " + |
|
91 |
"'%(parentName)' with a XML Schema type '%(xsParentElementName)'"; |
|
92 |
code = serialVersionUID; |
|
93 |
} |
|
94 |
|
|
95 |
/* |
|
96 |
* (non-Javadoc) |
|
97 |
* @see org.gvsig.exceptions.BaseException#values() |
|
98 |
*/ |
|
99 |
protected Map values() { |
|
100 |
Hashtable hash = new Hashtable(); |
|
101 |
hash.put("elementName", elementName); |
|
102 |
hash.put("xsElementName", xsElementName); |
|
103 |
hash.put("parentName", parentName); |
|
104 |
hash.put("xsParentElementName", xsParentElementName); |
|
105 |
return hash; |
|
106 |
} |
|
107 |
|
|
108 |
} |
|
0 | 109 |
tags/tmp_build/libraries/libGPE/src/org/gvsig/gpe/warnings/FeatureNotSupportedWarning.java | ||
---|---|---|
1 |
package org.gvsig.gpe.warnings; |
|
2 |
|
|
3 |
import java.util.Hashtable; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.gvsig.exceptions.BaseException; |
|
7 |
|
|
8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
9 |
* |
|
10 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or |
|
13 |
* modify it under the terms of the GNU General Public License |
|
14 |
* as published by the Free Software Foundation; either version 2 |
|
15 |
* of the License, or (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
25 |
* |
|
26 |
* For more information, contact: |
|
27 |
* |
|
28 |
* Generalitat Valenciana |
|
29 |
* Conselleria d'Infraestructures i Transport |
|
30 |
* Av. Blasco Ib??ez, 50 |
|
31 |
* 46010 VALENCIA |
|
32 |
* SPAIN |
|
33 |
* |
|
34 |
* +34 963862235 |
|
35 |
* gvsig@gva.es |
|
36 |
* www.gvsig.gva.es |
|
37 |
* |
|
38 |
* or |
|
39 |
* |
|
40 |
* IVER T.I. S.A |
|
41 |
* Salamanca 50 |
|
42 |
* 46005 Valencia |
|
43 |
* Spain |
|
44 |
* |
|
45 |
* +34 963163400 |
|
46 |
* dac@iver.es |
|
47 |
*/ |
|
48 |
/* CVS MESSAGES: |
|
49 |
* |
|
50 |
* $Id: FeatureNotSupportedWarning.java 190 2007-11-21 12:53:42Z csanchez $ |
|
51 |
* $Log$ |
|
52 |
* Revision 1.2 2007/06/19 10:34:51 jorpiell |
|
53 |
* Add some comments and creates a warning when an operation is not supported |
|
54 |
* |
|
55 |
* Revision 1.1 2007/05/16 12:07:07 jorpiell |
|
56 |
* New exceptions added |
|
57 |
* |
|
58 |
* |
|
59 |
*/ |
|
60 |
/** |
|
61 |
* This warning is throwed when an application try to write |
|
62 |
* a feature that the current format doesn't supports it. |
|
63 |
* A feature in this case is not a "geographic feature": |
|
64 |
* is a detail: A layer with bbox, a leyer name... * |
|
65 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
66 |
*/ |
|
67 |
public class FeatureNotSupportedWarning extends BaseException{ |
|
68 |
private static final long serialVersionUID = 8532995170438868404L; |
|
69 |
private String feature = null; |
|
70 |
private String parserName = null; |
|
71 |
public static final String LAYERWITHNAME = "Layer with name"; |
|
72 |
public static final String LAYERWITHDESCRIPTION = "Layer with description"; |
|
73 |
public static final String LAYERWITHBBOX = "Layer with bbox"; |
|
74 |
public static final String LAYERWITHSRS = "Layer with srs"; |
|
75 |
public static final String FEATUEWITHBBOX = "Feature with bbox"; |
|
76 |
public static final String FEATUREWITHELEMENTS = "Feature with elements"; |
|
77 |
public static final String FEATUREWITHNAME = "Feature with name"; |
|
78 |
public static final String FEATURECREATION = "Feature creation"; |
|
79 |
public static final String FEATUREWITHGEOMETRY = "Feature with geometry"; |
|
80 |
public static final String LAYERCREATION = "Layer creation"; |
|
81 |
public static final String LAYERWITHCHILDREN = "Layer with children"; |
|
82 |
public static final String LAYERWITHFEATURES = "Layer with features"; |
|
83 |
public static final String ELEMENTCREATION = "Create an element"; |
|
84 |
public static final String ELEMENTWITHCHILDREN = "Element with child elements"; |
|
85 |
public static final String BBOXCREATION = "Create a bbox"; |
|
86 |
public static final String POINTCREATION = "Create a point"; |
|
87 |
public static final String LINESTRINGCREATION = "Create a lineString"; |
|
88 |
public static final String LINEARRINGCREATION = "Create a linearRing"; |
|
89 |
public static final String POLYGONCREATION = "Create a polygon"; |
|
90 |
public static final String POLYGONWITHINNERPOLYGON = "Polygon with inner polygon"; |
|
91 |
public static final String INNERBOUNDARYCREATION = "Create a polygon innerboundary"; |
|
92 |
public static final String MULTIPOINTCREATION = "Create a multiPoint"; |
|
93 |
public static final String MULTILINESTRINGCREATION = "Create a multiLineString"; |
|
94 |
public static final String MULTIPOLYGONCREATION = "Create a multiPolygon"; |
|
95 |
public static final String MULTIGEOMETRYCREATION = "Create a multiGeometry"; |
|
96 |
/************** CURVE CREATIONS FOR GML 3 ***************/ |
|
97 |
public static final String MULTICURVECREATION = "Create a multiCurve"; |
|
98 |
public static final String CURVECREATION = "Create a Curve"; |
|
99 |
|
|
100 |
public FeatureNotSupportedWarning(String feature, String parserName){ |
|
101 |
this.feature = feature; |
|
102 |
this.parserName = parserName; |
|
103 |
initialize(); |
|
104 |
} |
|
105 |
|
|
106 |
public FeatureNotSupportedWarning(String feature){ |
|
107 |
this.feature = feature; |
|
108 |
initialize(); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Initialize the properties |
|
113 |
*/ |
|
114 |
private void initialize() { |
|
115 |
messageKey = "gpe_feature_not_supported_warning"; |
|
116 |
if (parserName != null){ |
|
117 |
formatString = "The feature '%(feature)' is not supported" + |
|
118 |
" by the %(parserName) parser. It could be by two" + |
|
119 |
" reasons: 1) The parser doesn't support this feature. " + |
|
120 |
" 2) The format doesn't support the feature."; |
|
121 |
}else{ |
|
122 |
formatString = "The feature '%(feature)' is not supported" + |
|
123 |
" by the consumer application."; |
|
124 |
} |
|
125 |
code = serialVersionUID; |
|
126 |
} |
|
127 |
|
|
128 |
/* |
|
129 |
* (non-Javadoc) |
|
130 |
* @see org.gvsig.exceptions.BaseException#values() |
|
131 |
*/ |
|
132 |
protected Map values() { |
|
133 |
Hashtable hash = new Hashtable(); |
|
134 |
hash.put("feature", feature); |
|
135 |
if (parserName != null){ |
|
136 |
hash.put("parserName", parserName); |
|
137 |
} |
|
138 |
return hash; |
|
139 |
} |
|
140 |
|
|
141 |
|
|
142 |
} |
|
0 | 143 |
tags/tmp_build/libraries/libGPE/src/org/gvsig/gpe/warnings/NotSupportedFeatureWarning.java | ||
---|---|---|
1 |
package org.gvsig.gpe.warnings; |
|
2 |
|
|
3 |
import java.util.Hashtable; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.gvsig.exceptions.BaseException; |
|
7 |
|
|
8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
9 |
* |
|
10 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or |
|
13 |
* modify it under the terms of the GNU General Public License |
|
14 |
* as published by the Free Software Foundation; either version 2 |
|
15 |
* of the License, or (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
25 |
* |
|
26 |
* For more information, contact: |
|
27 |
* |
|
28 |
* Generalitat Valenciana |
|
29 |
* Conselleria d'Infraestructures i Transport |
|
30 |
* Av. Blasco Ib??ez, 50 |
|
31 |
* 46010 VALENCIA |
|
32 |
* SPAIN |
|
33 |
* |
|
34 |
* +34 963862235 |
|
35 |
* gvsig@gva.es |
|
36 |
* www.gvsig.gva.es |
|
37 |
* |
|
38 |
* or |
|
39 |
* |
|
40 |
* IVER T.I. S.A |
|
41 |
* Salamanca 50 |
|
42 |
* 46005 Valencia |
|
43 |
* Spain |
|
44 |
* |
|
45 |
* +34 963163400 |
|
46 |
* dac@iver.es |
|
47 |
*/ |
|
48 |
/* CVS MESSAGES: |
|
49 |
* |
|
50 |
* $Id: NotSupportedFeatureWarning.java 162 2007-06-29 12:19:48Z jorpiell $ |
|
51 |
* $Log$ |
|
52 |
* Revision 1.2 2007/06/29 12:19:14 jorpiell |
|
53 |
* The schema validation is made independently of the concrete writer |
|
54 |
* |
|
55 |
* Revision 1.1 2007/06/28 13:04:33 jorpiell |
|
56 |
* The Qname has been updated to the 1.5 JVM machine. The schema validation is made in the GPEWriterHandlerImplementor class |
|
57 |
* |
|
58 |
* |
|
59 |
*/ |
|
60 |
/** |
|
61 |
* It is thrown when there is an feture that can not |
|
62 |
* be validated using the XML Schema |
|
63 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es) |
|
64 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es) |
|
65 |
*/ |
|
66 |
public class NotSupportedFeatureWarning extends BaseException{ |
|
67 |
private static final long serialVersionUID = -907568605199930636L; |
|
68 |
private String featureName = null; |
|
69 |
private String xsFeatureType = null; |
|
70 |
private String layerName = null; |
|
71 |
private String xsLayerType = null; |
|
72 |
private boolean hasParentSchema = false; |
|
73 |
|
|
74 |
public NotSupportedFeatureWarning(String featureName, String xsFeatureType, String layerName, String xsLayerType) { |
|
75 |
super(); |
|
76 |
this.featureName = featureName; |
|
77 |
this.xsFeatureType = xsFeatureType; |
|
78 |
this.layerName = layerName; |
|
79 |
this.xsLayerType = xsLayerType; |
|
80 |
hasParentSchema = true; |
|
81 |
initialize(); |
|
82 |
} |
|
83 |
|
|
84 |
public NotSupportedFeatureWarning(String featureName, String xsFeatureType) { |
|
85 |
super(); |
|
86 |
this.featureName = featureName; |
|
87 |
this.xsFeatureType = xsFeatureType; |
|
88 |
hasParentSchema = false; |
|
89 |
initialize(); |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* Initialize the properties |
|
94 |
*/ |
|
95 |
private void initialize() { |
|
96 |
messageKey = "gpe_not_supported_feature_warning"; |
|
97 |
if (hasParentSchema){ |
|
98 |
formatString = "The feature '%(featureName)' with a XML schema " + |
|
99 |
"type '%(xsFeatureType)' is not contained in the parent layer " + |
|
100 |
"'%(layerName)' with a XML Schema type '%(xsLayerType)'"; |
|
101 |
}else{ |
|
102 |
formatString = "The feature '%(featureName)' with a XML schema " + |
|
103 |
"type '%(xsFeatureType)' is not found on the XML schema "; |
|
104 |
} |
|
105 |
code = serialVersionUID; |
|
106 |
} |
|
107 |
|
|
108 |
/* |
|
109 |
* (non-Javadoc) |
|
110 |
* @see org.gvsig.exceptions.BaseException#values() |
|
111 |
*/ |
|
112 |
protected Map values() { |
|
113 |
Hashtable hash = new Hashtable(); |
|
114 |
hash.put("featureName", featureName); |
|
115 |
hash.put("xsFeatureType", xsFeatureType); |
|
116 |
if (hasParentSchema){ |
|
117 |
hash.put("layerName", layerName); |
|
118 |
hash.put("xsLayerType", xsLayerType); |
|
119 |
} |
|
120 |
return hash; |
|
121 |
} |
|
122 |
} |
|
0 | 123 |
tags/tmp_build/libraries/libGPE/src/org/gvsig/gpe/warnings/PolygonNotClosedWarning.java | ||
---|---|---|
1 |
package org.gvsig.gpe.warnings; |
|
2 |
|
|
3 |
import java.util.Hashtable; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.gvsig.exceptions.BaseException; |
|
7 |
|
|
8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
9 |
* |
|
10 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or |
|
13 |
* modify it under the terms of the GNU General Public License |
|
14 |
* as published by the Free Software Foundation; either version 2 |
|
15 |
* of the License, or (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
25 |
* |
|
26 |
* For more information, contact: |
|
27 |
* |
|
28 |
* Generalitat Valenciana |
|
29 |
* Conselleria d'Infraestructures i Transport |
|
30 |
* Av. Blasco Ib??ez, 50 |
|
31 |
* 46010 VALENCIA |
|
32 |
* SPAIN |
|
33 |
* |
|
34 |
* +34 963862235 |
|
35 |
* gvsig@gva.es |
|
36 |
* www.gvsig.gva.es |
|
37 |
* |
|
38 |
* or |
|
39 |
* |
|
40 |
* IVER T.I. S.A |
|
41 |
* Salamanca 50 |
|
42 |
* 46005 Valencia |
|
43 |
* Spain |
|
44 |
* |
|
45 |
* +34 963163400 |
|
46 |
* dac@iver.es |
|
47 |
*/ |
|
48 |
/* CVS MESSAGES: |
|
49 |
* |
|
50 |
* $Id: PolygonNotClosedWarning.java 124 2007-05-16 09:27:40Z jorpiell $ |
|
51 |
* $Log$ |
|
52 |
* Revision 1.1 2007/05/16 09:27:40 jorpiell |
|
53 |
* Add some warnings |
|
54 |
* |
|
55 |
* |
|
56 |
*/ |
|
57 |
/** |
|
58 |
* This warning is throwed when the first and |
|
59 |
* the last coordinates of a Polygon have not the |
|
60 |
* same value. It is a warning, because the application |
|
61 |
* could close the polygon |
|
62 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
63 |
*/ |
|
64 |
public class PolygonNotClosedWarning extends BaseException{ |
|
65 |
private static final long serialVersionUID = -7711784191638191730L; |
|
66 |
private double[] x = null; |
|
67 |
private double[] y = null; |
|
68 |
private double[] z = null; |
|
69 |
|
|
70 |
/** |
|
71 |
* Constructor |
|
72 |
* @param coordinates |
|
73 |
* Polygon coordinates |
|
74 |
*/ |
|
75 |
public PolygonNotClosedWarning(double[][] coordinates){ |
|
76 |
this.x = coordinates[0]; |
|
77 |
this.y = coordinates[1]; |
|
78 |
this.z = coordinates[2]; |
|
79 |
initialize(); |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* Costructor |
|
84 |
* @param x |
|
85 |
* Coordinate X |
|
86 |
* @param y |
|
87 |
* Coordinate Y |
|
88 |
* @param z |
|
89 |
* Coordinate Z |
|
90 |
*/ |
|
91 |
public PolygonNotClosedWarning(double[] x, double[] y, double[] z){ |
|
92 |
this.x = x; |
|
93 |
this.y = y ; |
|
94 |
this.z = z; |
|
95 |
initialize(); |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Initialize the properties |
|
100 |
*/ |
|
101 |
private void initialize() { |
|
102 |
messageKey = "gpe_polygon_not_closed_warning"; |
|
103 |
formatString = "The polygon is not closed. The first coordinate is" + |
|
104 |
" %(X0),%(Y0),%(Z0) and the last one is %(X1),%(Y1),%(Z1)"; |
|
105 |
code = serialVersionUID; |
|
106 |
} |
|
107 |
|
|
108 |
/* |
|
109 |
* (non-Javadoc) |
|
110 |
* @see org.gvsig.exceptions.BaseException#values() |
|
111 |
*/ |
|
112 |
protected Map values() { |
|
113 |
Hashtable hash = new Hashtable(); |
|
114 |
hash.put("X0", String.valueOf(x[0])); |
|
115 |
hash.put("Y0", String.valueOf(y[0])); |
|
116 |
hash.put("Z0", String.valueOf(z[0])); |
|
117 |
hash.put("X1", String.valueOf(x[x.length - 1])); |
|
118 |
hash.put("Y1", String.valueOf(y[y.length - 1])); |
|
119 |
hash.put("Z1", String.valueOf(z[z.length - 1])); |
|
120 |
return hash; |
|
121 |
} |
|
122 |
} |
|
0 | 123 |
tags/tmp_build/libraries/libGPE/src/org/gvsig/gpe/warnings/NotSupportedLayerWarning.java | ||
---|---|---|
1 |
package org.gvsig.gpe.warnings; |
|
2 |
|
|
3 |
import java.util.Hashtable; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.gvsig.exceptions.BaseException; |
|
7 |
|
|
8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
9 |
* |
|
10 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or |
|
13 |
* modify it under the terms of the GNU General Public License |
|
14 |
* as published by the Free Software Foundation; either version 2 |
|
15 |
* of the License, or (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
25 |
* |
|
26 |
* For more information, contact: |
Also available in: Unified diff