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.config;
006:
007: import org.vfny.geoserver.global.dto.NameSpaceInfoDTO;
008:
009: /**
010: * NameSpaceConfig purpose.
011: *
012: * <p>
013: * Represents the portion of a namespace required for the configuration of
014: * geoserver. Defines namespaces to be used by the datastores.
015: * </p>
016: *
017: * <p></p>
018: *
019: * @author dzwiers, Refractions Research, Inc.
020: * @version $Id: NameSpaceConfig.java 6326 2007-03-15 18:36:40Z jdeolive $
021: */
022: public class NameSpaceConfig {
023: //public static final String PREFIX_DELIMITER = ":";
024:
025: /** The namespace prefix. */
026: private String prefix;
027:
028: /** The URI for this namespace. */
029: private String uri;
030:
031: /** Whether this is the default namespace. */
032: private boolean _default;
033:
034: /**
035: * NameSpaceConfig constructor.
036: *
037: * <p>
038: * Creates a NameSpaceConfig to represent an instance with default data.
039: * </p>
040: *
041: * @see defaultSettings()
042: */
043: public NameSpaceConfig() {
044: prefix = "";
045: uri = "";
046: _default = false;
047: }
048:
049: /**
050: * NameSpaceConfig constructor.
051: *
052: * <p>
053: * Creates a copy of the NameSpaceConfig provided. If the NameSpaceConfig
054: * provided is null then default values are used. All the data structures
055: * are cloned.
056: * </p>
057: *
058: * @param ns The namespace to copy.
059: *
060: * @throws NullPointerException DOCUMENT ME!
061: */
062: public NameSpaceConfig(NameSpaceInfoDTO ns) {
063: if (ns == null) {
064: throw new NullPointerException("");
065: }
066:
067: prefix = ns.getPrefix();
068: uri = ns.getUri();
069: _default = ns.isDefault();
070: }
071:
072: /**
073: * Implement loadDTO.
074: *
075: * <p>
076: * Imports the data contained in the NameSpaceInfoDTO object provided.
077: * </p>
078: *
079: * @param dto An NameSpaceInfoDTO object
080: *
081: * @throws NullPointerException DOCUMENT ME!
082: *
083: * @see org.vfny.geoserver.config.DataStructure#loadDTO(java.lang.Object)
084: */
085: public void update(NameSpaceInfoDTO dto) {
086: if (dto == null) {
087: throw new NullPointerException(
088: "NameSpace Data Transfer Object required");
089: }
090:
091: NameSpaceInfoDTO ns = (NameSpaceInfoDTO) dto;
092: prefix = ns.getPrefix();
093: uri = ns.getUri();
094: _default = ns.isDefault();
095: }
096:
097: /**
098: * Implement toDTO.
099: *
100: * <p>
101: * Creates a DTO representation of this Object as a NameSpaceInfoDTO
102: * </p>
103: *
104: * @return a NameSpaceInfoDTO which representts the data in this class.
105: *
106: * @see org.vfny.geoserver.config.DataStructure#toDTO()
107: */
108: public NameSpaceInfoDTO toDTO() {
109: NameSpaceInfoDTO nsDto = new NameSpaceInfoDTO();
110: nsDto.setDefault(_default);
111: nsDto.setPrefix(prefix);
112: nsDto.setUri(uri);
113:
114: return nsDto;
115: }
116:
117: /**
118: * isDefault purpose.
119: *
120: * <p>
121: * Description ...
122: * </p>
123: *
124: * @return
125: */
126: public boolean isDefault() {
127: return _default;
128: }
129:
130: /**
131: * getPrefix purpose.
132: *
133: * <p>
134: * Description ...
135: * </p>
136: *
137: * @return
138: */
139: public String getPrefix() {
140: return prefix;
141: }
142:
143: /**
144: * getUri purpose.
145: *
146: * <p>
147: * Description ...
148: * </p>
149: *
150: * @return
151: */
152: public String getUri() {
153: return uri;
154: }
155:
156: /**
157: * setDdefault purpose.
158: *
159: * <p>
160: * Description ...
161: * </p>
162: *
163: * @param b
164: */
165: public void setDefault(boolean b) {
166: _default = b;
167: }
168:
169: /**
170: * setPrefix purpose.
171: *
172: * <p>
173: * Description ...
174: * </p>
175: *
176: * @param string
177: */
178: public void setPrefix(String string) {
179: prefix = string;
180: }
181:
182: /**
183: * setUri purpose.
184: *
185: * <p>
186: * Description ...
187: * </p>
188: *
189: * @param string
190: */
191: public void setUri(String string) {
192: uri = string;
193: }
194: }
|