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


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:         *    Created on 16-Sep-2004
017:         */
018:        package org.geotools.data.wfs;
019:
020:        import java.util.HashMap;
021:        import java.util.Map;
022:        import java.util.NoSuchElementException;
023:        import java.util.logging.Logger;
024:
025:        import org.geotools.feature.Feature;
026:        import org.geotools.feature.IllegalAttributeException;
027:        import org.opengis.filter.Filter;
028:        import org.geotools.filter.FilterFactoryFinder;
029:        import org.geotools.filter.Filters;
030:        import org.geotools.filter.visitor.DuplicatorFilterVisitor;
031:
032:        /**
033:         * This interface represents pending actions within a transaction.
034:         *
035:         * @author dzwiers
036:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/wfs/src/main/java/org/geotools/data/wfs/Action.java $
037:         */
038:        public interface Action {
039:            /**
040:             * Action mask for an Insert Action
041:             */
042:            public static final int INSERT = 1;
043:            /**
044:             * Action mask for an Update Action
045:             */
046:            public static final int UPDATE = 2;
047:            /**
048:             * Action mask for a Delete Action
049:             */
050:            public static final int DELETE = 4;
051:
052:            /**
053:             * @return The Type of Action ... one of the three Constants
054:             */
055:            public int getType();
056:
057:            /**
058:             * @return The Filter on which to inflict the Action
059:             */
060:            public Filter getFilter();
061:
062:            /**
063:             * @return The FeatureType name for which this Action is intended
064:             */
065:            public String getTypeName();
066:
067:            /**
068:             * Represents an Update Action
069:             * 
070:             * @author dzwiers
071:             */
072:            public static class UpdateAction implements  Action {
073:                private final Filter filter;
074:                private final Map properties;
075:                private final String typeName;
076:
077:                /**
078:                 * Makes an UpdateAction Filter is copied so any further changes will not be included in filter of action.
079:                 * 
080:                 * @param typeName The TypeName
081:                 * @param f Filter which this update affects
082:                 * @param properties The properties to update.  Entries must be <String, Object>  where String is an attribute to 
083:                 * update and Object is the new Value.
084:                 */
085:                public UpdateAction(String typeName, Filter f, Map properties) {
086:                    DuplicatorFilterVisitor visitor = new DuplicatorFilterVisitor(
087:                            FilterFactoryFinder.createFilterFactory(), false);
088:                    Filters.accept(f, visitor);
089:                    filter = (Filter) visitor.getCopy();
090:                    this .properties = new HashMap(properties);
091:                    this .typeName = typeName;
092:                }
093:
094:                /**
095:                 * @return @see Action#UPDATE
096:                 */
097:                public int getType() {
098:                    return UPDATE;
099:                }
100:
101:                /**
102:                 * Returns the property if found ... this method will not create a 
103:                 * NullPointerException if properties is null.
104:                 * 
105:                 * @param name String the property key
106:                 * @return Object The property if found, null other wise. 
107:                 */
108:                public Object getProperty(String name) {
109:                    return (properties == null) ? null : properties.get(name);
110:                }
111:
112:                /**
113:                 * Returns the property names if they exist ... this method will not create a 
114:                 * NullPointerException if properties is null.
115:                 * 
116:                 * @return A list of the keys. 
117:                 */
118:                public String[] getPropertyNames() {
119:                    return properties == null ? new String[0]
120:                            : (String[]) properties.keySet().toArray(
121:                                    new String[properties.keySet().size()]);
122:                }
123:
124:                /**
125:                 * @return a clone of the properties map, null if it does not exist. 
126:                 */
127:                public Map getProperties() {
128:                    return properties == null ? null : new HashMap(properties);
129:                }
130:
131:                /**
132:                 * @return Filter the Filter
133:                 */
134:                public Filter getFilter() {
135:                    return filter;
136:                }
137:
138:                /**
139:                 * @return String the TypeName
140:                 */
141:                public String getTypeName() {
142:                    return typeName;
143:                }
144:
145:                public void update(Feature feature) {
146:                    if (!filter.evaluate(feature))
147:                        throw new IllegalArgumentException(
148:                                feature
149:                                        + "is not affected by this update, only call update on features that"
150:                                        + "the Action applies to!");
151:                    String[] propNames = getPropertyNames();
152:
153:                    for (int j = 0; j < propNames.length; j++) {
154:                        try {
155:                            feature.setAttribute(propNames[j],
156:                                    getProperty(propNames[j]));
157:                        } catch (IllegalAttributeException e) {
158:                            NoSuchElementException ee = new NoSuchElementException(
159:                                    e.getMessage());
160:                            ee.initCause(e);
161:                            throw ee;
162:                        }
163:                    }
164:                }
165:
166:                public String toString() {
167:                    return "UPDATE " + filter + " " + properties;
168:                }
169:            }
170:
171:            /**
172:             * Represents a Delete Action for a Transaction
173:             * 
174:             * @author dzwiers
175:             */
176:            public static class DeleteAction implements  Action {
177:                private final Filter filter;
178:                private final String typeName;
179:
180:                /**
181:                 * Represents a Delete Action.  Filter is copied so any further changes will not be included in filter of action.
182:                 * 
183:                 * @param typeName TypeName
184:                 * @param f Filter of Features to Delete
185:                 */
186:                public DeleteAction(String typeName, Filter f) {
187:                    DuplicatorFilterVisitor visitor = new DuplicatorFilterVisitor(
188:                            FilterFactoryFinder.createFilterFactory(), false);
189:                    Filters.accept(f, visitor);
190:                    filter = (Filter) visitor.getCopy();
191:                    this .typeName = typeName;
192:                }
193:
194:                /**
195:                 * @return @see Action#DELETE
196:                 */
197:                public int getType() {
198:                    return DELETE;
199:                }
200:
201:                /**
202:                 * @return the TypeName
203:                 */
204:                public String getTypeName() {
205:                    return typeName;
206:                }
207:
208:                /**
209:                 * @return the Filter
210:                 */
211:                public Filter getFilter() {
212:                    return filter;
213:                }
214:
215:                public String toString() {
216:                    return "REMOVE " + filter;
217:                }
218:
219:            }
220:
221:            /**
222:             * Represents an Insert Action
223:             * 
224:             * @author dzwiers
225:             */
226:            public static class InsertAction implements  Action {
227:                private final Feature feature;
228:
229:                /**
230:                 * Creates an insert action for the Feature specified.  The feature is copied to
231:                 * prevent inadvertant side effect of modifing the feature after an insert.
232:                 * 
233:                 * @param f Feature to add
234:                 */
235:                public InsertAction(Feature f) {
236:                    Feature feature;
237:                    try {
238:                        feature = f.getFeatureType().duplicate(f);
239:                    } catch (IllegalAttributeException e) {
240:                        org.geotools.util.logging.Logging.getLogger(
241:                                "org.geotools.data.wfs").warning(
242:                                "Failed to duplicate feature:" + f);
243:                        feature = f;
244:                    }
245:                    this .feature = feature;
246:                }
247:
248:                /**
249:                 * @return @see Action#INSERT
250:                 */
251:                public int getType() {
252:                    return INSERT;
253:                }
254:
255:                /**
256:                 * @return The Feature to add
257:                 */
258:                public Feature getFeature() {
259:                    return feature;
260:                }
261:
262:                /**
263:                 * @see org.geotools.data.wfs.Action#getTypeName()
264:                 */
265:                public String getTypeName() {
266:                    return (feature == null) ? null : feature.getFeatureType()
267:                            .getTypeName();
268:                }
269:
270:                /**
271:                 * @see org.geotools.data.wfs.Action#getFilter()
272:                 */
273:                public Filter getFilter() {
274:                    return (feature.getID() == null) ? null
275:                            : (FilterFactoryFinder.createFilterFactory()
276:                                    .createFidFilter(feature.getID()));
277:                }
278:
279:                public String toString() {
280:                    return "INSERT " + feature;
281:                }
282:            }
283:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.