001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.data.ows;
017:
018: import java.net.URI;
019: import java.util.LinkedList;
020: import java.util.List;
021:
022: import com.vividsolutions.jts.geom.Envelope;
023:
024: /**
025: * <p>
026: * Represents a wfs:FeatureType ... and didn't want to use FeatureType as it
027: * could get confused with org.geotools.data.FeatureType
028: * </p>
029: *
030: * @author dzwiers
031: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/wfs/src/main/java/org/geotools/data/ows/FeatureSetDescription.java $
032: */
033: public class FeatureSetDescription {
034: /**
035: * Mask for no operation allowed on the FeatureType
036: */
037: public static final int NO_OPERATION = 0;
038: /**
039: * Mask for query operation allowed on the FeatureType
040: */
041: public static final int QUERY_OPERATION = 1;
042: /**
043: * Mask for insert operation allowed on the FeatureType
044: */
045: public static final int INSERT_OPERATION = 2;
046: /**
047: * Mask for update operation allowed on the FeatureType
048: */
049: public static final int UPDATE_OPERATION = 4;
050: /**
051: * Mask for delete operation allowed on the FeatureType
052: */
053: public static final int DELETE_OPERATION = 8;
054: /**
055: * Mask for lock operation allowed on the FeatureType
056: */
057: public static final int LOCK_OPERATION = 16;
058:
059: private String name;
060: private URI namespace;
061: private String title;
062: private String _abstract;
063: private String SRS;
064: private List keywords;
065: private Envelope latLongBoundingBox;
066: private int operations;
067:
068: /**
069: * Converts the string into the appropriate mask.
070: *
071: * @param s The String to attempt to convert
072: * @return one of the Constant Operation Values
073: * @see FeatureSetDescription#DELETE_OPERATION
074: * @see FeatureSetDescription#UPDATE_OPERATION
075: * @see FeatureSetDescription#LOCK_OPERATION
076: * @see FeatureSetDescription#NO_OPERATION
077: * @see FeatureSetDescription#QUERY_OPERATION
078: * @see FeatureSetDescription#INSERT_OPERATION
079: */
080: public static int findOperation(String s) {
081: if ("Query".equals(s)) {
082: return 1;
083: }
084:
085: if ("Insert".equals(s)) {
086: return 2;
087: }
088:
089: if ("Update".equals(s)) {
090: return 4;
091: }
092:
093: if ("Delete".equals(s)) {
094: return 8;
095: }
096:
097: if ("Lock".equals(s)) {
098: return 16;
099: }
100:
101: return 0;
102: }
103:
104: /**
105: * Converts the int into the appropriate String.
106: *
107: * @param i the int to convert, must match exactly.
108: * @return A string representation of the int.
109: * @see FeatureSetDescription#DELETE_OPERATION
110: * @see FeatureSetDescription#UPDATE_OPERATION
111: * @see FeatureSetDescription#LOCK_OPERATION
112: * @see FeatureSetDescription#NO_OPERATION
113: * @see FeatureSetDescription#QUERY_OPERATION
114: * @see FeatureSetDescription#INSERT_OPERATION
115: */
116: public static String writeOperation(int i) {
117: switch (i) {
118: case 1:
119: return "Query";
120:
121: case 2:
122: return "Insert";
123:
124: case 4:
125: return "Update";
126:
127: case 8:
128: return "Delete";
129:
130: case 16:
131: return "Lock";
132: }
133:
134: return "";
135: }
136:
137: /**
138: * Converts the int mask into the appropriate set of Strings.
139: *
140: * @param i The int mask to attempt to convert
141: * @return Set of Strings representing the mask
142: * @see FeatureSetDescription#DELETE_OPERATION
143: * @see FeatureSetDescription#UPDATE_OPERATION
144: * @see FeatureSetDescription#LOCK_OPERATION
145: * @see FeatureSetDescription#NO_OPERATION
146: * @see FeatureSetDescription#QUERY_OPERATION
147: * @see FeatureSetDescription#INSERT_OPERATION
148: */
149: public static String[] writeOperations(int i) {
150: List l = new LinkedList();
151:
152: if ((i & 1) == 1) {
153: l.add("Query");
154: }
155:
156: if ((i & 2) == 2) {
157: l.add("Insert");
158: }
159:
160: if ((i & 4) == 4) {
161: l.add("Update");
162: }
163:
164: if ((i & 8) == 8) {
165: l.add("Delete");
166: }
167:
168: if ((i & 16) == 16) {
169: l.add("Lock");
170: }
171:
172: return (String[]) l.toArray(new String[l.size()]);
173: }
174:
175: /**
176: * DOCUMENT ME!
177: *
178: * @return Returns the abstracT.
179: */
180: public String getAbstract() {
181: return _abstract;
182: }
183:
184: /**
185: * DOCUMENT ME!
186: *
187: * @param _abstract The abstracT to set.
188: */
189: public void setAbstract(String _abstract) {
190: this ._abstract = _abstract;
191: }
192:
193: /**
194: * DOCUMENT ME!
195: *
196: * @return Returns the keywords.
197: */
198: public List getKeywords() {
199: return keywords;
200: }
201:
202: /**
203: * DOCUMENT ME!
204: *
205: * @param keywords The keywords to set.
206: */
207: public void setKeywords(List keywords) {
208: this .keywords = keywords;
209: }
210:
211: /**
212: * DOCUMENT ME!
213: *
214: * @return Returns the latLongBoundingBox.
215: */
216: public Envelope getLatLongBoundingBox() {
217: return latLongBoundingBox;
218: }
219:
220: /**
221: * DOCUMENT ME!
222: *
223: * @param latLongBoundingBox The latLongBoundingBox to set.
224: */
225: public void setLatLongBoundingBox(Envelope latLongBoundingBox) {
226: this .latLongBoundingBox = latLongBoundingBox;
227: }
228:
229: /**
230: * DOCUMENT ME!
231: *
232: * @return Returns the name.
233: */
234: public String getName() {
235: return name;
236: }
237:
238: /**
239: * DOCUMENT ME!
240: *
241: * @param name The name to set.
242: */
243: public void setName(String name) {
244: this .name = name;
245: }
246:
247: /**
248: * DOCUMENT ME!
249: *
250: * @return Returns the operations.
251: */
252: public int getOperations() {
253: return operations;
254: }
255:
256: /**
257: * DOCUMENT ME!
258: *
259: * @param operations The operations to set.
260: */
261: public void setOperations(int operations) {
262: this .operations = operations;
263: }
264:
265: /**
266: * DOCUMENT ME!
267: *
268: * @return Returns the sRS.
269: */
270: public String getSRS() {
271: return SRS;
272: }
273:
274: /**
275: * DOCUMENT ME!
276: *
277: * @param srs The sRS to set.
278: */
279: public void setSRS(String srs) {
280: SRS = srs;
281: }
282:
283: /**
284: * DOCUMENT ME!
285: *
286: * @return Returns the title.
287: */
288: public String getTitle() {
289: return title;
290: }
291:
292: /**
293: * DOCUMENT ME!
294: *
295: * @param title The title to set.
296: */
297: public void setTitle(String title) {
298: this .title = title;
299: }
300:
301: /**
302: * @return Returns the namespace.
303: */
304: public URI getNamespace() {
305: return namespace;
306: }
307:
308: /**
309: * @param namespace The namespace to set.
310: */
311: public void setNamespace(URI namespace) {
312: this.namespace = namespace;
313: }
314: }
|