Source Code Cross Referenced for DefaultCollectionChangeEventFactory.java in  » GIS » GeoTools-2.4.1 » org » apache » commons » events » observable » 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.apache.commons.events.observable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.commons.events.observable;
002:
003:        import java.util.Collection;
004:        import java.util.Map;
005:
006:        public class DefaultCollectionChangeEventFactory implements 
007:                CollectionChangeEventFactory {
008:
009:            private Object source = null;
010:
011:            /**
012:             * Creates a new <code>CollectionChangeEventFactory</code> initialized
013:             * to produce events from the provided source.  The source must be 
014:             * one of the observable collection types (e.g., 
015:             * <code>BoundCollection</code> or <code>ConstrainedCollection</code>.)
016:             *
017:             * @param source The observed collection which acts as the source of all
018:             *   events produced by this factory.
019:             * @throws IllegalArgumentException if <code>source</code> is not 
020:             *   one of the observable collection types.
021:             */
022:            public DefaultCollectionChangeEventFactory(Object source)
023:                    throws IllegalArgumentException {
024:
025:                setCollection(source);
026:            }
027:
028:            public DefaultCollectionChangeEventFactory() {
029:            }
030:
031:            /**
032:             * This method creates and returns a new 
033:             * DefaultCollectionChangeEventFactory.  As this class does not maintain
034:             * any state information other than the event source, and the 
035:             * event source is the only thing which is not supposed to be 
036:             * replicated according to the interface contract, this is entirely 
037:             * proper.
038:             * @return A new DefaultCollectionChangeEventFactory with the 
039:             *    source term uninitialized.
040:             */
041:            public Object clone() {
042:                return new DefaultCollectionChangeEventFactory();
043:            }
044:
045:            public Object getCollection() {
046:                return source;
047:            }
048:
049:            /**
050:             * <p>
051:             * Sets the source of events produced by this factory.  This method may 
052:             * only be called once.  Attempting to change the source of the factory
053:             * when it has previously been set will cause this method to 
054:             * throw an <code>UnsupportedOperationException</code>.  This method 
055:             * is provided so that users may explicitly supply a factory to a 
056:             * bound or constrained collection decorator.  
057:             * </p>
058:             *
059:             * @param source The observed collection which acts as the source of all
060:             *   events produced by this factory.
061:             * @throws IllegalArgumentException if <code>source</code> is not 
062:             *   one of the observable collection types.
063:             * @throws UnsupportedOperationException if <code>source</code> has 
064:             *   previously been set.
065:             */
066:            public void setCollection(Object source)
067:                    throws IllegalArgumentException,
068:                    UnsupportedOperationException {
069:
070:                // check for an existing collection
071:                if (this .source != null) {
072:                    throw new UnsupportedOperationException(
073:                            "Changing the event source is not allowed.");
074:                }
075:
076:                // check that the collection is the correct type.
077:                if (!(source instanceof  BoundCollection)
078:                        && !(source instanceof  ConstrainedCollection)
079:                        && !(source instanceof  BoundMap)) {
080:
081:                    throw new IllegalArgumentException(
082:                            "Source must be a BoundCollection, ConstrainedCollection, "
083:                                    + "or BoundMap.");
084:                }
085:
086:                this .source = source;
087:            }
088:
089:            public CollectionChangeEvent createAdd(Object element,
090:                    boolean changed) {
091:                return new CollectionChangeEvent(source,
092:                        CollectionChangeType.ADD, changed, element);
093:            }
094:
095:            public CollectionChangeEvent createAddIndexed(int index,
096:                    Object element, boolean changed) {
097:
098:                return new CollectionChangeEvent(source,
099:                        CollectionChangeType.ADD_INDEXED, changed, element,
100:                        index);
101:            }
102:
103:            public CollectionChangeEvent createAddNCopies(int copies,
104:                    Object element, boolean changed) {
105:
106:                return new CollectionChangeEvent(source,
107:                        CollectionChangeType.ADD_NCOPIES, changed, element,
108:                        copies);
109:            }
110:
111:            public CollectionChangeEvent createAddIterated(int index,
112:                    Object element, boolean changed) {
113:
114:                return new CollectionChangeEvent(source,
115:                        CollectionChangeType.ADD_ITERATED, changed, element,
116:                        index);
117:            }
118:
119:            public CollectionChangeEvent createAddAll(Collection element,
120:                    boolean changed) {
121:                return new CollectionChangeEvent(source,
122:                        CollectionChangeType.ADD_ALL, changed, element);
123:            }
124:
125:            public CollectionChangeEvent createAddAllIndexed(int index,
126:                    Collection element, boolean changed) {
127:
128:                return new CollectionChangeEvent(source,
129:                        CollectionChangeType.ADD_ALL_INDEXED, changed, element,
130:                        index);
131:            }
132:
133:            public CollectionChangeEvent createClear(boolean changed) {
134:
135:                return new CollectionChangeEvent(source,
136:                        CollectionChangeType.CLEAR, changed);
137:            }
138:
139:            public CollectionChangeEvent createRemove(Object element,
140:                    boolean changed) {
141:                return new CollectionChangeEvent(source,
142:                        CollectionChangeType.REMOVE, changed, element);
143:            }
144:
145:            public CollectionChangeEvent createRemoveIndexed(int index,
146:                    Object element, boolean changed) {
147:
148:                return new CollectionChangeEvent(source,
149:                        CollectionChangeType.REMOVE_INDEXED, changed, element,
150:                        index);
151:            }
152:
153:            public CollectionChangeEvent createRemoveNCopies(int copies,
154:                    Object element, boolean changed) {
155:
156:                return new CollectionChangeEvent(source,
157:                        CollectionChangeType.REMOVE_NCOPIES, changed, element,
158:                        copies);
159:            }
160:
161:            public CollectionChangeEvent createRemoveNext(Object element,
162:                    boolean changed) {
163:
164:                return new CollectionChangeEvent(source,
165:                        CollectionChangeType.REMOVE_NEXT, changed, element);
166:            }
167:
168:            public CollectionChangeEvent createRemoveIterated(int index,
169:                    Object element, boolean changed) {
170:
171:                return new CollectionChangeEvent(source,
172:                        CollectionChangeType.REMOVE_ITERATED, changed, element,
173:                        index);
174:            }
175:
176:            public CollectionChangeEvent createRemoveAll(Collection element,
177:                    boolean changed) {
178:
179:                return new CollectionChangeEvent(source,
180:                        CollectionChangeType.REMOVE_ALL, changed, element);
181:            }
182:
183:            public CollectionChangeEvent createRetainAll(Collection element,
184:                    boolean changed) {
185:
186:                return new CollectionChangeEvent(source,
187:                        CollectionChangeType.RETAIN_ALL, changed, element);
188:            }
189:
190:            public CollectionChangeEvent createSetIndexed(int index,
191:                    Object oldValue, Object element, boolean changed) {
192:
193:                return new CollectionChangeEvent(source,
194:                        CollectionChangeType.SET_INDEXED, changed, element,
195:                        oldValue, index);
196:            }
197:
198:            public CollectionChangeEvent createSetIterated(int index,
199:                    Object oldValue, Object element, boolean changed) {
200:
201:                return new CollectionChangeEvent(source,
202:                        CollectionChangeType.SET_ITERATED, changed, element,
203:                        oldValue, index);
204:            }
205:
206:            public CollectionChangeEvent createPut(Object key, Object value,
207:                    Object oldValue, boolean changed) {
208:
209:                return new CollectionChangeEvent(source,
210:                        CollectionChangeType.PUT, changed, key, oldValue, value);
211:            }
212:
213:            public CollectionChangeEvent createPutAll(Map map, boolean changed) {
214:
215:                return new CollectionChangeEvent(source,
216:                        CollectionChangeType.PUT_ALL, changed, map);
217:            }
218:
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.