Source Code Cross Referenced for CheckedHashSet.java in  » GIS » GeoTools-2.4.1 » org » geotools » util » 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 » GeoTools 2.4.1 » org.geotools.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2002-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.util;
017:
018:        // J2SE dependencies
019:        import java.util.LinkedHashSet;
020:
021:        // OpenGIS dependencies
022:        import org.opengis.util.Cloneable;
023:
024:        // Geotools dependencies
025:        import org.geotools.resources.Utilities;
026:        import org.geotools.resources.i18n.Errors;
027:        import org.geotools.resources.i18n.ErrorKeys;
028:
029:        /**
030:         * Acts as a typed {@link java.util.Set} while we wait for Java 5.0.
031:         * 
032:         * @since 2.1
033:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/util/CheckedHashSet.java $
034:         * @version $Id: CheckedHashSet.java 25193 2007-04-18 13:37:38Z desruisseaux $
035:         * @author Jody Garnett (Refractions Research)
036:         * @author Martin Desruisseaux
037:         *
038:         * @todo Provides synchronization facility on arbitrary lock, for use with the metadata package.
039:         *       The lock would be the metadata that owns this collection. Be carefull to update the lock
040:         *       after a clone (this work may be done in {@code MetadataEntity.unmodifiable(Object)}).
041:         */
042:        public class CheckedHashSet extends LinkedHashSet implements 
043:                CheckedCollection, Cloneable {
044:            /**
045:             * Serial version UID for compatibility with different versions.
046:             */
047:            private static final long serialVersionUID = -9014541457174735097L;
048:
049:            /**
050:             * The element type.
051:             */
052:            private final Class type;
053:
054:            /**
055:             * Constructs a set of the specified type.
056:             *
057:             * @param type The element type (should not be null).
058:             */
059:            public CheckedHashSet(final Class type) {
060:                super ();
061:                this .type = type;
062:                ensureNonNull();
063:            }
064:
065:            /**
066:             * Constructs a set of the specified type and initial capacity.
067:             *
068:             * @param type The element type (should not be null).
069:             * @param capacity The initial capacity.
070:             *
071:             * @since 2.4
072:             */
073:            public CheckedHashSet(final Class type, final int capacity) {
074:                super (capacity);
075:                this .type = type;
076:                ensureNonNull();
077:            }
078:
079:            /**
080:             * Returns the element type given at construction time.
081:             *
082:             * @since 2.4
083:             */
084:            public Class getElementType() {
085:                return type;
086:            }
087:
088:            /**
089:             * Make sure that {@link #type} is non-null.
090:             */
091:            private void ensureNonNull() {
092:                if (type == null) {
093:                    throw new IllegalArgumentException(Errors.format(
094:                            ErrorKeys.NULL_ARGUMENT_$1, "type"));
095:                }
096:            }
097:
098:            /**
099:             * Checks the type of the specified object. The default implementation ensure
100:             * that the object is assignable to the type specified at construction time.
101:             *
102:             * @param  element the object to check, or {@code null}.
103:             * @throws IllegalArgumentException if the specified element is not of the expected type.
104:             */
105:            protected void ensureValidType(final Object element)
106:                    throws IllegalArgumentException {
107:                if (element != null && !type.isInstance(element)) {
108:                    throw new IllegalArgumentException(Errors.format(
109:                            ErrorKeys.ILLEGAL_CLASS_$2, Utilities
110:                                    .getShortClassName(element), Utilities
111:                                    .getShortName(type)));
112:                }
113:            }
114:
115:            /**
116:             * Adds the specified element to this set if it is not already present.
117:             *
118:             * @param  element element to be added to this set.
119:             * @return {@code true} if the set did not already contain the specified element.
120:             * @throws IllegalArgumentException if the specified element is not of the expected type.
121:             */
122:            public boolean add(final Object element) {
123:                ensureValidType(element);
124:                return super.add(element);
125:            }
126:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.