📄 datadto.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.
*/
/* 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 java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
/**
* Data Transfer Object used to represent GeoServer Catalog information.
*
* <p>
* Represents an instance of the catalog.xml file in the configuration of the
* server, along with associated configuration files for the feature types.
* </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>
*
* <p>
* Example:
* </p>
* <pre><code>
* DataDTO dDto = new DataDTO();
* Map m = new HashMap();
* NameSpaceInfoDTO ns = new NameSpaceInfoDTO();
* ns.setUri("dzwiers.refractions.net");
* m.put("nsDave",ns);
* dDto.setNameSpaces(m);
* ns = new NameSpaceInfoDTO();
* ns.setUri("jgarnett.refractions.net");
* ns.setDefault(true);
* dDto.addNameSpace("nsJody"ns);
* dDto.setDefaultNameSpace(ns);
* ...
* </code></pre>
*
* @author dzwiers, Refractions Research, Inc.
* @author $Author: Alessio Fabiani (alessio.fabiani@gmail.com) $ (last modification)
* @author $Author: Simone Giannecchini (simboss1@gmail.com) $ (last modification)
* @version $Id: DataDTO.java 6326 2007-03-15 18:36:40Z jdeolive $
*
* @see DataSource
* @see FeatureTypeInfo
* @see StyleConfig
*/
public final class DataDTO implements DataTransferObject {
/**
* DataStoreInfoDTO referenced by key "<code>dataStoreID</code>".
*
* @see org.vfny.geoserver.global.dto.DataStoreInfoDTO
*
* @uml.property name="dataStores"
* @uml.associationEnd elementType="java.lang.String" qualifier="key:java.lang.String
* org.vfny.geoserver.global.dto.DataStoreInfoDTO" multiplicity="(0 -1)" ordering=
* "ordered"
*/
private Map dataStores;
/**
* CoverageStoreInfoDTO referenced by key "<code>formatID</code>".
*
* @see org.vfny.geoserver.global.dto.CoverageStoreInfoDTO
*
* @uml.property name="formats"
* @uml.associationEnd elementType="java.lang.String" qualifier="getFormatId:java.lang.String
* org.vfny.geoserver.global.dto.CoverageStoreInfoDTO" multiplicity="(0 -1)" ordering="ordered"
*/
private Map formats;
/**
* NamespaceDTO referenced by key "<code>prefix</code>".
*
* @see org.vfny.geoserver.global.dto.NameSpaceInfoDTO
*
* @uml.property name="nameSpaces"
* @uml.associationEnd elementType="java.lang.String" qualifier="key:java.lang.String
* org.vfny.geoserver.global.dto.NameSpaceInfoDTO" multiplicity="(0 -1)" ordering=
* "ordered"
*/
private Map nameSpaces;
/**
* FeatureTypesInfoDTO referenced by key
* "<code>dataStoreID.typeName</code>"
*
* @see org.vfny.geoserver.global.dto.FeatureTypeInfoDTO
*
* @uml.property name="featuresTypes"
* @uml.associationEnd elementType="org.vfny.geoserver.global.dto.AttributeTypeInfoDTO"
* qualifier="key:java.lang.String org.vfny.geoserver.global.dto.FeatureTypeInfoDTO"
* multiplicity="(0 -1)" ordering="ordered"
*/
private Map featuresTypes;
/**
*
* @uml.property name="coverages"
* @uml.associationEnd qualifier="key:java.lang.String org.vfny.geoserver.global.dto.DataTransferObject"
* multiplicity="(0 1)"
*/
private Map coverages;
/**
* StyleDTO referenced by key "<code>id</code>"
*
* @see org.vfny.geoserver.global.dto.StyleDTO
*
* @uml.property name="styles"
* @uml.associationEnd qualifier="key:java.lang.String org.vfny.geoserver.global.dto.DataTransferObject"
* multiplicity="(0 1)"
*/
private Map styles;
/**
* The default namespace for the server instance.
*
* <p>
* This may be <code>null</code> if a default has not been defined. the
* config files is supposed to use the "first" Namespace when a default is
* not defined - but we have lost all sense of order by placing this in a
* Map. For 99% of the time when no default has been provided it is
* because there is only one Namespace for the application.
* </p>
*
* @see org.vfny.geoserver.global.dto.NameSpaceInfo
*
* @uml.property name="defaultNameSpacePrefix" multiplicity="(0 1)"
*/
private String defaultNameSpacePrefix;
/**
* Data constructor.
*
* <p>
* does nothing
* </p>
*/
public DataDTO() {
}
/**
* Creates a duplicate of the provided DataDTO using deep copy.
*
* <p>
* Creates a copy of the Data provided. If the Data provided is null then
* default values are used. All the datastructures are cloned.
* </p>
*
* @param dto The catalog to copy.
*
* @throws NullPointerException DOCUMENT ME!
*/
public DataDTO(DataDTO dto) {
if (dto == null) {
throw new NullPointerException("Non null DataDTO required");
}
try {
dataStores = CloneLibrary.clone(dto.getDataStores());
} catch (Exception e) {
dataStores = new HashMap();
}
try {
formats = CloneLibrary.clone(dto.getFormats());
} catch (Exception e) {
formats = new HashMap();
}
try {
nameSpaces = CloneLibrary.clone(dto.getNameSpaces());
} catch (Exception e) {
nameSpaces = new HashMap();
}
try {
featuresTypes = CloneLibrary.clone(dto.getFeaturesTypes());
} catch (Exception e) {
featuresTypes = new HashMap();
}
try {
coverages = CloneLibrary.clone(dto.getCoverages());
} catch (Exception e) {
coverages = new HashMap();
}
try {
styles = CloneLibrary.clone(dto.getStyles());
} catch (Exception e) {
styles = new HashMap();
}
defaultNameSpacePrefix = dto.getDefaultNameSpacePrefix();
}
/**
* Implement clone as a Deep copy.
*
* @return A copy of this Data
*
* @see java.lang.Object#clone()
*/
public Object clone() {
return new DataDTO(this);
}
/**
* Implement equals as part of the Object contract.
*
* <p>
* Recursively tests to determine if the object passed in is a copy of this
* object.
* </p>
*
* @param other The Data 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 other) {
if ((other == null) || !(other instanceof DataDTO)) {
return false;
}
DataDTO c = (DataDTO) other;
boolean r = true;
if (dataStores != null) {
r = r && EqualsLibrary.equals(dataStores, c.getDataStores());
} else if (c.getDataStores() != null) {
return false;
}
if (formats != null) {
r = r && EqualsLibrary.equals(formats, c.getFormats());
} else if (c.getFormats() != null) {
return false;
}
if (nameSpaces != null) {
r = r && EqualsLibrary.equals(nameSpaces, c.getNameSpaces());
} else if (c.getNameSpaces() != null) {
return false;
}
if (featuresTypes != null) {
r = r && EqualsLibrary.equals(featuresTypes, c.getFeaturesTypes());
} else if (c.getFeaturesTypes() != null) {
return false;
}
if (coverages != null) {
r = r && EqualsLibrary.equals(coverages, c.getCoverages());
} else if (c.getCoverages() != null) {
return false;
}
if (styles != null) {
r = r && EqualsLibrary.equals(styles, c.getStyles());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -