001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.vfny.geoserver.global.dto;
006:
007: /**
008: * Data Transfer Object for GeoServer NameSpaceInfo information.
009: *
010: * <p>
011: * Represents the portion of a namespace required for the configuration of
012: * geoserver. Defines namespaces to be used by the datastores.
013: * </p>
014: *
015: * <p>
016: * Data Transfer object are used to communicate between the GeoServer
017: * application and its configuration and persistent layers. As such the class
018: * is final - to allow for its future use as an on-the-wire message.
019: * </p>
020: *
021: * <p>
022: * Jody here - does this actual defin the namespace used by the GML?
023: * </p>
024: *
025: * <p>
026: * NameSpaceInfoDTO nsDto = new NameSpaceInfoDTO(); nsDto.setDefault(false);
027: * nsDto.setPrefix("me"); nsDto.setUri("dzwiers.refraction.net");
028: * </p>
029: *
030: * @author dzwiers, Refractions Research, Inc.
031: * @version $Id: NameSpaceInfoDTO.java 6326 2007-03-15 18:36:40Z jdeolive $
032: */
033: public final class NameSpaceInfoDTO implements DataTransferObject {
034: //public static final String PREFIX_DELIMITER = ":";
035:
036: /** The namespace prefix. */
037: private String prefix;
038:
039: /** The URI for this namespace. */
040: private String uri;
041:
042: /** Whether this is the default namespace. */
043: private boolean _default = false;
044:
045: /**
046: * NameSpaceConfig constructor.
047: *
048: * <p>
049: * does nothing
050: * </p>
051: */
052: public NameSpaceInfoDTO() {
053: }
054:
055: /**
056: * NameSpaceConfig constructor.
057: *
058: * <p>
059: * Creates a copy of the NameSpaceConfig provided. If the NameSpaceConfig
060: * provided is null then default values are used. All the data structures
061: * are cloned.
062: * </p>
063: *
064: * @param ns The namespace to copy.
065: *
066: * @throws NullPointerException DOCUMENT ME!
067: */
068: public NameSpaceInfoDTO(NameSpaceInfoDTO ns) {
069: if (ns == null) {
070: throw new NullPointerException();
071: }
072:
073: prefix = ns.getPrefix();
074: uri = ns.getUri();
075: _default = ns.isDefault();
076: }
077:
078: /**
079: * Implement clone.
080: *
081: * <p>
082: * creates a clone of this object
083: * </p>
084: *
085: * @return A copy of this NameSpaceConfig
086: *
087: * @see java.lang.Object#clone()
088: */
089: public Object clone() {
090: return new NameSpaceInfoDTO(this );
091: }
092:
093: /**
094: * Implement equals.
095: *
096: * <p>
097: * recursively tests to determine if the object passed in is a copy of this
098: * object.
099: * </p>
100: *
101: * @param obj The NameSpaceConfig object to test.
102: *
103: * @return true when the object passed is the same as this object.
104: *
105: * @see java.lang.Object#equals(java.lang.Object)
106: */
107: public boolean equals(Object obj) {
108: if ((obj == null) || !(obj instanceof NameSpaceInfoDTO)) {
109: return false;
110: }
111:
112: NameSpaceInfoDTO ns = (NameSpaceInfoDTO) obj;
113:
114: return ((prefix == ns.getPrefix()) && ((uri == ns.getUri()) && (_default == ns
115: .isDefault())));
116: }
117:
118: /**
119: * Implement hashCode.
120: *
121: * @return Service hashcode or 0
122: *
123: * @see java.lang.Object#hashCode()
124: */
125: public int hashCode() {
126: int r = 1;
127:
128: if (prefix != null) {
129: r *= prefix.hashCode();
130: }
131:
132: if (uri != null) {
133: r *= uri.hashCode();
134: }
135:
136: return r;
137: }
138:
139: /**
140: * isDefault purpose.
141: *
142: * <p>
143: * Description ...
144: * </p>
145: *
146: * @return
147: */
148: public boolean isDefault() {
149: return _default;
150: }
151:
152: /**
153: * getPrefix purpose.
154: *
155: * <p>
156: * Description ...
157: * </p>
158: *
159: * @return
160: */
161: public String getPrefix() {
162: return prefix;
163: }
164:
165: /**
166: * getUri purpose.
167: *
168: * <p>
169: * Description ...
170: * </p>
171: *
172: * @return
173: */
174: public String getUri() {
175: return uri;
176: }
177:
178: /**
179: * setDdefault purpose.
180: *
181: * <p>
182: * Description ...
183: * </p>
184: *
185: * @param b
186: */
187: public void setDefault(boolean b) {
188: _default = b;
189: }
190:
191: /**
192: * setPrefix purpose.
193: *
194: * <p>
195: * Description ...
196: * </p>
197: *
198: * @param string
199: */
200: public void setPrefix(String string) {
201: prefix = string;
202: }
203:
204: /**
205: * setUri purpose.
206: *
207: * <p>
208: * Description ...
209: * </p>
210: *
211: * @param string
212: */
213: public void setUri(String string) {
214: uri = string;
215: }
216:
217: public String toString() {
218: return "xmlns:" + getPrefix() + "=\"" + getUri()
219: + "\", isDefault=" + _default;
220: }
221: }
|