Source Code Cross Referenced for DataDTO.java in  » GIS » GeoServer » org » vfny » geoserver » global » dto » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoServer » org.vfny.geoserver.global.dto 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:
006:        /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org.  All rights reserved.
007:         * This code is licensed under the GPL 2.0 license, availible at the root
008:         * application directory.
009:         */
010:        package org.vfny.geoserver.global.dto;
011:
012:        import java.util.HashMap;
013:        import java.util.Map;
014:        import java.util.NoSuchElementException;
015:
016:        /**
017:         * Data Transfer Object used to represent GeoServer Catalog information.
018:         *
019:         * <p>
020:         * Represents an instance of the catalog.xml file in the configuration of the
021:         * server, along with associated configuration files for the feature types.
022:         * </p>
023:         *
024:         * <p>
025:         * Data Transfer object are used to communicate between the GeoServer
026:         * application and its configuration and persistent layers. As such the class
027:         * is final - to allow for its future use as an on-the-wire message.
028:         * </p>
029:         *
030:         * <p>
031:         * Example:
032:         * </p>
033:         * <pre><code>
034:         * DataDTO dDto = new DataDTO();
035:         * Map m = new HashMap();
036:         * NameSpaceInfoDTO ns = new NameSpaceInfoDTO();
037:         * ns.setUri("dzwiers.refractions.net");
038:         * m.put("nsDave",ns);
039:         * dDto.setNameSpaces(m);
040:         * ns = new NameSpaceInfoDTO();
041:         * ns.setUri("jgarnett.refractions.net");
042:         * ns.setDefault(true);
043:         * dDto.addNameSpace("nsJody"ns);
044:         * dDto.setDefaultNameSpace(ns);
045:         * ...
046:         * </code></pre>
047:         *
048:         * @author dzwiers, Refractions Research, Inc.
049:         * @author $Author: Alessio Fabiani (alessio.fabiani@gmail.com) $ (last modification)
050:         * @author $Author: Simone Giannecchini (simboss1@gmail.com) $ (last modification)
051:         * @version $Id: DataDTO.java 6326 2007-03-15 18:36:40Z jdeolive $
052:         *
053:         * @see DataSource
054:         * @see FeatureTypeInfo
055:         * @see StyleConfig
056:         */
057:        public final class DataDTO implements  DataTransferObject {
058:            /**
059:             * DataStoreInfoDTO referenced by key "<code>dataStoreID</code>".
060:             *
061:             * @see org.vfny.geoserver.global.dto.DataStoreInfoDTO
062:             *
063:             * @uml.property name="dataStores"
064:             * @uml.associationEnd elementType="java.lang.String" qualifier="key:java.lang.String
065:             * org.vfny.geoserver.global.dto.DataStoreInfoDTO" multiplicity="(0 -1)" ordering=
066:             * "ordered"
067:             */
068:            private Map dataStores;
069:
070:            /**
071:             * CoverageStoreInfoDTO referenced by key "<code>formatID</code>".
072:             *
073:             * @see org.vfny.geoserver.global.dto.CoverageStoreInfoDTO
074:             *
075:             * @uml.property name="formats"
076:             * @uml.associationEnd elementType="java.lang.String" qualifier="getFormatId:java.lang.String
077:             * org.vfny.geoserver.global.dto.CoverageStoreInfoDTO" multiplicity="(0 -1)" ordering="ordered"
078:             */
079:            private Map formats;
080:
081:            /**
082:             * NamespaceDTO referenced by key "<code>prefix</code>".
083:             *
084:             * @see org.vfny.geoserver.global.dto.NameSpaceInfoDTO
085:             *
086:             * @uml.property name="nameSpaces"
087:             * @uml.associationEnd elementType="java.lang.String" qualifier="key:java.lang.String
088:             * org.vfny.geoserver.global.dto.NameSpaceInfoDTO" multiplicity="(0 -1)" ordering=
089:             * "ordered"
090:             */
091:            private Map nameSpaces;
092:
093:            /**
094:             * FeatureTypesInfoDTO referenced by key
095:             * "<code>dataStoreID.typeName</code>"
096:             *
097:             * @see org.vfny.geoserver.global.dto.FeatureTypeInfoDTO
098:             *
099:             * @uml.property name="featuresTypes"
100:             * @uml.associationEnd elementType="org.vfny.geoserver.global.dto.AttributeTypeInfoDTO"
101:             * qualifier="key:java.lang.String org.vfny.geoserver.global.dto.FeatureTypeInfoDTO"
102:             * multiplicity="(0 -1)" ordering="ordered"
103:             */
104:            private Map featuresTypes;
105:
106:            /**
107:             *
108:             * @uml.property name="coverages"
109:             * @uml.associationEnd qualifier="key:java.lang.String org.vfny.geoserver.global.dto.DataTransferObject"
110:             * multiplicity="(0 1)"
111:             */
112:            private Map coverages;
113:
114:            /**
115:             * StyleDTO referenced by key "<code>id</code>"
116:             *
117:             * @see org.vfny.geoserver.global.dto.StyleDTO
118:             *
119:             * @uml.property name="styles"
120:             * @uml.associationEnd qualifier="key:java.lang.String org.vfny.geoserver.global.dto.DataTransferObject"
121:             * multiplicity="(0 1)"
122:             */
123:            private Map styles;
124:
125:            /**
126:             * The default namespace for the server instance.
127:             *
128:             * <p>
129:             * This may be <code>null</code> if a default has not been defined. the
130:             * config files is supposed to use the "first" Namespace when a default is
131:             * not defined - but we have lost all sense of order by placing this in a
132:             * Map. For 99% of the time when no default has been provided it is
133:             * because there is only one Namespace for the application.
134:             * </p>
135:             *
136:             * @see org.vfny.geoserver.global.dto.NameSpaceInfo
137:             *
138:             * @uml.property name="defaultNameSpacePrefix" multiplicity="(0 1)"
139:             */
140:            private String defaultNameSpacePrefix;
141:
142:            /**
143:             * Data constructor.
144:             *
145:             * <p>
146:             * does nothing
147:             * </p>
148:             */
149:            public DataDTO() {
150:            }
151:
152:            /**
153:             * Creates a duplicate of the provided DataDTO using deep copy.
154:             *
155:             * <p>
156:             * Creates a copy of the Data provided. If the Data provided  is null then
157:             * default values are used. All the datastructures are cloned.
158:             * </p>
159:             *
160:             * @param dto The catalog to copy.
161:             *
162:             * @throws NullPointerException DOCUMENT ME!
163:             */
164:            public DataDTO(DataDTO dto) {
165:                if (dto == null) {
166:                    throw new NullPointerException("Non null DataDTO required");
167:                }
168:
169:                try {
170:                    dataStores = CloneLibrary.clone(dto.getDataStores());
171:                } catch (Exception e) {
172:                    dataStores = new HashMap();
173:                }
174:
175:                try {
176:                    formats = CloneLibrary.clone(dto.getFormats());
177:                } catch (Exception e) {
178:                    formats = new HashMap();
179:                }
180:
181:                try {
182:                    nameSpaces = CloneLibrary.clone(dto.getNameSpaces());
183:                } catch (Exception e) {
184:                    nameSpaces = new HashMap();
185:                }
186:
187:                try {
188:                    featuresTypes = CloneLibrary.clone(dto.getFeaturesTypes());
189:                } catch (Exception e) {
190:                    featuresTypes = new HashMap();
191:                }
192:
193:                try {
194:                    coverages = CloneLibrary.clone(dto.getCoverages());
195:                } catch (Exception e) {
196:                    coverages = new HashMap();
197:                }
198:
199:                try {
200:                    styles = CloneLibrary.clone(dto.getStyles());
201:                } catch (Exception e) {
202:                    styles = new HashMap();
203:                }
204:
205:                defaultNameSpacePrefix = dto.getDefaultNameSpacePrefix();
206:            }
207:
208:            /**
209:             * Implement clone as a Deep copy.
210:             *
211:             * @return A copy of this Data
212:             *
213:             * @see java.lang.Object#clone()
214:             */
215:            public Object clone() {
216:                return new DataDTO(this );
217:            }
218:
219:            /**
220:             * Implement equals as part of the Object contract.
221:             *
222:             * <p>
223:             * Recursively tests to determine if the object passed in is a copy of this
224:             * object.
225:             * </p>
226:             *
227:             * @param other The Data object to test.
228:             *
229:             * @return true when the object passed is the same as this object.
230:             *
231:             * @see java.lang.Object#equals(java.lang.Object)
232:             */
233:            public boolean equals(Object other) {
234:                if ((other == null) || !(other instanceof  DataDTO)) {
235:                    return false;
236:                }
237:
238:                DataDTO c = (DataDTO) other;
239:                boolean r = true;
240:
241:                if (dataStores != null) {
242:                    r = r
243:                            && EqualsLibrary.equals(dataStores, c
244:                                    .getDataStores());
245:                } else if (c.getDataStores() != null) {
246:                    return false;
247:                }
248:
249:                if (formats != null) {
250:                    r = r && EqualsLibrary.equals(formats, c.getFormats());
251:                } else if (c.getFormats() != null) {
252:                    return false;
253:                }
254:
255:                if (nameSpaces != null) {
256:                    r = r
257:                            && EqualsLibrary.equals(nameSpaces, c
258:                                    .getNameSpaces());
259:                } else if (c.getNameSpaces() != null) {
260:                    return false;
261:                }
262:
263:                if (featuresTypes != null) {
264:                    r = r
265:                            && EqualsLibrary.equals(featuresTypes, c
266:                                    .getFeaturesTypes());
267:                } else if (c.getFeaturesTypes() != null) {
268:                    return false;
269:                }
270:
271:                if (coverages != null) {
272:                    r = r && EqualsLibrary.equals(coverages, c.getCoverages());
273:                } else if (c.getCoverages() != null) {
274:                    return false;
275:                }
276:
277:                if (styles != null) {
278:                    r = r && EqualsLibrary.equals(styles, c.getStyles());
279:                } else if (c.getStyles() != null) {
280:                    return false;
281:                }
282:
283:                if (defaultNameSpacePrefix != null) {
284:                    r = r
285:                            && defaultNameSpacePrefix.equals(c
286:                                    .getDefaultNameSpacePrefix());
287:                } else if (c.getDefaultNameSpacePrefix() != null) {
288:                    return false;
289:                }
290:
291:                return r;
292:            }
293:
294:            /**
295:             * Implement hashCode as part of the Object contract.
296:             *
297:             * @return Service hashcode or 0
298:             *
299:             * @see java.lang.Object#hashCode()
300:             */
301:            public int hashCode() {
302:                int r = 1;
303:
304:                if (dataStores != null) {
305:                    r *= dataStores.hashCode();
306:                }
307:
308:                if (formats != null) {
309:                    r *= formats.hashCode();
310:                }
311:
312:                if (nameSpaces != null) {
313:                    r *= nameSpaces.hashCode();
314:                }
315:
316:                if (featuresTypes != null) {
317:                    r *= featuresTypes.hashCode();
318:                }
319:
320:                if (styles != null) {
321:                    r *= styles.hashCode();
322:                }
323:
324:                if (coverages != null) {
325:                    r *= coverages.hashCode();
326:                }
327:
328:                return r;
329:            }
330:
331:            /**
332:             * Retrive a Map of DataStoreInfoDTO by "dataStoreID".
333:             *
334:             * @return Map of DataStoreInfoDTO by "dataStoreID"
335:             *
336:             * @uml.property name="dataStores"
337:             */
338:            public Map getDataStores() {
339:                return dataStores;
340:            }
341:
342:            /**
343:             * Retrive a Map of CoverageStoreInfoDTO by "formatID".
344:             *
345:             * @return Map of CoverageStoreInfoDTO by "formatID"
346:             *
347:             * @uml.property name="formats"
348:             */
349:            public Map getFormats() {
350:                return formats;
351:            }
352:
353:            /**
354:             * Return the getDefaultNameSpace.
355:             *
356:             * <p>
357:             * May consider just returning the "prefix" of the default Namespace here.
358:             * It is unclear what happens when we are starting out with a Empty
359:             * DataDTO class.
360:             * </p>
361:             *
362:             * @return Default namespace or <code>null</code>
363:             *
364:             * @uml.property name="defaultNameSpacePrefix"
365:             */
366:            public String getDefaultNameSpacePrefix() {
367:                return defaultNameSpacePrefix;
368:            }
369:
370:            /**
371:             * Retrive Map of FeatureTypeInfoDTO by "dataStoreID.typeName".
372:             *
373:             * @return Map of FeatureTypeInfoDTO by "dataStoreID.typeName"
374:             *
375:             * @uml.property name="featuresTypes"
376:             */
377:            public Map getFeaturesTypes() {
378:                return featuresTypes;
379:            }
380:
381:            /**
382:             * Map of NamespaceDTO by "prefix".
383:             *
384:             * @return Map of NamespaceDTO by "prefix".
385:             *
386:             * @uml.property name="nameSpaces"
387:             */
388:            public Map getNameSpaces() {
389:                return nameSpaces;
390:            }
391:
392:            /**
393:             * Retrive Map of StyleDTO by "something?".  Key is Style.id
394:             *
395:             * @return Map of StyleDTO by "something"?
396:             *
397:             * @uml.property name="styles"
398:             */
399:            public Map getStyles() {
400:                return styles;
401:            }
402:
403:            /**
404:             * Replace DataStoreInfoDTO map.
405:             *
406:             * @param map Map of DataStoreInfoDTO by "dataStoreID"
407:             *
408:             * @throws NullPointerException DOCUMENT ME!
409:             *
410:             * @uml.property name="dataStores"
411:             */
412:            public void setDataStores(Map map) {
413:                if (map == null) {
414:                    throw new NullPointerException(
415:                            "DataStores map must not be null. Use Collections.EMPTY_MAP if you must");
416:                }
417:
418:                dataStores = new HashMap(map);
419:
420:                if (map != null) {
421:                    dataStores = map;
422:                }
423:            }
424:
425:            /**
426:             * Replace CoverageStoreInfoDTO map.
427:             *
428:             * @param map Map of CoverageStoreInfoDTO by "formatID"
429:             *
430:             * @throws NullPointerException DOCUMENT ME!
431:             *
432:             * @uml.property name="formats"
433:             */
434:            public void setFormats(Map map) {
435:                if (map == null) {
436:                    throw new NullPointerException(
437:                            "Formats map must not be null. Use Collections.EMPTY_MAP if you must");
438:                }
439:
440:                formats = new HashMap(map);
441:
442:                if (map != null) {
443:                    formats = map;
444:                }
445:            }
446:
447:            /**
448:             * Sets the default namespace.
449:             *
450:             * <p>
451:             * Note the provided namespace must be present in the namespace map.
452:             * </p>
453:             *
454:             * @param dnsp the default namespace prefix.
455:             *
456:             * @throws NoSuchElementException DOCUMENT ME!
457:             *
458:             * @uml.property name="defaultNameSpacePrefix"
459:             */
460:            public void setDefaultNameSpacePrefix(String dnsp) {
461:                defaultNameSpacePrefix = dnsp;
462:
463:                if (!nameSpaces.containsKey(dnsp)) {
464:                    throw new NoSuchElementException(
465:                            "Invalid NameSpace Prefix for Default");
466:                }
467:            }
468:
469:            /**
470:             * Set the FeatureTypeInfoDTO map.
471:             *
472:             * <p>
473:             * The dataStoreID used for the map must be in datastores.
474:             * </p>
475:             *
476:             * @param map of FeatureTypeInfoDTO by "dataStoreID.typeName"
477:             *
478:             * @throws NullPointerException DOCUMENT ME!
479:             *
480:             * @uml.property name="featuresTypes"
481:             */
482:            public void setFeaturesTypes(Map map) {
483:                if (map == null) {
484:                    throw new NullPointerException(
485:                            "FeatureTypeInfoDTO map must not be null. Use Collections.EMPTY_MAP if you must");
486:                }
487:
488:                featuresTypes = map;
489:            }
490:
491:            /**
492:             * Sets the NameSpaceInfoDTO map.
493:             *
494:             * <p>
495:             * The default prefix is not changed by this operation.
496:             * </p>
497:             *
498:             * @param map of NameSpaceInfoDTO by "prefix"
499:             *
500:             * @throws NullPointerException DOCUMENT ME!
501:             *
502:             * @uml.property name="nameSpaces"
503:             */
504:            public void setNameSpaces(Map map) {
505:                if (map == null) {
506:                    throw new NullPointerException(
507:                            "NameSpaceDTO map must not be null. Use Collections.EMPTY_MAP if you must");
508:                }
509:
510:                nameSpaces = map;
511:            }
512:
513:            /**
514:             * Set map of StyleDTO by "something?".
515:             *
516:             * @param map Map of StyleDTO by "someKey"?
517:             *
518:             * @throws NullPointerException DOCUMENT ME!
519:             *
520:             * @uml.property name="styles"
521:             */
522:            public void setStyles(Map map) {
523:                if (map == null) {
524:                    throw new NullPointerException(
525:                            "StyleInfoDTO map must not be null. Use Collections.EMPTY_MAP if you must");
526:                }
527:
528:                styles = map;
529:            }
530:
531:            /**
532:             * @return Returns the coverages.
533:             *
534:             * @uml.property name="coverages"
535:             */
536:            public Map getCoverages() {
537:                return coverages;
538:            }
539:
540:            /**
541:             * @param coverages The coverages to set.
542:             *
543:             * @uml.property name="coverages"
544:             */
545:            public void setCoverages(Map coverages) {
546:                if (coverages == null) {
547:                    throw new NullPointerException(
548:                            "CoverageInfoDTO map must not be null. Use Collections.EMPTY_MAP if you must");
549:                }
550:
551:                this.coverages = coverages;
552:            }
553:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.