📄 featuretypeinfodto.java
字号:
/* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
* This code is licensed under the GPL 2.0 license, availible at the root
* application directory.
*/
package org.vfny.geoserver.global.dto;
import com.vividsolutions.jts.geom.Envelope;
import org.opengis.filter.Filter;
import org.vfny.geoserver.config.DataConfig;
import org.vfny.geoserver.global.FeatureTypeInfo;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* Data Transfer Object used for GeoServer FeatureTypeInfo information.
*
* <p>
* FeatureTypeInfo is used because FeatureType is already used to represent
* schema information in GeoTools2.
* </p>
*
* <p>
* Data Transfer object are used to communicate between the GeoServer
* application and its configuration and persistent layers. As such the class
* is final - to allow for its future use as an on-the-wire message.
* </p>
* <pre>Example:<code>
* FeatureTypeInfoDTO ftiDto = new FeatureTypeInfoDTO();
* ftiDto.setName("My Feature Type");
* ftiDto.setTitle("The Best Feature Type");
* ftiDto.setSRS(23769);
* ftiDto.setDataStoreId("myDataStore");
* </code></pre>
*
* @author dzwiers, Refractions Research, Inc.
* @version $Id: FeatureTypeInfoDTO.java 7265 2007-07-18 12:51:13Z aaime $
*/
public final class FeatureTypeInfoDTO implements DataTransferObject {
/** The Id of the datastore which should be used to get this featuretype. */
private String dataStoreId;
/** A bounding box in EPSG:4326 for this featuretype */
private Envelope latLongBBox;
/** A bounding box in native's CRS for this featuretype */
private Envelope nativeBBox;
/** native wich EPGS code for the FeatureTypeInfo */
private int SRS;
/** either reproject or force, see {@link FeatureTypeInfo} */
private int SRSHandling;
/** Copy of the featuretype schema as a string. */
private List schema;
/** The schema name. */
private String schemaName;
/**
* The schemaBase name.
*
* <p>
* Example NullType, or PointPropertyType.
* </p>
*/
private String schemaBase;
/**
* The featuretype name.
*
* <p>
* Often related to the title - like bc_roads_Type
* </p>
*/
private String name;
private String wmsPath;
/**
* The featuretype directory name. This is used to write to, and is stored
* because it may be longer than the name, as this often includes
* information about the source of the featuretype.
*/
private String dirName;
/** The featuretype title */
private String title;
/** The feature type abstract, short explanation of this featuretype. */
private String _abstract;
/** A list of keywords to associate with this featuretype. */
private List keywords;
/** A list of metadataURLs to associate with this featuretype. */
private List metadataLinks;
/** Used to limit the number of decimals used in GML representations. */
private int numDecimals;
/**
* the list of exposed attributes. If the list is empty or not present at
* all, all the FeatureTypeInfo's attributes are exposed, if is present,
* only those oattributes in this list will be exposed by the services
*/
private Filter definitionQuery = null;
/** The default style name. */
private String defaultStyle;
/** Other Style Names. */
private ArrayList styles = new ArrayList();
// Modif C. Kolbowicz - 06/10/2004
/** The legend icon description. */
private LegendURLDTO legendURL;
//-- Modif C. Kolbowicz - 06/10/2004
/** Holds the location of the file that contains schema information.*/
private File schemaFile;
/**
* FeatureTypeInfo constructor.
*
* <p>
* does nothing
* </p>
*/
public FeatureTypeInfoDTO() {
}
/**
* This value is added the headers of generated maps, marking them as being both
* "cache-able" and designating the time for which they are to remain valid.
* The specific header added is "Cache-Control: max-age="
*/
private String cacheMaxAge;
/**
* Should we be adding the CacheControl: max-age header to outgoing maps which include this layer?
*/
private boolean cachingEnabled;
/**
* FeatureTypeInfo constructor.
*
* <p>
* Creates a copy of the FeatureTypeInfo provided. If the FeatureTypeInfo
* provided is null then default values are used. All the data structures
* are cloned.
* </p>
*
* @param dto The featuretype to copy.
*
* @throws NullPointerException DOCUMENT ME!
*/
public FeatureTypeInfoDTO(FeatureTypeInfoDTO dto) {
if (dto == null) {
throw new NullPointerException("Non null FeatureTypeInfoDTO required");
}
dataStoreId = dto.getDataStoreId();
latLongBBox = CloneLibrary.clone(dto.getLatLongBBox());
nativeBBox = CloneLibrary.clone(dto.getNativeBBox());
SRS = dto.getSRS();
SRSHandling = dto.getSRSHandling();
schema = dto.getSchemaAttributes();
name = dto.getName();
wmsPath = dto.getWmsPath();
title = dto.getTitle();
_abstract = dto.getAbstract();
numDecimals = dto.getNumDecimals();
definitionQuery = dto.getDefinitionQuery();
// Modif C. Kolbowicz - 06/10/2004
legendURL = dto.getLegendURL();
//-- Modif C. Kolbowicz - 06/10/2004
try {
keywords = CloneLibrary.clone(dto.getKeywords()); //clone?
} catch (Exception e) {
keywords = new LinkedList();
}
try {
metadataLinks = CloneLibrary.clone(dto.getMetadataLinks()); //clone?
} catch (Exception e) {
metadataLinks = new LinkedList();
}
defaultStyle = dto.getDefaultStyle();
styles = dto.getStyles();
dirName = dto.getDirName();
schemaName = dto.getSchemaName();
schemaBase = dto.getSchemaBase();
cachingEnabled = dto.isCachingEnabled();
cacheMaxAge = dto.getCacheMaxAge();
}
/**
* Implement clone as a deep copy.
*
* @return A copy of this FeatureTypeInfo
*
* @see java.lang.Object#clone()
*/
public Object clone() {
return new FeatureTypeInfoDTO(this);
}
/**
* Implement equals.
*
* <p>
* recursively tests to determine if the object passed in is a copy of this
* object.
* </p>
*
* @param obj The FeatureTypeInfo object to test.
*
* @return true when the object passed is the same as this object.
*
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if ((obj == null) || !(obj instanceof FeatureTypeInfoDTO)) {
return false;
}
FeatureTypeInfoDTO f = (FeatureTypeInfoDTO) obj;
boolean r = true;
r = r && (dataStoreId == f.getDataStoreId());
if (latLongBBox != null) {
r = r && latLongBBox.equals(f.getLatLongBBox());
} else if (f.getLatLongBBox() != null) {
return false;
}
if (nativeBBox != null) {
r = r && nativeBBox.equals(f.getNativeBBox());
} else if (f.getNativeBBox() != null) {
return false;
}
r = r && (SRS == f.getSRS());
r = r && (SRSHandling == f.getSRSHandling());
if (schema != null) {
r = r && schema.equals(f.getSchemaAttributes());
} else if (f.getSchemaAttributes() != null) {
return false;
}
// Modif C. Kolbowicz - 06/10/2004
if (legendURL != null) {
r = r && schema.equals(f.getLegendURL());
} else if (f.getLegendURL() != null) {
return false;
}
//-- Modif C. Kolbowicz - 06/10/2004
r = r && (defaultStyle == f.getDefaultStyle());
r = r && (styles == f.getStyles());
r = r && (name == f.getName());
r = r && (wmsPath == f.getWmsPath());
r = r && (title == f.getTitle());
r = r && (_abstract == f.getAbstract());
r = r && (numDecimals == f.getNumDecimals());
if (definitionQuery != null) {
r = r && definitionQuery.equals(f.getDefinitionQuery());
} else if (f.getDefinitionQuery() != null) {
return false;
}
if (keywords != null) {
r = r && EqualsLibrary.equals(keywords, f.getKeywords());
} else if (f.getKeywords() != null) {
return false;
}
if (metadataLinks != null) {
r = r && EqualsLibrary.equals(metadataLinks, f.getMetadataLinks());
} else if (f.getMetadataLinks() != null) {
return false;
}
r = r && (dirName == f.getDirName());
r = r && (schemaName == f.getSchemaName());
r = r && (schemaBase == f.getSchemaBase());
r = r && (isCachingEnabled() == f.isCachingEnabled());
r = r && ((getCacheMaxAge() != null) && getCacheMaxAge().equals(f.getCacheMaxAge()));
return r;
}
/**
* Implement hashCode.
*
* @return Service hashcode or 0
*
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
int r = 1;
if (name != null) {
r *= name.hashCode();
}
if (dataStoreId != null) {
r *= dataStoreId.hashCode();
}
// Modif C. Kolbowicz - 06/10/2004
if (legendURL != null) {
r *= legendURL.hashCode();
}
//-- Modif C. Kolbowicz - 06/10/2004
if (title != null) {
r *= title.hashCode();
}
if (SRS != 0) {
r = SRS % r;
}
r += SRSHandling;
if (cacheMaxAge != null) {
r *= cacheMaxAge.hashCode();
}
if (cachingEnabled) {
r += 1;
}
return r;
}
/**
* Short description of FeatureType.
*
* @return Description of FeatureType
*/
public String getAbstract() {
return _abstract;
}
/**
* Identifier of DataStore used to create FeatureType.
*
* @return DataStore identifier
*/
public String getDataStoreId() {
return dataStoreId;
}
/**
* List of keywords (limitied to text).
*
* @return List of Keywords about this FeatureType
*/
public List getKeywords() {
return keywords;
}
/**
* List of metadataURLs (limited to text).
*
* @return List of metadataURLs about this FeatureType
*/
public List getMetadataLinks() {
return metadataLinks;
}
/**
* Convience method for dataStoreId.typeName.
*
* <p>
* This key may be used to store this FeatureType in a Map for later.
* </p>
*
* @return dataStoreId.typeName
*/
public String getKey() {
return getDataStoreId() + DataConfig.SEPARATOR + getName();
}
/**
* The extent of this FeatureType.
*
* <p>
* Extent is measured against the tranditional LatLong coordinate system.
* </p>
*
* @return Envelope of FeatureType
*/
public Envelope getLatLongBBox() {
return latLongBBox;
}
/**
* Sets the feature type's envelope in its
* native CRS for cached storage.
*
* @param envelope
*/
public void setNativeBBox(Envelope envelope) {
nativeBBox = envelope;
}
/**
* The extent of this FeatureType.<p>Extent is measured against the
* FeatureType's native coordinate system.</p>
*
* @return Envelope of FeatureType
*/
public Envelope getNativeBBox() {
return nativeBBox;
}
/**
* Name of featureType, must match typeName provided by DataStore.
*
* @return typeName of FeatureType
*/
public String getName() {
return name;
}
/**
* Spatial Reference System for FeatureType.
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -