Revision 37468

View differences:

tags/v2_0_0_Build_2042/libraries/libRemoteServices/src/org/gvsig/remoteclient/utils/PropertyManager.java
1
package org.gvsig.remoteclient.utils;
2

  
3
import java.io.IOException;
4
import java.io.InputStream;
5
import java.util.Hashtable;
6
import java.util.Properties;
7

  
8
/**
9
 * Description: Loads the configuration files
10
 *
11
 * @author  Laura Diaz
12
 * @version 1.0 
13
 */
14
public class PropertyManager
15
{
16
 public final static String LOGGER_PROPERTIES = "org/gvsig/remoteClient/conf/logger.properties";
17
 
18
 //The property file names to load
19
 private final static String[] s_propertyFileNames = new String[]{LOGGER_PROPERTIES};
20
 																	
21

  
22
 //Hashtable containing all properties objects that are loaded
23
 private static Hashtable s_propertyFiles = null;
24

  
25
 /**
26
 * Gets a properties object
27
 * If the the property files are not yet loaded, then loads them first
28
 *
29
 * @param propertyFileName, String
30
 * @return Properties
31
 * @throws java.io.IOException
32
 */
33
 public static Properties getProperties(String propertyFileName) throws IOException
34
 {
35
   if (s_propertyFiles == null)
36
   {
37
     loadProperties();
38
   }
39

  
40
   return (Properties)s_propertyFiles.get(propertyFileName);
41
 }
42

  
43
 //Loads the property files
44
 private static synchronized void loadProperties() throws IOException
45
 {
46
   s_propertyFiles = new Hashtable(s_propertyFileNames.length);
47
   ClassLoader loader = PropertyManager.class.getClassLoader();
48

  
49
   for (int i = 0; i < s_propertyFileNames.length; i++)
50
   {
51
     try
52
     {
53
       InputStream input = loader.getResourceAsStream(s_propertyFileNames[i]);
54
       Properties props = new Properties();
55
       props.load(input);
56
       s_propertyFiles.put(s_propertyFileNames[i], props);
57
     }
58
     catch(Exception e)
59
     {
60
     	System.err.println("\n[PropertyManager] ERROR - Failed to read properties file \""
61
                          + s_propertyFileNames[i] + "\": "
62
                          + e.getMessage());       
63
     }
64
   }
65
 }
66
 
67
 //Loads the property files
68
 /*
69
 public static synchronized void saveProperties(String propsName) throws IOException
70
 {  
71
     try
72
     {	 
73
	  //ClassLoader loader = PropertyManager.class.getClassLoader();    	  
74
	  //InputStream input = loader.getResourceAsStream(propsName);    	      	
75
	   FileOutputStream output = new FileOutputStream(propsName);
76
	   Properties props = new Properties();
77
	   props.store(output, propsName);
78
	   output.close();            
79
     }
80
     catch(Exception e)
81
     {
82
     	System.err.println("\n[PropertyManager] ERROR - Failed to save properties file \""
83
                          + propsName + "\": "
84
                          + e.getMessage());       
85
     }
86
 }
87
*/
88
 
89
 
90
}
0 91

  
tags/v2_0_0_Build_2042/libraries/libRemoteServices/src/org/gvsig/remoteclient/utils/EncodingXMLParser.java
1
package org.gvsig.remoteclient.utils;
2

  
3
import java.io.BufferedReader;
4
import java.io.File;
5
import java.io.FileInputStream;
6
import java.io.FileReader;
7
import java.io.IOException;
8
import java.io.StringReader;
9

  
10
import org.kxml2.io.KXmlParser;
11
import org.xmlpull.v1.XmlPullParserException;
12

  
13
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
14
 *
15
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
16
 *
17
 * This program is free software; you can redistribute it and/or
18
 * modify it under the terms of the GNU General Public License
19
 * as published by the Free Software Foundation; either version 2
20
 * of the License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU General Public License
28
 * along with this program; if not, write to the Free Software
29
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
30
 *
31
 * For more information, contact:
32
 *
33
 *  Generalitat Valenciana
34
 *   Conselleria d'Infraestructures i Transport
35
 *   Av. Blasco Ib??ez, 50
36
 *   46010 VALENCIA
37
 *   SPAIN
38
 *
39
 *      +34 963862235
40
 *   gvsig@gva.es
41
 *      www.gvsig.gva.es
42
 *
43
 *    or
44
 *
45
 *   IVER T.I. S.A
46
 *   Salamanca 50
47
 *   46005 Valencia
48
 *   Spain
49
 *
50
 *   +34 963163400
51
 *   dac@iver.es
52
 */
53
/* CVS MESSAGES:
54
 *
55
 * $Id$
56
 * $Log$
57
 *
58
 */
59
/**
60
 * This class is a XML pull parser that discover and manage
61
 * the file encoding
62
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
63
 */
64
public class EncodingXMLParser extends KXmlParser{
65

  
66
	/**
67
	 * This method reads the first bytes of the file and
68
	 * try to discover the file encoding. It parses the file
69
	 * with retrieved encoding.
70
	 * @param file
71
	 * @throws XmlPullParserException 
72
	 * @throws IOException 
73
	 */
74
	public void setInput(File file) throws XmlPullParserException, IOException{
75
		FileReader reader = null;
76
		reader = new FileReader(file);
77
		BufferedReader br = new BufferedReader(reader);
78
		String encoding = "UTF-8";
79

  
80
		char[] buffer = new char[(int) file.length()];
81
		reader.read(buffer);
82
		String string = new String(buffer);
83

  
84
		// patch for ArcIMS + WMS connector > 9.0 bug
85
		int a = string.toLowerCase().indexOf("<?xml");
86
		if (a !=-1){
87
			string = string.substring(a, string.length());
88
		}
89
		// end patch
90

  
91
		StringBuffer st = new StringBuffer(string);
92
		String searchText = "encoding=\"";
93
		int index = st.indexOf(searchText);
94
		if (index>-1) {
95
			st.delete(0, index+searchText.length());
96
			encoding = st.substring(0, st.indexOf("\""));
97
		}			
98
		
99
		if (a > 0){
100
			// patch for ArcIMS + WMS connector > 9.0 bug
101
			super.setInput(new StringReader(string));
102
			// end patch
103
		}else{
104
			super.setInput( new FileInputStream(file), encoding);
105
		}
106
	}
107
}
108

  
tags/v2_0_0_Build_2042/libraries/libRemoteServices/src/org/gvsig/remoteclient/utils/DumbXMLParser.java
1
/*
2
 * Created on 07-sep-2005
3
 */
4
package org.gvsig.remoteclient.utils;
5
import java.awt.geom.Rectangle2D;
6
import java.util.TreeMap;
7

  
8
/**
9
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
10
 */
11
public class DumbXMLParser {
12
	public Rectangle2D getBoundingBox(String l) {
13
		// System.out.println("l='"+l+"'");
14
		TreeMap pairs = getPairs(l);
15
		return getBoundingBox(pairs);
16
	}
17

  
18
	public Rectangle2D getBoundingBox(TreeMap pairs) {
19
		double minX = Double.parseDouble((String)pairs.get("minx"));
20
		double minY = Double.parseDouble((String)pairs.get("miny"));
21
		double maxX = Double.parseDouble((String)pairs.get("maxx"));
22
		double maxY = Double.parseDouble((String)pairs.get("maxy"));
23

  
24
		return new Rectangle2D.Double(minX, minY, maxX-minX, maxY-minY);
25
	}
26
	
27
	public TreeMap getPairs(String l) {
28
		TreeMap data = new TreeMap();
29
		int pos = l.indexOf("=");
30
		while (pos>0) {
31
			String cmd = l.substring(l.lastIndexOf(" ", pos)+1,
32
				l.indexOf("\"", pos+2)+1);
33
			//System.out.println(cmd);
34
			int comilla = cmd.indexOf("\"");
35
			if (comilla > 0) {
36
				String key = l.substring(l.lastIndexOf(" ", pos)+1, pos);
37
				String value = cmd.substring(comilla+1,cmd.length()-1);
38
				data.put(key.toLowerCase(), value);
39
			}
40
			pos = l.indexOf("=", pos+1);
41
		}
42
		return data;
43
	}
44
	
45
	/**
46
	 * saca un valor double de una linea del tipo 
47
	 * <westBoundLongitude>-180</westBoundLongitude>
48
	 * @param l
49
	 * @return
50
	 */
51
	public double getValueDouble(String l) {
52
		return Double.parseDouble(getValue(l));	
53
	}
54
	
55
	/**
56
	 * saca un valor double de una linea del tipo 
57
	 * <westBoundLongitude>-180</westBoundLongitude>
58
	 * @param l
59
	 * @return
60
	 */
61
	public String getValue(String l) {
62
		int pos = l.indexOf(">");
63
		return l.substring(pos+1, l.indexOf("<", pos));	
64
	}
65
	
66
	public String getToken(String l, int num) {
67
		int pos = l.indexOf("<");
68
		for (int i=0; i<num; i++)
69
			pos = l.indexOf("<", pos+1);
70
		return l.substring(pos+1, l.indexOf(">", pos));	
71
	}
72
	
73
	public int countTokens(String l) {
74
		int times = 0;
75
		int pos = l.indexOf("<");
76
		while (pos >= 0) {
77
			times ++; pos = l.indexOf("<", pos+1);
78
		}
79
		return times;
80
	}
81
}
0 82

  
tags/v2_0_0_Build_2042/libraries/libRemoteServices/src/org/gvsig/remoteclient/utils/CapabilitiesTags.java
1
package org.gvsig.remoteclient.utils;
2

  
3
/**
4
 * Class containing a description for all the TAGS defined in the Capabilities Object returned from a WMS
5
 * note: this describes the WMT_MS_Capabilitites 1.1.1
6
 * */
7
public class CapabilitiesTags
8
{
9
	private CapabilitiesTags () {};
10
	public final static String CAPABILITIES_ROOT1_1_0="WMT_MS_Capabilities";
11
	public final static String CAPABILITIES_ROOT1_1_1="WMT_MS_Capabilities";
12
	public final static String CAPABILITIES_ROOT1_3_0="WMS_Capabilities";
13
	public final static String CAPABILITY="Capability";
14
	public final static String SERVICE ="Service";
15
	public final static String NAME ="Name";
16
	public final static String TITLE ="Title";
17
	public final static String ABSTRACT ="Abstract";
18
	public final static String KEYWORDLIST ="KeywordList";
19
	public final static String KEYWORD ="Keyword";
20
	public final static String ONLINERESOURCE ="OnlineResource";
21

  
22
	public final static String CONTACTINFORMATION ="ContactInformation";
23
	public final static String CONTACTPOSITION ="ContactPosition";
24
	public final static String CONTACTADRESS ="ContactAddress";
25
	public final static String CONTACTVOICETELEPHONE ="ContactVoiceTelephone";
26
	public final static String CONTACTFACSIMILETELEPHONE ="ContactFacsimileTelephone";
27
	public final static String CONTACTPERSONPRIMARY ="ContactPersonPrimary";
28
	public final static String CONTACTPERSON ="ContactPerson";
29
	public final static String CONTACTORGANIZATION ="ContactOrganization";
30
	public final static String CONTACTEMAILADRESS ="ContactElectronicMailAddress";
31
	public final static String FEES ="Fees";
32
	public final static String ACCESSCONSTRAINTS ="AccessConstraints";
33
	public final static String REQUEST ="Request";
34
	public final static String GETCAPABILITIES ="GetCapabilities";
35
	public final static String FORMAT ="Format";
36
	public final static String DCPTYPE ="DCPType";
37
	public final static String XMLNS_XLINK ="xmlns:xlink";
38
	public final static String XLINK_TYPE ="xlink:type";
39
	public final static String XLINK_HREF ="xlink:href";
40
	public final static String HTTP ="HTTP";
41
	public final static String GET ="Get";
42
	public final static String POST ="Post";
43
	public final static String GETMAP ="GetMap";
44
	public final static String GETFEATUREINFO ="GetFeatureInfo";
45
	public final static String DESCRIBELAYER ="DescribeLayer";
46
	public final static String GETLEGENDGRAPHIC ="GetLegendGraphic";
47
	public final static String EXCEPTION ="Exception";
48
	public final static String VENDORSPECIFICCAPABILITIES ="VendorSpecificCapabilities";
49
	public final static String USERDEFINEDSYMBOLIZATION ="UserDefinedSymbolization";
50
	public final static String LAYER ="Layer";
51
	public final static String EXCEPTIONS_1_1_x = "application/vnd.ogc.se_xml";
52
	public final static String EXCEPTIONS_1_3_0 = "XML";
53
//	<!ELEMENT Layer ( Name?, Title, Abstract?, KeywordList?, SRS*,
54
//			LatLonBoundingBox?, BoundingBox*, Dimension*, Extent*,
55
//			Attribution?, AuthorityURL*, Identifier*, MetadataURL*, DataURL*,
56
//			FeatureListURL*, Style*, ScaleHint?, Layer* ) >
57
	public final static String SRS ="SRS";
58
	public final static String CRS ="CRS";
59
	public final static String DEAFAULTSRS ="DefaultSRS";	
60

  
61
	public final static String BOUNDINGBOX ="BoundingBox";
62
	public final static String WGS84BOUNDINGBOX = "WGS84BoundingBox";
63
	public final static String LOWERCORNER = "LowerCorner";
64
	public final static String UPPERCORNER = "UpperCorner";
65
	// Used in the WMS as "LatLonBoundingBox" don't change it and create your own one
66
	public final static String LATLONBOUNDINGBOX ="LatLonBoundingBox";
67
	public final static String EX_GEOGRAPHICBOUNDINGBOX ="EX_GeographicBoundingBox";
68
	public final static String METADATAURL ="MetadataURL";
69
	public final static String LOGOURL ="LogoURL";
70
	public final static String AUTHORITYURL ="AuthorityURL";
71
	public final static String STYLE ="Style";
72
	public final static String LEGENDURL="LegendURL";
73
	public final static String SCALEHINT ="ScaleHint";
74
	public final static String MINSCALEDENOMINATOR ="MinScaleDenominator";
75
	public final static String DIMENSION ="Dimension";
76
	public final static String TIME ="Time";
77
	public final static String CONSTRAINT = "Constraint";
78

  
79
	// capabilities attributes
80
	public final static String VERSION ="version";
81
	public final static String UPDATESEQUENCE ="updatesequence";
82
	public final static String ENCODING ="encoding";
83
	public final static String STANDALONE ="standalone";
84
	public final static String SUPPORTSLD ="SupportSLD";
85
	public final static String USERLAYER ="UserLayer";
86
	public final static String USERSTYLE ="UserStyle";
87
	public final static String QUERYABLE ="queryable";
88
	public final static String CASCADED ="cascaded";
89
	public final static String NOSUBSETS ="noSubsets";
90
	public final static String OPAQUE ="opaque";
91
	public final static String FIXEDWIDTH ="fixedWidth";
92
	public final static String FIXEDHEIGHT ="fixedHeight";
93
    public static final String ATTRIBUTION = "Attribution";
94
    
95
    //LegendURL attributes
96
    public static final String WIDTH = "width";
97
    public static final String HEIGHT = "height";
98

  
99
	public final static String MINX ="minx";
100
	public final static String MINY ="miny";
101
	public final static String MAXX ="maxx";
102
	public final static String MAXY ="maxy";
103
	public final static String RESX ="resx";
104
	public final static String RESY ="rexy";
105
	public final static String WESTBOUNDLONGITUDE ="westBoundLongitude";
106
	public final static String EASTBOUNDLONGITUDE ="eastBoundLongitude";
107
	public final static String SOUTHBOUNDLATITUDE ="southBoundLatitude";
108
	public final static String NORTHBOUNDLATITUDE ="northBoundLatitude";
109

  
110
	public final static String TYPE ="type";
111
	public final static String MIN ="min";
112
	public final static String MAX ="max";
113
	public final static String DIMENSION_NAME ="name";
114
    public final static String DIMENSION_UNITS ="units";
115
    public final static String DIMENSION_UNIT_SYMBOL ="unitSymbol";
116

  
117
    // WMS Extent specifics
118
    public static final String EXTENT="Extent";
119
    public static final String EXTENT_MULTIPLE_VALUES = "multipleValues";
120
    public static final String EXTENT_NEAREST_VALUE = "nearestValue";
121
    public static final String EXTENT_CURRENT="current";
122

  
123

  
124
    // WCS specific
125
    public static final String WCS_CAPABILITIES_ROOT1_0_0 = "WCS_Capabilities";
126
    public static final String WCS_CONTENTMETADATA = "ContentMetadata";
127
    public static final String WCS_LABEL = "label";
128
    public static final String WCS_KEYWORDS = "keywords";
129
    public static final String WCS_DESCRIPTION = "description";
130
    public static final String DESCRIBECOVERAGE = "DescribeCoverage";
131
    public static final String GETCOVERAGE = "GetCoverage";
132
    public static final String WCS_COVERAGEOFFERING = "CoverageOffering";
133
    public static final String WCS_COVERAGEOFFERINGBRIEF = "CoverageOfferingBrief";
134

  
135
    // Miscelaneous
136
    public final static String DEFAULT ="default";
137

  
138
    public final static String EPSG_4326="EPSG:4326";
139
    public final static String CRS_84 ="CRS:84";
140

  
141
    //WFS specific
142
    public static final String WFS_NAMESPACE_PREFIX = "wfs";
143
    public static final String WFS_CAPABILITIES_ROOT1_0_0 = "WFS_Capabilities";
144
    public static final String WFS_TITLE = "Title";
145
    public static final String WFS_ABSTRACT = "Abstract";
146
	public final static String WFS_ONLINERESOURCE ="OnlineResource";
147
	public final static String WFS_FEATURETYPELIST="FeatureTypeList";
148
	public final static String WFS_FEATURETYPE="FeatureType";
149
	public final static String WFS_SCHEMAROOT="schema";
150
	public final static String WFS_DESCRIBEFEATURETYPE ="DescribeFeatureType";
151
	public final static String WFS_GETFEATURE="GetFeature";
152
	public final static String WFS_TRANSACTION = "Transaction";
153
	public final static String WFS_LOCKFEATURE ="LockFeature";
154
	public final static String WFS_KEYWORDS ="Keywords";
155
	public final static String WFS_FEATURE_COLLECTION ="FeatureCollection";
156
	public final static String LATLONGBOUNDINGBOX ="LatLongBoundingBox";
157
	public final static String COMPLEXTYPE="complexType";
158
	public final static String COMPLEXCONTENT = "complexContent";
159
	public final static String EXTENSION = "extension";
160
	public final static String SEQUENCE = "sequence";
161
	public final static String ELEMENT = "element";
162
	public final static String ELEMENT_NAME = "name";
163
	public final static String ELEMENT_TYPE = "type";
164
	public final static String ELEMENT_MINOCCURS = "minOccurs";
165
	public final static String ELEMENT_MAXOCCURS = "maxOccurs";
166
	public final static String ELEMENT_REF = "ref";
167
	public final static String SIMPLETYPE = "simpleType";
168
	public final static String RESTRICTION  = "restriction";
169
	public final static String TOTAL_DIGITS = "totalDigits";
170
	public final static String FRACTION_DIGITS = "fractionDigits";
171
	public final static String VALUE = "value";
172
	public final static String BASE = "base";
173
	public final static String CHOICE = "choice";
174
	public final static String SERVICE_EXCEPTION_REPORT = "ServiceExceptionReport"; 
175
    public final static String EXCEPTION_REPORT = "ExceptionReport"; 
176
	public final static String SERVICE_EXCEPTION = "ServiceException";
177
	public final static String CODE = "code";
178
    public final static String EXCEPTION_CODE = "exceptionCode";
179
    public final static String EXCEPTION_TEXT = "ExceptionText";
180
    public final static String MAXFEATURES = "maxFeatures";
181
    
182
	 //WFS specific (1.1.0)
183
	public final static String SERVICE_IDENTIFICATION = "ServiceIdentification";
184
	public final static String SERVICE_PROVIDER = "ServiceProvider";
185
	public final static String OPERATIONS_METADATA = "OperationsMetadata";
186
	public final static String FEATURE_TYPE_LIST = "FeatureTypeList";
187
	public final static String FILTER_CAPABILITIES = "Filter_Capabilities";
188
	public final static String OPERATION = "Operation";
189
	public final static String DCP = "DCP";
190
	public final static String HREF = "xlink:href";
191
	public final static String OPERATION_NAME = "name";
192
	public final static String DEFAULTMAXFEATURES = "DefaultMaxFeatures";
193
	
194
	
195
	//WFS Code errors
196
	public final static String INVALID_FORMAT = "InvalidFormat";
197
	
198
	//WMTS
199
	public final static String WMTS_GMLTAG = "ows:";
200
	public final static String WMTS_CAPABILITIES = "Capabilities";
201
	public final static String WMTS_SERVICEID = "ServiceIdentification";
202
	public final static String WMTS_SERVICEPROV = "ServiceProvider";
203
	public final static String WMTS_OPMETADATA = "OperationsMetadata";
204
	public final static String WMTS_CONTENTS = "Contents";
205
	//Themes
206
	public final static String WMTS_THEMES = "Themes";
207
	public final static String WMTS_THEME = "Theme";
208
	public final static String WMTS_LAYERREF = "LayerRef";
209
	//Content
210
	public final static String WMTS_LAYER = "Layer";
211
	public final static String WMTS_OTHERSRC = "OtherSource";
212
	public final static String WMTS_TILEMATRIXSET = "TileMatrixSet";
213
	//Style
214
	public final static String WMTS_IDENTIFIER = "Identifier";
215
	public final static String WMTS_TITLE = "Title";
216
	public final static String WMTS_ABSTRACT = "Abstract";
217
	public final static String WMTS_KEYWORDS = "Keywords";
218
	public final static String WMTS_LEGENDURL = "LegendURL";
219
	public final static String WMTS_ISDEFAULT = "isDefault";
220
	//Layer
221
	public final static String WMTS_WGS84BOUNDINGBOX = "WGS84BoundingBox";
222
	public final static String WMTS_BOUNDINGBOX = "BoundingBox";
223
	public final static String WMTS_STYLE = "Style";
224
	public final static String WMTS_FORMAT = "Format";
225
	public final static String WMTS_INFOFORMAT = "InfoFormat";
226
	public final static String WMTS_DIMENSION = "Dimension";
227
	public final static String WMTS_METADATA = "Metadata";
228
	public final static String WMTS_RESOURCEURL = "ResourceURL";
229
	public final static String WMTS_TILEMATRIXSETLINK = "TileMatrixSetLink";
230
	public final static String WMTS_TILEMATRIXLIMITS = "TileMatrixLimits";
231
	//LegendURL
232
	public final static String WMTS_MINSCALEDEN = "MinScaleDenominator";
233
	public final static String WMTS_MAXSCALEDEN = "MaxScaleDenominator";
234
	public final static String WMTS_HREF = "href";
235
	public final static String WMTS_WIDTH = "width";
236
	public final static String WMTS_HEIGHT = "height";
237
	//WGS84BoundingBox
238
	public final static String WMTS_LOWERCORNER = "LowerCorner";
239
	public final static String WMTS_UPPERCORNER = "UpperCorner";
240
	public final static String WMTS_CRS = "crs";
241
	public final static String WMTS_DIMENSIONS = "dimensions";
242
	//Tiles
243
	public final static String WMTS_TILEMATRIX = "TileMatrix";
244
	public final static String WMTS_MINTILEROW = "MinTileRow";
245
	public final static String WMTS_MAXTILEROW = "MaxTileRow";
246
	public final static String WMTS_MINTILECOL = "MinTileCol";
247
	public final static String WMTS_MAXTILECOL = "MaxTileCol";
248
	//TileMatrixSet
249
	public final static String WMTS_SUPPORTEDCRS = "SupportedCRS";
250
	public final static String WMTS_WELLKNOWNSCALESET = "WellKnownScaleSet";
251
	//TileMatrix
252
	public final static String WMTS_SCALEDENOMINATOR = "ScaleDenominator";
253
	public final static String WMTS_TOPLEFTCORNER = "TopLeftCorner";
254
	public final static String WMTS_TILEWIDTH = "TileWidth";
255
	public final static String WMTS_TILEHEIGHT = "TileHeight";
256
	public final static String WMTS_MATRIXWIDTH = "MatrixWidth";
257
	public final static String WMTS_MATRIXHEIGHT = "MatrixHeight";
258
	
259
	public final static String WMTS_UNITSYMBOL = "UnitsSymbol";
260
	public final static String WMTS_DEFAULTVALUE = "Default";
261
	public final static String WMTS_CURRENT = "Current";
262
	public final static String WMTS_AVAILABLEVALUE = "Value";
263
	//ServiceIdentification
264
	public final static String WMTS_SERVICETYPE = "ServiceType";
265
	public final static String WMTS_SERVICETYPEVERSION = "ServiceTypeVersion";
266
	public final static String WMTS_PROFILE = "Profile";
267
	public final static String WMTS_FEES = "Fees";
268
	public final static String WMTS_ACCESSCONSTRAINTS = "AccessConstraints";
269
	
270
	//ServiceProvider
271
	public final static String WMTS_PROVIDERNAME = "ProviderName";
272
	public final static String WMTS_PROVIDERSITE = "ProviderSite";
273
	public final static String WMTS_SERVICECONTACT = "ServiceContact";
274

  
275
}
276

  
277

  
0 278

  
tags/v2_0_0_Build_2042/libraries/libRemoteServices/src/org/gvsig/remoteclient/utils/DescribeCoverageTags.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
/**
42
 *
43
 */
44
package org.gvsig.remoteclient.utils;
45

  
46
/**
47
 * @author jaume
48
 *
49
 */
50
public class DescribeCoverageTags {
51
	private DescribeCoverageTags() {};
52
    public static final String COVERAGE_DESCRIPTION = "CoverageDescription";
53
    public static final String COVERAGE_OFFERING = "CoverageOffering";
54
    public static final String NAME = "name";
55
    public static final String LABEL = "label";
56
    public static final String LONLAT_ENVELOPE = "lonLatEnvelope";
57
	public static final String WGS84 = "WGS84(DD)"; // Decimal Degree
58
	public static final String GML_ENVELOPE = "gml:Envelope";
59
	public static final String GML_POS = "gml:pos";
60
	public static final String SRSNAME = "srsName";
61

  
62
	public static final String DOMAINSET = "domainSet";
63
	public static final String SPATIALDOMAIN = "spatialDomain";
64
	public static final String GRID = "gml:Grid";
65
	public static final String RECTIFIEDGRID = "gml:RectifiedGrid";
66
	public static final String GML_GRIDENVELOPE = "gml:GridEnvelope";
67
	public static final String GML_LIMITS = "gml:limits";
68
	public static final String GML_AXISNAME = "gml:axisName";
69
	public static final String GML_ORIGIN = "gml:origin";
70
	public static final String DIMENSION = "dimension";
71
	public static final String GML_LOW = "gml:low";
72
	public static final String GML_HIGH = "gml:high";
73
	public static final String OFFSETVECTOR = "gml:offsetVector";
74
	public static final String TEMPORALDOMAIN = "temporalDomain";
75
	public static final String GML_TIMEPOSITION = "gml:timePosition";
76
	public static final String TIMEPERIOD = "timePeriod";
77
	public static final String BEGINPOSITION = "beginPosition";
78
	public static final String ENDPOSITION = "endPosition";
79
	public static final String TIMERESOLUTION = "timeResolution";
80

  
81
	public static final String RANGESET = "RangeSet";
82
	/* TODO this can cause eventually problems if in a future the "rangeSet" (not "RangeSet")
83
	 * has more than one sub RangeSet subelement since I'm assuming it and a "rangeSet" tag is
84
	 * simply ignored since it has no effect if it just contains one, and only one, RangeSet
85
	 * subelement.
86
	 */
87
	public static final String AXISDESCRIPTION = "AxisDescription" ;
88
	public static final String VALUES = "values";
89
	public static final String SINGLEVALUE = "singleValue";
90
	public static final String INTERVAL = "interval";
91
	public static final String DEFAULT = "default";
92
	public static final String NULLVALUES = "NullValues";
93

  
94
	public static final String SUPPORTED_CRSS = "supportedCRSs";
95
	public static final String REQUEST_RESPONSE_CRSS = "requestResponseCRSs";
96
	public static final String NATIVE_CRS = "nativeCRSs";
97
	public static final String REQUEST_CRSS = "requestCRSs";
98
	public static final String RESPONSE_CRSS = "responseCRSs";
99

  
100
	public static final String SUPPORTED_FORMATS = "supportedFormats";
101
	public static final String NATIVE_FORMAT = "nativeFormat";
102
	public static final String FORMATS = "formats";
103
	public static final String SUPPORTED_INTERPOLATIONS = "supportedInterpolations";
104
	public static final String INTERPOLATION_METHOD = "interpolationMethod";
105

  
106

  
107
}
0 108

  
tags/v2_0_0_Build_2042/libraries/libRemoteServices/src/org/gvsig/remoteclient/utils/Utilities.java
1
package org.gvsig.remoteclient.utils;
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42

  
43
import java.io.BufferedOutputStream;
44
import java.io.DataOutputStream;
45
import java.io.File;
46
import java.io.FileNotFoundException;
47
import java.io.FileOutputStream;
48
import java.io.FileReader;
49
import java.io.IOException;
50
import java.io.InputStream;
51
import java.io.OutputStream;
52
import java.net.ConnectException;
53
import java.net.URL;
54
import java.net.UnknownHostException;
55
import java.util.Hashtable;
56
import java.util.StringTokenizer;
57
import java.util.Vector;
58

  
59
import org.gvsig.compat.CompatLocator;
60
import org.gvsig.compat.net.Downloader;
61
import org.gvsig.compat.net.ICancellable;
62

  
63

  
64

  
65

  
66
/**
67
 * Clase con m?todos de utilidad en el protocolo WMS
68
 *
69
 * @authors Laura D?az, jaume dominguez faus
70
 */
71
public class Utilities {
72
	private static final Downloader downloader = CompatLocator.getDownloader();
73
    private static String characters;
74
	static boolean canceled;
75
	static final long latency = 500;
76
	/**
77
	 * Used to cancel a group of files
78
	 * <b>key</b>: Group id, <b>value</b>: Boolean (true if
79
	 * the group has to be canceled. Otherwise it is
80
	 * false)
81
	 */
82
	static Hashtable canceledGroup = new Hashtable();
83
	/**
84
	 * <b>key</b>: URL, <b>value</b>: path to the downloaded file.
85
	 */
86
	private static Hashtable downloadedFiles;
87
	static Exception downloadException;
88
	private static final String tempDirectoryPath = System.getProperty("java.io.tmpdir")+"/tmp-andami";
89

  
90

  
91
	static {
92
		characters = "";
93
		for (int j = 32; j<=127; j++){
94
			characters += (char) j;
95
		}
96
		characters += "?????????????????????????????????????????????????\n\r\f\t??";
97
	}
98

  
99

  
100
	/**
101
	 * Checks a File and tries to figure if the file is a text or a binary file.<br>
102
	 * Keep in mind that binary files are those that contains at least one
103
	 * non-printable character.
104
	 *
105
	 * @param file
106
	 * @return <b>true</b> when the file is <b>pretty problably</b> text,
107
	 * <b>false</b> if the file <b>is</b> binary.
108
	 */
109
	public static boolean isTextFile(File file){
110
		return isTextFile(file, 1024);
111
	}
112

  
113
	/**
114
	 * Checks a File and tries to figure if the file is a text or a binary file.<br>
115
	 * Keep in mind that binary files are those that contains at least one
116
	 * non-printable character.
117
	 *
118
	 * @param file
119
	 * @param byteAmount, number of bytes to check.
120
	 * @return <b>true</b> when the file is <b>pretty problably</b> text,
121
	 * <b>false</b> if the file <b>is</b> binary.
122
	 */
123
	public static boolean isTextFile(File file, int byteAmount){
124
		int umbral = byteAmount;
125
		try {
126
			FileReader fr = new FileReader(file);
127
			for (int i = 0; i < umbral; i++) {
128
				int c = fr.read();
129
				if (c==-1){
130
					// End of file. If we reach this
131
					// everything before is printable data.
132
					return true;
133
				}
134
				char ch = (char) c;
135
				if (characters.indexOf(ch)==-1){
136
					// We've found a non-printable character.
137
					// Then we'll assume that this file is binary.
138
					return false;
139
				}
140
			}
141
		} catch (FileNotFoundException e) {
142
			e.printStackTrace();
143
		} catch (IOException e) {
144
			e.printStackTrace();
145
		}
146
		return true;
147
	}
148

  
149
	/**
150
	 * Checks a byte array and tells if it contains only text or contains
151
	 * any binary data.
152
	 *
153
	 * @param file
154
	 * @return <b>true</b> when the data is <b>only</b> text, <b>false</b> otherwise.
155
	 * @deprecated
156
	 */
157
	public static boolean isTextData(byte[] data){
158
		char[] charData = new char[data.length];
159
		for (int i = 0; i<data.length; i++){
160
			charData[i] = (char) data[i];
161
		}
162

  
163
		for (int i = 0; i < data.length; i++) {
164
			int c = charData[i];
165

  
166

  
167
			if (c==-1){
168
				// End of file. If we reach this
169
				// everything before is printable data.
170
				return true;
171
			}
172
			char ch = (char) c;
173
			if (characters.indexOf(ch)==-1){
174
				// We've found a non-printable character.
175
				// Then we'll assume that this file is binary.
176

  
177
				//System.out.println(ch+" at "+i);
178
				return false;
179
			}
180
		}
181
		return true;
182
	}
183

  
184

  
185

  
186

  
187
	/**
188
	 * Copia el contenido de un InputStream en un OutputStream
189
	 *
190
	 * @param in InputStream
191
	 * @param out OutputStream
192
	 */
193
	public static void serializar(InputStream in, OutputStream out) {
194
		byte[] buffer = new byte[102400];
195

  
196
		int n;
197

  
198
		try {
199
			while ((n = in.read(buffer)) != -1) {
200
				out.write(buffer, 0, n);
201
			}
202
		} catch (IOException e) {
203
			e.printStackTrace();
204
		}
205
	}
206

  
207
	/**
208
	 * Elimina del xml la declaraci?n del DTD
209
	 *
210
	 * @param bytes bytes del fichero XML de respuesta a getCapabilities
211
	 * @param startTag Tag raiz del xml respuesta a getCapabilities
212
	 *
213
	 * @return bytes del fichero XML sin la declaraci?n del DTD
214
	 */
215
	public static byte[] eliminarDTD(byte[] bytes, String startTag) {
216
		String text = new String(bytes);
217
		int index1 = text.indexOf("?>") + 2;
218
		int index2;
219

  
220
		try {
221
			index2 = findBeginIndex(bytes, startTag);
222
		} catch (Exception e) {
223
			return bytes;
224
		}
225

  
226
		byte[] buffer = new byte[bytes.length - (index2 - index1)];
227
		System.arraycopy(bytes, 0, buffer, 0, index1);
228
		System.arraycopy(bytes, index2, buffer, index1, bytes.length - index2);
229

  
230
		return buffer;
231
	}
232

  
233
	/**
234
	 * Obtiene el ?ndice del comienzo del xml
235
	 *
236
	 * @param bytes bytes del fichero XML en el que se busca
237
	 * @param tagRaiz Tag raiz del xml respuesta a getCapabilities
238
	 *
239
	 * @return ?ndice donde empieza el tag raiz
240
	 *
241
	 * @throws Exception Si no se encuentra el tag
242
	 */
243
	private static int findBeginIndex(byte[] bytes, String tagRaiz)
244
	throws Exception {
245
		try {
246
			int nodo = 0;
247
			int ret = -1;
248

  
249
			int i = 0;
250

  
251
			while (true) {
252
				switch (nodo) {
253
				case 0:
254

  
255
					if (bytes[i] == '<') {
256
						ret = i;
257
						nodo = 1;
258
					}
259

  
260
					break;
261

  
262
				case 1:
263

  
264
					if (bytes[i] == ' ') {
265
					} else if (bytes[i] == tagRaiz.charAt(0)) {
266
						nodo = 2;
267
					} else {
268
						nodo = 0;
269
					}
270

  
271
					break;
272

  
273
				case 2:
274

  
275
					String aux = new String(bytes, i, 18);
276

  
277
					if (aux.equalsIgnoreCase(tagRaiz.substring(1))) {
278
						return ret;
279
					}
280

  
281
					nodo = 0;
282

  
283
					break;
284
				}
285

  
286
				i++;
287
			}
288
		} catch (Exception e) {
289
			throw new Exception("No se pudo parsear el xml", e);
290
		}
291
	}
292

  
293
	/**
294
	 * Converts the contents of a Vector to a comma separated list
295
	 *
296
	 * */
297
	public static String Vector2CS(Vector v)
298
	{
299
		String str = new String();
300
		if (v != null)
301
		{
302
			int i;
303
			for (i=0; i<v.size() ;i++)
304
			{
305
				str = str + v.elementAt(i);
306
				if (i<v.size()-1)
307
					str = str + ",";
308
			}
309
		}
310
		return str;
311
	}
312

  
313
	public static boolean isValidVersion(String version)
314
	{
315
		if(version.trim().length() == 5)
316
		{
317
			if ( (version.charAt(1)=='.') && (version.charAt(3)=='.'))
318
			{
319
				char x = version.charAt(0);
320
				char y = version.charAt(2);
321
				char z = version.charAt(4);
322

  
323
				if ((Character.isDigit(x)) && (Character.isDigit(y)) && (Character.isDigit(z)))
324
				{
325
					return true;
326
				}
327
				else
328
				{
329
					return false;
330
				}
331
			}
332
			else
333
			{
334
				return false;
335
			}
336
		}
337
		else
338
		{
339
			return false;
340
		}
341
	}
342

  
343
	/**
344
	 * Crea un fichero temporal con un nombre concreto y unos datos pasados por
345
	 * par?metro.
346
	 * @param fileName Nombre de fichero
347
	 * @param data datos a guardar en el fichero
348
	 */
349
	public static void createTemp(String fileName, String data)throws IOException{
350
		File f = new File(fileName);
351
		DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(f)) );
352
		dos.writeBytes(data);
353
		dos.close();
354
		f.deleteOnExit();
355
	}
356

  
357
	/**
358
	 * Checks if a String is a number or not
359
	 *
360
	 * @param String, s
361
	 * @return boolean, true if s is a number
362
	 */
363
	public static boolean isNumber(String s)
364
	{
365
		try
366
		{
367
			//double d = Double.parseDouble(s);
368
			return true;
369
		}
370
		catch(NumberFormatException e)
371
		{
372
			return false;
373
		}
374

  
375
	}
376

  
377
	/**
378
	 * Parses the String containing different items [character] separated and
379
	 * creates a vector with them.
380
	 * @param str String contains item1[c]item2[c]item3...
381
	 * @param c is the string value for separating the items
382
	 * @return Vector containing all the items
383
	 */
384
	public static Vector createVector(String str, String c)
385
	{
386
		StringTokenizer tokens = new StringTokenizer(str, c);
387
		Vector v = new Vector();
388
		try
389
		{
390
			while (tokens.hasMoreTokens())
391
			{
392
				v.addElement(tokens.nextToken());
393
			}
394
			return v;
395
		}
396
		catch (Exception e)
397
		{
398
			return new Vector();
399
		}
400
	}
401

  
402
	/**
403
	 * @param dimensions
404
	 * @return
405
	 */
406
	public static String Vector2URLParamString(Vector v) {
407
		if (v==null) return "";
408
		String s = "";
409
		for (int i = 0; i < v.size(); i++) {
410
			s += v.get(i);
411
			if (i<v.size()-1)
412
				s += "&";
413
		}
414
		return s;
415
	}
416
	
417
	/**
418
	 * Downloads an URL into a temporary file that is removed the next time the
419
	 * tempFileManager class is called, which means the next time gvSIG is launched.
420
	 *
421
	 * @param url
422
	 * @param name
423
	 * @return
424
	 * @throws IOException
425
	 * @throws ServerErrorResponseException
426
	 * @throws ConnectException
427
	 * @throws UnknownHostException
428
	 */
429
	public static synchronized File downloadFile(URL url, String name, ICancellable cancel) throws IOException,ConnectException, UnknownHostException{
430
	    return downloader.downloadFile(url, name, cancel);
431
	}
432
	
433
	private static String calculateFileName(String name){
434
		int index = name.lastIndexOf(".");
435
		if (index > 0){
436
			return tempDirectoryPath + "/" + name.substring(0,index) + System.currentTimeMillis() + 
437
				name.substring(index, name.length());
438
		}
439
		return tempDirectoryPath+"/"+name+System.currentTimeMillis();
440
	}
441

  
442
	/**
443
	 * Downloads a URL using the HTTP Post protocol
444
	 * @param url
445
	 * The server URL
446
	 * @param data
447
	 * The data to send in the request
448
	 * @param name
449
	 * A common name for all the retrieved files
450
	 * @param cancel
451
	 * Used to cancel the downloads
452
	 * @return
453
	 * The retrieved file
454
	 * @throws IOException
455
	 * @throws ConnectException
456
	 * @throws UnknownHostException
457
	 */
458
	public static synchronized File downloadFile(URL url, String data, String name, ICancellable cancel) throws IOException,ConnectException, UnknownHostException{
459
	    return downloader.downloadFile(url, data, name, cancel);
460
	}
461

  
462
	/**
463
	 * Cleans every temporal file previously downloaded.
464
	 */
465
	public static void cleanUpTempFiles() {
466
		downloader.cleanUpTempFiles();
467
	}
468

  
469

  
470
	/**
471
	 * Remove an URL from the system cache. The file will remain in the file
472
	 * system for further eventual uses.
473
	 * @param request
474
	 */
475
	public static void removeURL(URL url) {
476
		downloader.removeURL(url);
477
	}
478

  
479
	/**
480
	 * Remove an URL from the system cache. The file will remain in the file
481
	 * system for further eventual uses.
482
	 * @param request
483
	 */
484
	public static void removeURL(Object url) {
485
	    downloader.removeURL(url);
486
	}
487
	
488
	/**
489
	 * This class has to be deleted when all the classes uses the ICancellable
490
	 * method from libCompat
491
	 * @author gvSIG Team
492
	 * @version $Id$
493
	 * @deprecated You should use always org.gvsig.compat.net.ICancellable
494
	 */
495
	/*private static class CancellableAdapter implements org.gvsig.compat.net.ICancellable {
496
	    private ICancellable cancellable = null;
497

  
498
        public CancellableAdapter(
499
            org.gvsig.remoteclient.wms.ICancellable cancellable) {
500
            super();
501
            this.cancellable = cancellable;
502
        }
503

  
504
        public Object getID() {            
505
            return cancellable.getID();
506
        }
507

  
508
        public boolean isCanceled() {     
509
            return cancellable.isCanceled();
510
        } 	    
511
	}*/
512
}
0 513

  
tags/v2_0_0_Build_2042/libraries/libRemoteServices/src/org/gvsig/remoteclient/utils/BoundaryBox.java
1

  
2
package org.gvsig.remoteclient.utils;
3

  
4
/**
5
 * <p></p>
6
 * 
7
 */
8
public class BoundaryBox {
9
    
10
/**
11
 * <p>Represents ...</p>
12
 * 
13
 */
14
    private double xmin;
15

  
16
/**
17
 * <p>Represents ...</p>
18
 * 
19
 */
20
    private double xmax;
21

  
22
/**
23
 * <p>Represents ...</p>
24
 * 
25
 */
26
    private double ymin;
27

  
28
/**
29
 * <p>Represents ...</p>
30
 * 
31
 */
32
    private double ymax;
33

  
34
/**
35
 * <p>Represents ...</p>
36
 * 
37
 */
38
    private String srs;
39

  
40
/**
41
 * <p>Represents ...</p>
42
 * 
43
 * 
44
 * @return 
45
 */
46
    public double getXmin() {        
47
        return xmin;
48
    } 
49

  
50
/**
51
 * <p>Represents ...</p>
52
 * 
53
 * 
54
 * @param _xmin 
55
 */
56
    public void setXmin(double _xmin) {        
57
        xmin = _xmin;
58
    } 
59

  
60
/**
61
 * <p>Represents ...</p>
62
 * 
63
 * 
64
 * @return 
65
 */
66
    public double getXmax() {        
67
        return xmax;
68
    } 
69

  
70
/**
71
 * <p>Represents ...</p>
72
 * 
73
 * 
74
 * @param _xmax 
75
 */
76
    public void setXmax(double _xmax) {        
77
        xmax = _xmax;
78
    } 
79

  
80
/**
81
 * <p>Represents ...</p>
82
 * 
83
 * 
84
 * @return 
85
 */
86
    public double getYmin() {        
87
        return ymin;
88
    } 
89

  
90
/**
91
 * <p>Represents ...</p>
92
 * 
93
 * 
94
 * @param _ymin 
95
 */
96
    public void setYmin(double _ymin) {        
97
        ymin = _ymin;
98
    } 
99

  
100
/**
101
 * <p>Represents ...</p>
102
 * 
103
 * 
104
 * @return 
105
 */
106
    public double getYmax() {        
107
        return ymax;
108
    } 
109

  
110
/**
111
 * <p>Represents ...</p>
112
 * 
113
 * 
114
 * @param _ymax 
115
 */
116
    public void setYmax(double _ymax) {        
117
        ymax = _ymax;
118
    } 
119

  
120
/**
121
 * <p>Represents ...</p>
122
 * 
123
 * 
124
 * @return 
125
 */
126
    public String getSrs() {        
127
        return srs;
128
    } 
129

  
130
/**
131
 * <p>Represents ...</p>
132
 * 
133
 * 
134
 * @param _srs 
135
 */
136
    public void setSrs(String _srs) {        
137
        srs = _srs;
138
    }
139
    
140
    public String toString(){
141
        String s = srs + " (" + xmin + ", " + ymin + ", " + xmax + ", " + ymax + ")";
142
        
143
        return s;
144
    }
145
 }
0 146

  
tags/v2_0_0_Build_2042/libraries/libRemoteServices/src/org/gvsig/remoteclient/utils/DateTime.java
1

  
2
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib��ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
42
package org.gvsig.remoteclient.utils;
43
import java.util.Calendar;
44
import java.util.Date;
45
import java.util.GregorianCalendar;
46
import java.util.Locale;
47

  
48
/**
49
 * This class contains static methods to manage Dates. It was principally 
50
 * created because of some problems doing the "String do DateTime" 
51
 * and the "DateTime to String" conversions.  
52
 * 
53
 * @author Jorge Piera Llodr� (piera_jor@gva.es)
54
 */
55
public class DateTime {
56

  
57
/**
58
 * returns the current date
59
 * 
60
 * 
61
 * @return java.util.Date
62
 */
63
    public static Date getCurrentDate() {        
64
        Calendar cal = new GregorianCalendar();
65
 
66
        return cal.getTime();
67
    } 
68

  
69
/**
70
 * It trnasforms one date in one String
71
 * 
72
 * 
73
 * @return A String
74
 * @param dtK Date
75
 * @param sFormat Date format. Example: "Y-m-d H:i:s.Z";
76
 */
77
    public static String dateToString(Date dtK, String sFormat) {        
78
        String sDate;
79
        int nYear;
80
        int nMonth;
81
        int nDay;
82
        int nHour;
83
        int nMinute;
84
        int nSecond;
85
        int nMS;
86
        Calendar clnK;
87
        String sf;
88
        int jc;
89
        clnK = Calendar.getInstance(Locale.US);
90
        clnK.setTime(dtK);
91
        nYear = clnK.get(Calendar.YEAR);
92
        nMonth = 1 + clnK.get(Calendar.MONTH);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff