Revision 22007
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writer/schemas/GPEWriterWithSchemaBaseTest.java | ||
---|---|---|
115 | 115 |
public void testWriter() throws Exception{ |
116 | 116 |
writeSchema(); |
117 | 117 |
getSchema().write(new FileOutputStream(getSchemaFile())); |
118 |
GPEDefaults.setProperty(GPEDefaults.XSD_SCHEMA_FILE, getSchemaFile().getAbsolutePath());
|
|
118 |
GPEDefaults.setProperty("schemaName", getSchemaFile().getAbsolutePath());
|
|
119 | 119 |
getWriterHandler().getSchemaDocument().addSchema( |
120 | 120 |
new URI(getSchemaFile().getPath()), |
121 | 121 |
getSchema()); |
trunk/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 |
|
trunk/libraries/libGPE/src/org/gvsig/gpe/IGPEProperties.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 is used to add properties to the {@link GPEDefaults}. |
|
34 |
* Each parser or writer that need configurable properties to work |
|
35 |
* have to use this class to provide them. |
|
36 |
* <p> |
|
37 |
* The library uses the SPI (Service Provider Interface) mechanism to |
|
38 |
* add a set of configurable properties. The information about how |
|
39 |
* it is possible to add new properties can be read in |
|
40 |
* {@link GPEDefaults} |
|
41 |
* </p> |
|
42 |
* @see {@link GPEDeafults} |
|
43 |
*/ |
|
44 |
public interface IGPEProperties { |
|
45 |
|
|
46 |
/** |
|
47 |
* Returns a set of properties that are registered in |
|
48 |
* {@link GPEDefaults} and can be read and written by the |
|
49 |
* consumer application. |
|
50 |
*/ |
|
51 |
public Properties getProperties(); |
|
52 |
|
|
53 |
} |
|
54 |
|
trunk/libraries/libGPE/src/org/gvsig/gpe/GPEDefaults.java | ||
---|---|---|
1 | 1 |
package org.gvsig.gpe; |
2 | 2 |
|
3 | 3 |
import java.util.Iterator; |
4 |
import java.util.LinkedHashMap;
|
|
4 |
import java.util.Properties;
|
|
5 | 5 |
|
6 |
import org.gvsig.gpe.parser.GPEParser; |
|
7 |
|
|
6 | 8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
7 | 9 |
* |
8 | 10 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
... | ... | |
80 | 82 |
* |
81 | 83 |
*/ |
82 | 84 |
/** |
83 |
* This class is used to add the properties that are used |
|
84 |
* by the GPE parsers. |
|
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 |
* |
|
85 | 124 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
86 | 125 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es) |
87 | 126 |
*/ |
88 | 127 |
public class GPEDefaults { |
89 |
private static LinkedHashMap properties = new LinkedHashMap(); |
|
90 |
//Decimal sepatarator |
|
91 |
public static final String DECIMAL = "decimal"; |
|
92 |
private static final String DECIMAL_VALUE = "."; |
|
93 |
//Coordinates separator. Ex: xSEPARATORy |
|
94 |
public static final String COORDINATES_SEPARATOR = "coordinatesSeparator"; |
|
95 |
private static final String COORDINATES_SEPARATOR_VALUE = ","; |
|
96 |
//Set of tuples separator Ex: x1,y1SEPARATORx2,y2 |
|
97 |
public static final String TUPLES_SEPARATOR = "tuplesSeparator"; |
|
98 |
private static final String TUPLES_SEPARATOR_VALUE = " "; |
|
99 |
//Number of decimal digits |
|
100 |
public static final String DECIMAL_DIGITS = "decimalDigits"; |
|
101 |
private static final Integer DECIMAL_DIGITS_VALUE = new Integer(20); |
|
102 |
//Namespace prefix to create the XML files |
|
103 |
public static final String DEFAULT_NAMESPACE_PREFIX = "namespacePrefix"; |
|
104 |
private static final String DEFAULT_NAMESPACE_PREFIX_VALUE = "cit"; |
|
105 |
//Namespace URI to create the XML files |
|
106 |
public static final String DEFAULT_NAMESPACE_URI= "namespaceURI"; |
|
107 |
private static final String DEFAULT_NAMESPACE_URI_VALUE= "http://www.gvsig.org/cit"; |
|
108 |
//Default name for a feature collection |
|
109 |
public static final String DEFAULT_FEATURECOLLECTION= "featureCollection"; |
|
110 |
private static final String DEFAULT_FEATURECOLLECTION_VALUE= "FeatureCollection"; |
|
111 |
//Default name for a feature |
|
112 |
public static final String DEFAULT_FEATURE= "feature"; |
|
113 |
private static final String DEFAULT_FEATURE_VALUE= "Feature"; |
|
114 |
//Default schema name |
|
115 |
public static final String XSD_SCHEMA_FILE = "schemaName"; |
|
116 |
private static final String XSD_SCHEMA_FILE_VALUE = "cit.xsd"; |
|
117 |
//XML version = 1.0 |
|
118 |
public static final String XML_VERSION = "xmlVersion"; |
|
119 |
private static final String XML_VERSION_VALUE = "1.0"; |
|
120 |
//XML encoding (UTF-8) by default |
|
121 |
public static final String XML_ENCODING = "xmlEncoding"; |
|
122 |
private static final String XML_ENCODING_VALUE = "UTF-8"; |
|
123 |
//Default output file |
|
124 |
public static final String DEFAULT_FILE_NAME = "defaultFileName"; |
|
125 |
private static final String DEFAULT_FILE_NAME_VALUE = "output"; |
|
126 |
//Default black space symbol |
|
127 |
public static final String DEFAULT_BLANC_SPACE = "defaultBlancSpace"; |
|
128 |
private static final String DEFAULT_BLANC_SPACE_VALUE = "_"; |
|
129 |
//Default black space symbol |
|
130 |
public static final String SRS_BASED_ON_XML = "srsBasedOnXml"; |
|
131 |
private static final Boolean SRS_BASED_ON_XML_VALUE = new Boolean(true); |
|
132 |
//If the parser can download schemas |
|
133 |
public static final String XML_SCHEMA_VALIDATED = "xmlSchemaValidated"; |
|
134 |
private static final Boolean XML_SCHEMA_VALIDATED_VALUE = new Boolean(true); |
|
135 |
|
|
136 |
static{ |
|
137 |
properties.put(DECIMAL, DECIMAL_VALUE); |
|
138 |
properties.put(COORDINATES_SEPARATOR, COORDINATES_SEPARATOR_VALUE); |
|
139 |
properties.put(TUPLES_SEPARATOR, TUPLES_SEPARATOR_VALUE); |
|
140 |
properties.put(DEFAULT_NAMESPACE_PREFIX, DEFAULT_NAMESPACE_PREFIX_VALUE); |
|
141 |
properties.put(DEFAULT_NAMESPACE_URI, DEFAULT_NAMESPACE_URI_VALUE); |
|
142 |
properties.put(DEFAULT_FEATURECOLLECTION, DEFAULT_FEATURECOLLECTION_VALUE); |
|
143 |
properties.put(DEFAULT_FEATURE, DEFAULT_FEATURE_VALUE); |
|
144 |
properties.put(XML_VERSION, XML_VERSION_VALUE); |
|
145 |
properties.put(XML_ENCODING, XML_ENCODING_VALUE); |
|
146 |
properties.put(DEFAULT_FILE_NAME, DEFAULT_FILE_NAME_VALUE); |
|
147 |
properties.put(XSD_SCHEMA_FILE, XSD_SCHEMA_FILE_VALUE); |
|
148 |
properties.put(DEFAULT_BLANC_SPACE, DEFAULT_BLANC_SPACE_VALUE); |
|
149 |
properties.put(DECIMAL_DIGITS, DECIMAL_DIGITS_VALUE); |
|
150 |
properties.put(SRS_BASED_ON_XML, SRS_BASED_ON_XML_VALUE); |
|
151 |
properties.put(XML_SCHEMA_VALIDATED, XML_SCHEMA_VALIDATED_VALUE); |
|
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 |
} |
|
152 | 141 |
} |
153 | 142 |
|
154 | 143 |
/** |
155 |
* @return the keys used to retrieve all the properties |
|
144 |
* Returns an iterator over instances of the registered GPE properties. |
|
145 |
* @return all the registered GPE properties |
|
156 | 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 |
*/ |
|
157 | 156 |
public static Iterator getKeys(){ |
158 | 157 |
return properties.keySet().iterator(); |
159 | 158 |
} |
trunk/libraries/libGPE/src/META-INF/services/org.gvsig.gpe.IGPEProperties | ||
---|---|---|
1 |
org.gvsig.gpe.GPEProperties |
Also available in: Unified diff