Source Code Cross Referenced for Identifiable.java in  » GIS » deegree » org » deegree » crs » 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 » deegree » org.deegree.crs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$HeadURL: $
002:        /*----------------    FILE HEADER  ------------------------------------------
003:         This file is part of deegree.
004:         Copyright (C) 2001-2008 by:
005:         Department of Geography, University of Bonn
006:         http://www.giub.uni-bonn.de/deegree/
007:         lat/lon GmbH
008:         http://www.lat-lon.de
009:
010:         This library is free software; you can redistribute it and/or
011:         modify it under the terms of the GNU Lesser General Public
012:         License as published by the Free Software Foundation; either
013:         version 2.1 of the License, or (at your option) any later version.
014:         This library is distributed in the hope that it will be useful,
015:         but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017:         Lesser General Public License for more details.
018:         You should have received a copy of the GNU Lesser General Public
019:         License along with this library; if not, write to the Free Software
020:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021:         Contact:
022:
023:         Andreas Poth
024:         lat/lon GmbH
025:         Aennchenstr. 19
026:         53177 Bonn
027:         Germany
028:         E-Mail: poth@lat-lon.de
029:
030:         Prof. Dr. Klaus Greve
031:         Department of Geography
032:         University of Bonn
033:         Meckenheimer Allee 166
034:         53115 Bonn
035:         Germany
036:         E-Mail: greve@giub.uni-bonn.de
037:         ---------------------------------------------------------------------------*/
038:
039:        package org.deegree.crs;
040:
041:        import org.deegree.i18n.Messages;
042:
043:        /**
044:         * The <code>Identifiable</code> class can be used to identify a crs, ellipsoid, Datum and primemeridian
045:         * 
046:         * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
047:         * 
048:         * @author last edited by: $Author:$
049:         * 
050:         * @version $Revision:$, $Date:$
051:         * 
052:         */
053:
054:        public class Identifiable {
055:
056:            private String[] identifiers;
057:
058:            private String[] versions;
059:
060:            private String[] names;
061:
062:            private String[] descriptions;
063:
064:            private String[] areasOfUse;
065:
066:            /**
067:             * Takes the references of the other object and stores them in this Identifiable Object.
068:             * 
069:             * @param other
070:             *            identifiable object.
071:             */
072:            public Identifiable(Identifiable other) {
073:                this (other.getIdentifiers(), other.getNames(), other
074:                        .getVersions(), other.getDescriptions(), other
075:                        .getAreasOfUse());
076:            }
077:
078:            /**
079:             * 
080:             * @param identifiers
081:             * @param names
082:             *            the human readable names of the object.
083:             * @param versions
084:             * @param descriptions
085:             * @param areasOfUse
086:             * @throws IllegalArgumentException
087:             *             if no identifier(s) was/were given.
088:             */
089:            public Identifiable(String[] identifiers, String[] names,
090:                    String[] versions, String[] descriptions,
091:                    String[] areasOfUse) {
092:                if (identifiers == null || identifiers.length == 0) {
093:                    throw new IllegalArgumentException(
094:                            "An identifiable object must at least have one identifier.");
095:                }
096:                this .identifiers = identifiers;
097:
098:                this .names = names;
099:                this .versions = versions;
100:                this .descriptions = descriptions;
101:                this .areasOfUse = areasOfUse;
102:            }
103:
104:            /**
105:             * Creates arrays fromt the given identifier and name without setting the versions, descriptions and areasOfUse.
106:             * 
107:             * @param identifiers
108:             *            of the object.
109:             */
110:            public Identifiable(String[] identifiers) {
111:                this (identifiers, null, null, null, null);
112:            }
113:
114:            // /**
115:            // * Creates arrays fromt the given identifier and name without setting the versions, descriptions and areasOfUse.
116:            // *
117:            // * @param identifier of the object.
118:            // * @param name the human readable name of the object.
119:            // */
120:            // protected Identifiable( String identifier, String name ) {
121:            // this( new String[]{identifier}, new String[]{name}, null, null, null );
122:            // }
123:
124:            /**
125:             * @return the first of all areasOfUse or <code>null</code> if no areasOfUse were given.
126:             */
127:            public final String getAreaOfUse() {
128:                return (areasOfUse != null && areasOfUse.length > 0) ? areasOfUse[0]
129:                        : null;
130:            }
131:
132:            /**
133:             * @return the first of all descriptions or <code>null</code> if no descriptions were given.
134:             */
135:            public final String getDescription() {
136:                return (descriptions != null && descriptions.length > 0) ? descriptions[0]
137:                        : null;
138:            }
139:
140:            /**
141:             * @return the first of all identifiers.
142:             */
143:            public final String getIdentifier() {
144:                return identifiers[0];
145:            }
146:
147:            /**
148:             * @return the first of all names or <code>null</code> if no names were given.
149:             */
150:            public final String getName() {
151:                return (names != null && names.length > 0) ? names[0] : null;
152:            }
153:
154:            /**
155:             * @return the first of all versions or <code>null</code> if no versions were given.
156:             */
157:            public final String getVersion() {
158:                return (versions != null && versions.length > 0) ? versions[0]
159:                        : null;
160:            }
161:
162:            /**
163:             * throws an InvalidParameterException if the given object is null
164:             * 
165:             * @param toBeChecked
166:             *            for <code>null</code>
167:             * @param message
168:             *            to put into the exception. If absent, the default message (CRS_INVALID_NULL_PARAMETER) will be
169:             *            inserted.
170:             * @throws IllegalArgumentException
171:             *             if the given object is <code>null</code>.
172:             */
173:            protected void checkForNullObject(Object toBeChecked, String message)
174:                    throws IllegalArgumentException {
175:                if (toBeChecked == null) {
176:                    if (message == null || "".equals(message.trim())) {
177:                        message = Messages
178:                                .getMessage("CRS_INVALID_NULL_PARAMETER");
179:                    }
180:                    throw new IllegalArgumentException(message);
181:                }
182:
183:            }
184:
185:            /**
186:             * throws an InvalidParameterException if the given object is null
187:             * 
188:             * @param toBeChecked
189:             *            for <code>null</code>
190:             * @param functionName
191:             *            of the caller
192:             * @param paramName
193:             *            of the parameter to be checked.
194:             * @throws IllegalArgumentException
195:             *             if the given object is <code>null</code>.
196:             */
197:            protected void checkForNullObject(Object toBeChecked,
198:                    String functionName, String paramName)
199:                    throws IllegalArgumentException {
200:                if (toBeChecked == null) {
201:                    throw new IllegalArgumentException(Messages.getMessage(
202:                            "CRS_PARAMETER_NOT_NULL", functionName, paramName));
203:                }
204:            }
205:
206:            /**
207:             * throws an IllegalArgumentException if the given object array is null or empty
208:             * 
209:             * @param toBeChecked
210:             *            for <code>null</code> or empty
211:             * @param message
212:             *            to put into the exception. If absent, the default message (CRS_INVALID_NULL_PARAMETER) will be
213:             *            inserted.
214:             * @throws IllegalArgumentException
215:             *             if the given object array is <code>null</code> or empty.
216:             */
217:            protected void checkForNullObject(Object[] toBeChecked,
218:                    String message) throws IllegalArgumentException {
219:                if (toBeChecked != null && toBeChecked.length != 0) {
220:                    return;
221:                }
222:                if (message == null || "".equals(message.trim())) {
223:                    message = Messages.getMessage("CRS_INVALID_NULL_ARRAY");
224:                }
225:                throw new IllegalArgumentException(message);
226:            }
227:
228:            @Override
229:            public String toString() {
230:                StringBuilder sb = new StringBuilder("id: [");
231:                for (int i = 0; i < identifiers.length; ++i) {
232:                    sb.append(identifiers[i]);
233:                    if ((i + 1) < identifiers.length) {
234:                        sb.append(", ");
235:                    }
236:                }
237:                if (getName() != null) {
238:                    sb.append("], name: [");
239:                    for (int i = 0; i < names.length; ++i) {
240:                        sb.append(names[i]);
241:                        if ((i + 1) < names.length) {
242:                            sb.append(", ");
243:                        }
244:                    }
245:                }
246:                if (getVersion() != null) {
247:                    sb.append("], version: [");
248:                    for (int i = 0; i < versions.length; ++i) {
249:                        sb.append(versions[i]);
250:                        if ((i + 1) < versions.length) {
251:                            sb.append(", ");
252:                        }
253:                    }
254:                }
255:                if (getDescription() != null) {
256:                    sb.append("], description: [");
257:                    for (int i = 0; i < descriptions.length; ++i) {
258:                        sb.append(descriptions[i]);
259:                        if ((i + 1) < descriptions.length) {
260:                            sb.append(", ");
261:                        }
262:                    }
263:                }
264:                if (getAreaOfUse() != null) {
265:                    sb.append("], areasOfUse: [");
266:                    for (int i = 0; i < areasOfUse.length; ++i) {
267:                        sb.append(areasOfUse[i]);
268:                        if ((i + 1) < areasOfUse.length) {
269:                            sb.append(", ");
270:                        }
271:                    }
272:                }
273:                return sb.toString();
274:            }
275:
276:            /**
277:             * @return the first id and the name (if given) as id: id, name: name.
278:             */
279:            public String getIdAndName() {
280:                StringBuilder sb = new StringBuilder("id: ")
281:                        .append(getIdentifier());
282:                if (getName() != null) {
283:                    sb.append(", name: ").append(getName());
284:                }
285:                return sb.toString();
286:            }
287:
288:            @Override
289:            public boolean equals(Object other) {
290:                if (other != null && other instanceof  Identifiable) {
291:                    final Identifiable that = (Identifiable) other;
292:                    boolean isThisEPSG = false;
293:                    boolean isThatEPSG = false;
294:                    for (String id : getIdentifiers()) {
295:                        if (id.toLowerCase().contains("epsg")) {
296:                            isThisEPSG = true;
297:                            break;
298:                        }
299:                    }
300:                    for (String id : that.getIdentifiers()) {
301:                        if (id.toLowerCase().contains("epsg")) {
302:                            isThatEPSG = true;
303:                            break;
304:                        }
305:                    }
306:                    if (isThatEPSG && isThisEPSG) {
307:                        return idsMatch(that.identifiers);
308:                    }
309:                    return true;//idsMatch( that.identifiers );
310:                }
311:                return false;
312:            }
313:
314:            /**
315:             * Checks for the equality of id's between to different identifiable objects.
316:             * 
317:             * @param otherIDs
318:             *            of the other identifiable object.
319:             * @return true if the given strings match this.identifiers false otherwise.
320:             */
321:            private boolean idsMatch(String[] otherIDs) {
322:                if (otherIDs == null || identifiers.length != otherIDs.length) {
323:                    return false;
324:                }
325:                for (int i = 0; i < identifiers.length; ++i) {
326:                    String tmp = identifiers[i];
327:                    String other = otherIDs[i];
328:                    if (tmp != null) {
329:                        if (!tmp.equals(other)) {
330:                            return false;
331:                        }
332:                    } else if (other != null) {
333:                        return false;
334:                    }
335:                }
336:                return true;
337:
338:            }
339:
340:            /**
341:             * @return the areasOfUse or <code>null</code> if no areasOfUse were given.
342:             */
343:            public final String[] getAreasOfUse() {
344:                return areasOfUse;
345:            }
346:
347:            /**
348:             * @return the descriptions or <code>null</code> if no descriptions were given.
349:             */
350:            public final String[] getDescriptions() {
351:                return descriptions;
352:            }
353:
354:            /**
355:             * @return the identifiers, each identifiable object has atleast one id.
356:             */
357:            public final String[] getIdentifiers() {
358:                return identifiers;
359:            }
360:
361:            /**
362:             * @return the names or <code>null</code> if no names were given.
363:             */
364:            public final String[] getNames() {
365:                return names;
366:            }
367:
368:            /**
369:             * @return the versions or <code>null</code> if no versions were given.
370:             */
371:            public final String[] getVersions() {
372:                return versions;
373:            }
374:
375:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.