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


0001:        /*
0002:         *    GeoTools - OpenSource mapping toolkit
0003:         *    http://geotools.org
0004:         *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
0005:         *
0006:         *    This library is free software; you can redistribute it and/or
0007:         *    modify it under the terms of the GNU Lesser General Public
0008:         *    License as published by the Free Software Foundation; either
0009:         *    version 2.1 of the License, or (at your option) any later version.
0010:         *
0011:         *    This library is distributed in the hope that it will be useful,
0012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014:         *    Lesser General Public License for more details.
0015:         */
0016:        package org.geotools.xml.wfs;
0017:
0018:        import java.io.IOException;
0019:        import java.net.URI;
0020:        import java.util.ArrayList;
0021:        import java.util.Arrays;
0022:        import java.util.Collection;
0023:        import java.util.HashSet;
0024:        import java.util.Iterator;
0025:        import java.util.List;
0026:        import java.util.Map;
0027:        import java.util.Set;
0028:
0029:        import javax.naming.OperationNotSupportedException;
0030:
0031:        import org.geotools.data.Query;
0032:        import org.geotools.data.wfs.Action;
0033:        import org.geotools.data.wfs.LockRequest;
0034:        import org.geotools.data.wfs.LockResult;
0035:        import org.geotools.data.wfs.TransactionResult;
0036:        import org.geotools.data.wfs.WFSTransactionState;
0037:        import org.geotools.data.wfs.Action.DeleteAction;
0038:        import org.geotools.data.wfs.Action.InsertAction;
0039:        import org.geotools.data.wfs.Action.UpdateAction;
0040:        import org.geotools.feature.Feature;
0041:        import org.geotools.filter.FidFilter;
0042:        import org.geotools.filter.FilterFactory;
0043:        import org.geotools.filter.FilterFactoryFinder;
0044:        import org.geotools.xml.PrintHandler;
0045:        import org.geotools.xml.SchemaFactory;
0046:        import org.geotools.xml.filter.FilterSchema;
0047:        import org.geotools.xml.filter.FilterSchema.FilterElement;
0048:        import org.geotools.xml.gml.GMLSchema;
0049:        import org.geotools.xml.schema.Attribute;
0050:        import org.geotools.xml.schema.AttributeValue;
0051:        import org.geotools.xml.schema.Choice;
0052:        import org.geotools.xml.schema.Element;
0053:        import org.geotools.xml.schema.ElementGrouping;
0054:        import org.geotools.xml.schema.ElementValue;
0055:        import org.geotools.xml.schema.Facet;
0056:        import org.geotools.xml.schema.Schema;
0057:        import org.geotools.xml.schema.Sequence;
0058:        import org.geotools.xml.schema.SimpleType;
0059:        import org.geotools.xml.schema.impl.ChoiceGT;
0060:        import org.geotools.xml.schema.impl.FacetGT;
0061:        import org.geotools.xml.schema.impl.SequenceGT;
0062:        import org.geotools.xml.wfs.WFSBasicComplexTypes.FeatureCollectionType;
0063:        import org.geotools.xml.wfs.WFSBasicComplexTypes.QueryType;
0064:        import org.geotools.xml.wfs.WFSSchema.WFSAttribute;
0065:        import org.geotools.xml.wfs.WFSSchema.WFSComplexType;
0066:        import org.geotools.xml.wfs.WFSSchema.WFSElement;
0067:        import org.geotools.xml.xsi.XSISimpleTypes;
0068:        import org.xml.sax.Attributes;
0069:        import org.xml.sax.SAXException;
0070:        import org.xml.sax.SAXNotSupportedException;
0071:        import org.xml.sax.helpers.AttributesImpl;
0072:
0073:        import com.vividsolutions.jts.geom.Geometry;
0074:
0075:        /**
0076:         * <p>
0077:         * DOCUMENT ME!
0078:         * </p>
0079:         *
0080:         * @author dzwiers
0081:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/wfs/src/main/java/org/geotools/xml/wfs/WFSTransactionComplexTypes.java $
0082:         */
0083:        public class WFSTransactionComplexTypes {
0084:            /**
0085:             * <p>
0086:             * This class represents an TransactionType within the WFS Schema.  This
0087:             * includes both the data and parsing functionality associated with a
0088:             * TransactionType.
0089:             * </p>
0090:             *
0091:             * @see WFSComplexType
0092:             */
0093:            static class TransactionType extends WFSComplexType {
0094:                // singleton instance
0095:                private static final WFSComplexType instance = new TransactionType();
0096:
0097:                //        <xsd:complexType name="TransactionType">
0098:                //	      <xsd:annotation>
0099:                //	         <xsd:documentation>
0100:                //	            The TranactionType defines the Transaction operation.  A
0101:                //	            Transaction element contains one or more Insert, Update
0102:                //	            Delete and Native elements that allow a client application
0103:                //	            to create, modify or remove feature instances from the 
0104:                //	            feature repository that a Web Feature Service controls.
0105:                //	         </xsd:documentation>
0106:                //	      </xsd:annotation>
0107:                //	      <xsd:sequence>
0108:                //	         <xsd:element ref="wfs:LockId" minOccurs="0">
0109:                //	            <xsd:annotation>
0110:                //	               <xsd:documentation>
0111:                //	                  In order for a client application to operate upon locked
0112:                //	                  feature instances, the Transaction request must include
0113:                //	                  the LockId element.  The content of this element must be
0114:                //	                  the lock identifier the client application obtained from
0115:                //	                  a previous GetFeatureWithLock or LockFeature operation.
0116:                //
0117:                //	                  If the correct lock identifier is specified the Web
0118:                //	                  Feature Service knows that the client application may
0119:                //	                  operate upon the locked feature instances.
0120:                //
0121:                //	                  No LockId element needs to be specified to operate upon
0122:                //	                  unlocked features.
0123:                //	               </xsd:documentation>
0124:                //	            </xsd:annotation>
0125:                //	         </xsd:element>
0126:                //	         <xsd:choice minOccurs="0" maxOccurs="unbounded">
0127:                //	            <xsd:element ref="wfs:Insert"/>
0128:                //	            <xsd:element ref="wfs:Update"/>
0129:                //	            <xsd:element ref="wfs:Delete"/>
0130:                //	            <xsd:element ref="wfs:Native"/>
0131:                //	         </xsd:choice>
0132:                //	      </xsd:sequence>
0133:                //	      <xsd:attribute name="version"
0134:                //	                     type="xsd:string" use="required" fixed="1.0.0"/>
0135:                //	      <xsd:attribute name="service"
0136:                //	                     type="xsd:string" use="required" fixed="WFS"/>
0137:                //	      <xsd:attribute name="handle"
0138:                //	                     type="xsd:string" use="optional"/>
0139:                //	      <xsd:attribute name="releaseAction"
0140:                //	                     type="wfs:AllSomeType" use="optional">
0141:                //	         <xsd:annotation>
0142:                //	            <xsd:documentation>
0143:                //	               The releaseAction attribute is used to control how a Web
0144:                //	               Feature service releases locks on feature instances after
0145:                //	               a Transaction request has been processed.
0146:                //
0147:                //	               Valid values are ALL or SOME.
0148:                //
0149:                //	               A value of ALL means that the Web Feature Service should
0150:                //	               release the locks of all feature instances locked with the
0151:                //	               specified lockId, regardless or whether or not the features
0152:                //	               were actually modified.
0153:                //
0154:                //	               A value of SOME means that the Web Feature Service will 
0155:                //	               only release the locks held on feature instances that 
0156:                //	               were actually operated upon by the transaction.  The lockId
0157:                //	               that the client application obtained shall remain valid and
0158:                //	               the other, unmodified, feature instances shall remain locked.
0159:                //	               If the expiry attribute was specified in the original operation 
0160:                //	               that locked the feature instances, then the expiry counter
0161:                //	               will be reset to give the client application that same amount
0162:                //	               of time to post subsequent transactions against the locked
0163:                //	               features.
0164:                //	            </xsd:documentation>
0165:                //	         </xsd:annotation>
0166:                //	      </xsd:attribute>
0167:                //	   </xsd:complexType>
0168:                private static Element[] elems = new Element[] {
0169:                        new WFSElement("LockId", XSISimpleTypes.String
0170:                                .getInstance(), 0, 1, false, null),
0171:                        new WFSElement("Insert", InsertElementType
0172:                                .getInstance()),
0173:                        new WFSElement("Update", UpdateElementType
0174:                                .getInstance()),
0175:                        new WFSElement("Delete", DeleteElementType
0176:                                .getInstance()),
0177:                        new WFSElement("Native", NativeType.getInstance()) };
0178:                private static Sequence child = new SequenceGT(
0179:                        new ElementGrouping[] {
0180:                                elems[0],
0181:                                new ChoiceGT(null, 0, Integer.MAX_VALUE,
0182:                                        new Element[] { elems[1], elems[2],
0183:                                                elems[3], elems[4] }) });
0184:                private static Attribute[] attrs = new Attribute[] {
0185:                        new WFSAttribute("version", XSISimpleTypes.String
0186:                                .getInstance(), Attribute.REQUIRED) {
0187:                            public String getFixed() {
0188:                                return "1.0.0";
0189:                            }
0190:                        },
0191:                        new WFSAttribute("service", XSISimpleTypes.String
0192:                                .getInstance(), Attribute.REQUIRED) {
0193:                            public String getFixed() {
0194:                                return "WFS";
0195:                            }
0196:                        },
0197:                        new WFSAttribute("handle", XSISimpleTypes.String
0198:                                .getInstance(), Attribute.OPTIONAL),
0199:                        new WFSAttribute("lockAction", AllSomeType
0200:                                .getInstance(), Attribute.OPTIONAL) };
0201:
0202:                public static WFSComplexType getInstance() {
0203:                    return instance;
0204:                }
0205:
0206:                /**
0207:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
0208:                 */
0209:                public Attribute[] getAttributes() {
0210:                    return attrs;
0211:                }
0212:
0213:                /**
0214:                 * @see org.geotools.xml.schema.ComplexType#getChild()
0215:                 */
0216:                public ElementGrouping getChild() {
0217:                    return child;
0218:                }
0219:
0220:                /**
0221:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
0222:                 */
0223:                public Element[] getChildElements() {
0224:                    return elems;
0225:                }
0226:
0227:                /**
0228:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
0229:                 *      org.geotools.xml.schema.ElementValue[],
0230:                 *      org.xml.sax.Attributes, java.util.Map)
0231:                 */
0232:                public Object getValue(Element element, ElementValue[] value,
0233:                        Attributes attrs1, Map hints) throws SAXException,
0234:                        SAXNotSupportedException {
0235:                    throw new SAXNotSupportedException("");
0236:                }
0237:
0238:                /**
0239:                 * @see org.geotools.xml.schema.Type#getName()
0240:                 */
0241:                public String getName() {
0242:                    return "TransactionType";
0243:                }
0244:
0245:                /**
0246:                 * @see org.geotools.xml.schema.Type#getInstanceType()
0247:                 */
0248:                public Class getInstanceType() {
0249:                    return WFSTransactionState.class;
0250:                }
0251:
0252:                /**
0253:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0254:                 *      java.lang.Object, java.util.Map)
0255:                 */
0256:                public boolean canEncode(Element element, Object value,
0257:                        Map hints) {
0258:                    return (element != null) && (element.getType() != null)
0259:                            && getName().equals(element.getType().getName())
0260:                            && (value != null)
0261:                            && value instanceof  WFSTransactionState;
0262:                }
0263:
0264:                /**
0265:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0266:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
0267:                 *      java.util.Map)
0268:                 */
0269:                public void encode(Element element, Object value,
0270:                        PrintHandler output, Map hints) throws IOException,
0271:                        OperationNotSupportedException {
0272:                    if (!canEncode(element, value, hints)) {
0273:                        throw new IOException("Cannot encode");
0274:                    }
0275:
0276:                    AttributesImpl attributes = new AttributesImpl();
0277:                    attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
0278:                            attrs[0].getName(), null, "string", attrs[0]
0279:                                    .getFixed());
0280:                    attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
0281:                            attrs[1].getName(), null, "string", attrs[1]
0282:                                    .getFixed());
0283:                    attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
0284:                            attrs[3].getName(), null, "string", "ALL");
0285:
0286:                    WFSTransactionState transactionRequest = (WFSTransactionState) value;
0287:
0288:                    output.startElement(element.getNamespace(), element
0289:                            .getName(), attributes);
0290:
0291:                    if (transactionRequest.getLockId() != null) {
0292:                        elems[0].getType().encode(elems[0],
0293:                                transactionRequest.getLockId(), output, hints);
0294:                    }
0295:
0296:                    Iterator actions = transactionRequest.getAllActions()
0297:                            .iterator();
0298:
0299:                    while (actions.hasNext()) {
0300:                        Action a = (Action) actions.next();
0301:
0302:                        switch (a.getType()) {
0303:                        case Action.DELETE:
0304:                            elems[3].getType().encode(elems[3], a, output,
0305:                                    hints);
0306:
0307:                            break;
0308:
0309:                        case Action.INSERT:
0310:                            elems[1].getType().encode(elems[1], a, output,
0311:                                    hints);
0312:
0313:                            break;
0314:
0315:                        case Action.UPDATE:
0316:                            elems[2].getType().encode(elems[2], a, output,
0317:                                    hints);
0318:
0319:                            break;
0320:
0321:                        default:
0322:                            elems[4].getType().encode(elems[4], a, output,
0323:                                    hints);
0324:                        }
0325:                    }
0326:
0327:                    output
0328:                            .endElement(element.getNamespace(), element
0329:                                    .getName());
0330:                }
0331:            }
0332:
0333:            static class GetFeatureWithLockType extends WFSComplexType {
0334:                // singleton instance
0335:                private static final WFSComplexType instance = new FeatureCollectionType();
0336:
0337:                //        <xsd:complexType name="GetFeatureWithLockType">
0338:                //	      <xsd:annotation>
0339:                //	         <xsd:documentation>
0340:                //	            A GetFeatureWithLock request operates identically to a
0341:                //	            GetFeature request expect that it attempts to lock the
0342:                //	            feature instances in the result set and includes a lock
0343:                //	            identifier in its response to a client.  A lock identifier
0344:                //	            is an identifier generated by a Web Feature Service that 
0345:                //	            a client application can use, in subsequent operations,
0346:                //	            to reference the locked set of feature instances.
0347:                //	         </xsd:documentation>
0348:                //	      </xsd:annotation>
0349:                //	      <xsd:sequence>
0350:                //	         <xsd:element ref="wfs:Query" maxOccurs="unbounded"/>
0351:                //	      </xsd:sequence>
0352:                //	      <xsd:attribute name="version"
0353:                //	                     type="xsd:string" use="required" fixed="1.0.0"/>
0354:                //	      <xsd:attribute name="service"
0355:                //	                     type="xsd:string" use="required" fixed="WFS"/>
0356:                //	      <xsd:attribute name="handle"
0357:                //	                     type="xsd:string" use="optional"/>
0358:                //	      <xsd:attribute name="expiry"
0359:                //	                     type="xsd:positiveInteger" use="optional"/>
0360:                //	      <xsd:attribute name="outputFormat"
0361:                //	                     type="xsd:string" use="optional" default="GML2"/>
0362:                //	      <xsd:attribute name="maxFeatures"
0363:                //	                     type="xsd:positiveInteger" use="optional"/>
0364:                //	   </xsd:complexType>
0365:                private static Element[] elems = new Element[] { new WFSElement(
0366:                        "Query", QueryType.getInstance(), 1, Integer.MAX_VALUE,
0367:                        false, null) };
0368:                private static Sequence child = new SequenceGT(elems);
0369:                private static Attribute[] attrs = new Attribute[] {
0370:                        new WFSAttribute("version", XSISimpleTypes.String
0371:                                .getInstance(), Attribute.REQUIRED) {
0372:                            public String getFixed() {
0373:                                return "1.0.0";
0374:                            }
0375:                        },
0376:                        new WFSAttribute("service", XSISimpleTypes.String
0377:                                .getInstance(), Attribute.REQUIRED) {
0378:                            public String getFixed() {
0379:                                return "WFS";
0380:                            }
0381:                        },
0382:                        new WFSAttribute("handle", XSISimpleTypes.String
0383:                                .getInstance(), Attribute.OPTIONAL),
0384:                        new WFSAttribute("outputFormat", XSISimpleTypes.String
0385:                                .getInstance(), Attribute.OPTIONAL, "GML2"),
0386:                        new WFSAttribute("maxFeatures",
0387:                                XSISimpleTypes.PositiveInteger.getInstance(),
0388:                                Attribute.OPTIONAL) };
0389:
0390:                public static WFSComplexType getInstance() {
0391:                    return instance;
0392:                }
0393:
0394:                /**
0395:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
0396:                 */
0397:                public Attribute[] getAttributes() {
0398:                    return attrs;
0399:                }
0400:
0401:                /**
0402:                 * @see org.geotools.xml.schema.ComplexType#getChild()
0403:                 */
0404:                public ElementGrouping getChild() {
0405:                    return child;
0406:                }
0407:
0408:                /**
0409:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
0410:                 */
0411:                public Element[] getChildElements() {
0412:                    return elems;
0413:                }
0414:
0415:                /**
0416:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
0417:                 *      org.geotools.xml.schema.ElementValue[],
0418:                 *      org.xml.sax.Attributes, java.util.Map)
0419:                 */
0420:                public Object getValue(Element element, ElementValue[] value,
0421:                        Attributes attrs1, Map hints) throws SAXException,
0422:                        SAXNotSupportedException {
0423:                    throw new SAXNotSupportedException("");
0424:                }
0425:
0426:                /**
0427:                 * @see org.geotools.xml.schema.Type#getName()
0428:                 */
0429:                public String getName() {
0430:                    return "GetFeatureWithLockType";
0431:                }
0432:
0433:                /**
0434:                 * @see org.geotools.xml.schema.Type#getInstanceType()
0435:                 */
0436:                public Class getInstanceType() {
0437:                    return Query.class;
0438:                }
0439:
0440:                /**
0441:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0442:                 *      java.lang.Object, java.util.Map)
0443:                 */
0444:                public boolean canEncode(Element element, Object value,
0445:                        Map hints) {
0446:                    if ((element.getType() != null)
0447:                            && getName().equals(element.getType().getName())) {
0448:                        return ((value == null) || value instanceof  Query);
0449:                    }
0450:
0451:                    return false;
0452:                }
0453:
0454:                /**
0455:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0456:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
0457:                 *      java.util.Map)
0458:                 */
0459:                public void encode(Element element, Object value,
0460:                        PrintHandler output, Map hints) throws IOException,
0461:                        OperationNotSupportedException {
0462:                    if (canEncode(element, value, hints)) {
0463:                        AttributesImpl attributes = new AttributesImpl();
0464:                        attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
0465:                                attrs[0].getName(), null, "string", attrs[0]
0466:                                        .getFixed());
0467:                        attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
0468:                                attrs[1].getName(), null, "string", attrs[1]
0469:                                        .getFixed());
0470:                        attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
0471:                                attrs[2].getName(), null, "string", attrs[3]
0472:                                        .getDefault());
0473:
0474:                        Query query = (Query) value;
0475:
0476:                        if ((query != null)
0477:                                && (query.getMaxFeatures() != Query.DEFAULT_MAX)) {
0478:                            attributes.addAttribute(WFSSchema.NAMESPACE
0479:                                    .toString(), elems[3].getName(), null,
0480:                                    "integer", "" + query.getMaxFeatures());
0481:                        }
0482:
0483:                        if (hints != null) {
0484:                            String lockId = (String) hints
0485:                                    .get(WFSBasicComplexTypes.LOCK_KEY);
0486:
0487:                            if (lockId != null) {
0488:                                attributes.addAttribute(WFSSchema.NAMESPACE
0489:                                        .toString(), elems[2].getName(), null,
0490:                                        "string", lockId);
0491:                            }
0492:                        }
0493:
0494:                        output.startElement(element.getNamespace(), element
0495:                                .getName(), attributes);
0496:                        elems[0].getType().encode(elems[0], value, output,
0497:                                hints);
0498:                        output.endElement(element.getNamespace(), element
0499:                                .getName());
0500:                    } else {
0501:                        throw new OperationNotSupportedException(
0502:                                "not a valid value/element for a DescribeFeatureTypeType.");
0503:                    }
0504:                }
0505:            }
0506:
0507:            static class LockFeatureType extends WFSComplexType {
0508:                // singleton instance
0509:                private static final WFSComplexType instance = new FeatureCollectionType();
0510:
0511:                //        <xsd:complexType name="LockFeatureType">
0512:                //           <xsd:annotation>
0513:                //              <xsd:documentation>
0514:                //                 This type defines the LockFeature operation.  The LockFeature
0515:                //                 element contains one or more Lock elements that define
0516:                //                 which features of a particular type should be locked.  A lock
0517:                //                 identifier (lockId) is returned to the client application which
0518:                //                 can be used by subsequent operations to reference the locked
0519:                //                 features.
0520:                //              </xsd:documentation>
0521:                //           </xsd:annotation>
0522:                //           <xsd:sequence>
0523:                //              <xsd:element name="Lock" type="wfs:LockType" maxOccurs="unbounded">
0524:                //                 <xsd:annotation>
0525:                //                    <xsd:documentation>
0526:                //                       The lock element is used to indicate which feature 
0527:                //                       instances of particular type are to be locked.
0528:                //                    </xsd:documentation>
0529:                //                 </xsd:annotation>
0530:                //              </xsd:element>
0531:                //           </xsd:sequence>
0532:                //           <xsd:attribute name="version"
0533:                //                          type="xsd:string" use="required" fixed="1.0.0"/>
0534:                //           <xsd:attribute name="service"
0535:                //                          type="xsd:string" use="required" fixed="WFS"/>
0536:                //           <xsd:attribute name="expiry"
0537:                //                          type="xsd:positiveInteger" use="optional"/>
0538:                //           <xsd:attribute name="lockAction"
0539:                //                          type="wfs:AllSomeType" use="optional">
0540:                //              <xsd:annotation>
0541:                //                 <xsd:documentation>
0542:                //                    The lockAction attribute is used to indicate what
0543:                //                    a Web Feature Service should do when it encounters
0544:                //                    a feature instance that has already been locked by
0545:                //                    another client application.
0546:                //
0547:                //                    Valid values are ALL or SOME.
0548:                //
0549:                //                    ALL means that the Web Feature Service must acquire
0550:                //                    locks on all the requested feature instances.  If it
0551:                //                    cannot acquire those locks then the request should
0552:                //                    fail.  In this instance, all locks acquired by the
0553:                //                    operation should be released.
0554:                //      
0555:                //                    SOME means that the Web Feature Service should lock
0556:                //                    as many of the requested features as it can.
0557:                //                 </xsd:documentation>
0558:                //              </xsd:annotation>
0559:                //           </xsd:attribute>
0560:                //        </xsd:complexType>
0561:                private static Element[] elems = new Element[] { new WFSElement(
0562:                        "Lock", LockType.getInstance(), 1, Integer.MAX_VALUE,
0563:                        false, null), };
0564:                private Sequence child = new SequenceGT(elems);
0565:                private Attribute[] attrs = new Attribute[] {
0566:                        new WFSAttribute("version", XSISimpleTypes.String
0567:                                .getInstance(), Attribute.REQUIRED) {
0568:                            public String getFixed() {
0569:                                return "1.0.0";
0570:                            }
0571:                        },
0572:                        new WFSAttribute("service", XSISimpleTypes.String
0573:                                .getInstance(), Attribute.REQUIRED) {
0574:                            public String getFixed() {
0575:                                return "WFS";
0576:                            }
0577:                        },
0578:                        new WFSAttribute("expiry",
0579:                                XSISimpleTypes.PositiveInteger.getInstance(),
0580:                                Attribute.OPTIONAL),
0581:                        new WFSAttribute("lockAction", AllSomeType
0582:                                .getInstance(), Attribute.OPTIONAL) };
0583:
0584:                public static WFSComplexType getInstance() {
0585:                    return instance;
0586:                }
0587:
0588:                /**
0589:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
0590:                 */
0591:                public Attribute[] getAttributes() {
0592:                    return attrs;
0593:                }
0594:
0595:                /**
0596:                 * @see org.geotools.xml.schema.ComplexType#getChild()
0597:                 */
0598:                public ElementGrouping getChild() {
0599:                    return child;
0600:                }
0601:
0602:                /**
0603:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
0604:                 */
0605:                public Element[] getChildElements() {
0606:                    return elems;
0607:                }
0608:
0609:                /**
0610:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
0611:                 *      org.geotools.xml.schema.ElementValue[],
0612:                 *      org.xml.sax.Attributes, java.util.Map)
0613:                 */
0614:                public Object getValue(Element element, ElementValue[] value,
0615:                        Attributes attrs1, Map hints) throws SAXException,
0616:                        SAXNotSupportedException {
0617:                    throw new SAXNotSupportedException("");
0618:                }
0619:
0620:                /**
0621:                 * @see org.geotools.xml.schema.Type#getName()
0622:                 */
0623:                public String getName() {
0624:                    return "LockFeatureType";
0625:                }
0626:
0627:                /**
0628:                 * @see org.geotools.xml.schema.Type#getInstanceType()
0629:                 */
0630:                public Class getInstanceType() {
0631:                    return LockRequest.class;
0632:                }
0633:
0634:                /**
0635:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0636:                 *      java.lang.Object, java.util.Map)
0637:                 */
0638:                public boolean canEncode(Element element, Object value,
0639:                        Map hints) {
0640:                    return (element != null) && (element.getType() != null)
0641:                            && getName().equals(element.getType().getName())
0642:                            && (value != null) && value instanceof  LockRequest;
0643:                }
0644:
0645:                /**
0646:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0647:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
0648:                 *      java.util.Map)
0649:                 */
0650:                public void encode(Element element, Object value,
0651:                        PrintHandler output, Map hints) throws IOException,
0652:                        OperationNotSupportedException {
0653:                    if (!canEncode(element, value, hints)) {
0654:                        throw new IOException("Cannot encode");
0655:                    }
0656:
0657:                    AttributesImpl attributes = new AttributesImpl();
0658:                    attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
0659:                            attrs[0].getName(), null, "string", attrs[0]
0660:                                    .getFixed());
0661:                    attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
0662:                            attrs[1].getName(), null, "string", attrs[1]
0663:                                    .getFixed());
0664:                    attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
0665:                            attrs[3].getName(), null, "string", "ALL");
0666:
0667:                    LockRequest lockRequest = (LockRequest) value;
0668:
0669:                    if ((lockRequest != null)
0670:                            && (lockRequest.getDuration() > 0)) {
0671:                        attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
0672:                                elems[2].getName(), null, "integer", ""
0673:                                        + lockRequest.getDuration());
0674:                    }
0675:
0676:                    output.startElement(element.getNamespace(), element
0677:                            .getName(), attributes);
0678:
0679:                    Object[] t = new Object[2];
0680:
0681:                    for (int i = 0; i < lockRequest.getTypeNames().length; i++) {
0682:                        t[0] = lockRequest.getTypeNames()[i];
0683:                        t[1] = lockRequest.getFilters()[i];
0684:                        elems[0].getType().encode(elems[0], t, output, hints);
0685:                    }
0686:
0687:                    output
0688:                            .endElement(element.getNamespace(), element
0689:                                    .getName());
0690:                }
0691:            }
0692:
0693:            static class LockType extends WFSComplexType {
0694:                // singleton instance
0695:                private static final WFSComplexType instance = new LockType();
0696:
0697:                //        <xsd:complexType name="LockType">
0698:                //           <xsd:annotation>
0699:                //              <xsd:documentation>
0700:                //                 This type defines the Lock element.  The Lock element
0701:                //                 defines a locking operation on feature instances of 
0702:                //                 a single type. An OGC Filter is used to constrain the
0703:                //                 scope of the operation.  Features to be locked can be
0704:                //                 identified individually by using their feature identifier
0705:                //                 or they can be locked by satisfying the spatial and 
0706:                //                 non-spatial constraints defined in the filter.
0707:                //              </xsd:documentation>
0708:                //           </xsd:annotation>
0709:                //           <xsd:sequence>
0710:                //              <xsd:element ref="ogc:Filter" minOccurs="0" maxOccurs="1"/>
0711:                //           </xsd:sequence>
0712:                //           <xsd:attribute name="handle" 
0713:                //                          type="xsd:string" use="optional"/>
0714:                //           <xsd:attribute name="typeName" 
0715:                //                          type="xsd:QName" use="required"/>
0716:                //        </xsd:complexType>
0717:                private static Element[] elems = new Element[] { new WFSElement(
0718:                        FilterSchema.getInstance().getElements()[2].getName(),
0719:                        FilterSchema.getInstance().getElements()[2].getType(),
0720:                        0, 1, false,
0721:                        FilterSchema.getInstance().getElements()[2]
0722:                                .getSubstitutionGroup()) {
0723:                    public URI getNamespace() {
0724:                        return FilterSchema.NAMESPACE;
0725:                    }
0726:                }, };
0727:                private static Sequence child = new SequenceGT(elems);
0728:                private static Attribute[] attrs = new Attribute[] {
0729:                        new WFSAttribute("handle", XSISimpleTypes.String
0730:                                .getInstance(), Attribute.OPTIONAL),
0731:                        new WFSAttribute("typeName", XSISimpleTypes.QName
0732:                                .getInstance(), Attribute.REQUIRED) };
0733:
0734:                public static WFSComplexType getInstance() {
0735:                    return instance;
0736:                }
0737:
0738:                /**
0739:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
0740:                 */
0741:                public Attribute[] getAttributes() {
0742:                    return attrs;
0743:                }
0744:
0745:                /**
0746:                 * @see org.geotools.xml.schema.ComplexType#getChild()
0747:                 */
0748:                public ElementGrouping getChild() {
0749:                    return child;
0750:                }
0751:
0752:                /**
0753:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
0754:                 */
0755:                public Element[] getChildElements() {
0756:                    return elems;
0757:                }
0758:
0759:                /**
0760:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
0761:                 *      org.geotools.xml.schema.ElementValue[],
0762:                 *      org.xml.sax.Attributes, java.util.Map)
0763:                 */
0764:                public Object getValue(Element element, ElementValue[] value,
0765:                        Attributes attrs1, Map hints) throws SAXException,
0766:                        SAXNotSupportedException {
0767:                    throw new SAXNotSupportedException("");
0768:                }
0769:
0770:                /**
0771:                 * @see org.geotools.xml.schema.Type#getName()
0772:                 */
0773:                public String getName() {
0774:                    return "LockType";
0775:                }
0776:
0777:                /**
0778:                 * @see org.geotools.xml.schema.Type#getInstanceType()
0779:                 */
0780:                public Class getInstanceType() {
0781:                    return Object[].class;
0782:                }
0783:
0784:                /**
0785:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0786:                 *      java.lang.Object, java.util.Map)
0787:                 */
0788:                public boolean canEncode(Element element, Object value,
0789:                        Map hints) {
0790:                    return (element != null) && (element.getType() != null)
0791:                            && getName().equals(element.getType().getName())
0792:                            && (value != null) && value instanceof  Object[]
0793:                            && (((Object[]) value).length == 2);
0794:                }
0795:
0796:                /**
0797:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0798:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
0799:                 *      java.util.Map)
0800:                 */
0801:                public void encode(Element element, Object value,
0802:                        PrintHandler output, Map hints) throws IOException,
0803:                        OperationNotSupportedException {
0804:                    if (!canEncode(element, value, hints)) {
0805:                        throw new IOException("Cannot encode");
0806:                    }
0807:
0808:                    Object[] t = (Object[]) value;
0809:                    AttributesImpl attributes = new AttributesImpl();
0810:                    attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
0811:                            attrs[1].getName(), null, "string", (String) t[0]);
0812:
0813:                    LockRequest lockRequest = (LockRequest) value;
0814:
0815:                    if ((lockRequest != null)
0816:                            && (lockRequest.getDuration() > 0)) {
0817:                        attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
0818:                                elems[2].getName(), null, "integer", ""
0819:                                        + lockRequest.getDuration());
0820:                    }
0821:
0822:                    output.startElement(element.getNamespace(), element
0823:                            .getName(), attributes);
0824:                    elems[0].getType().encode(elems[0], t[1], output, hints);
0825:                    output
0826:                            .endElement(element.getNamespace(), element
0827:                                    .getName());
0828:                }
0829:            }
0830:
0831:            static class InsertElementType extends WFSComplexType {
0832:                // singleton instance
0833:                private static final WFSComplexType instance = new InsertElementType();
0834:
0835:                //        <xsd:complexType name="InsertElementType">
0836:                //           <xsd:sequence>
0837:                //              <xsd:element ref="gml:_Feature" maxOccurs="unbounded"/>
0838:                //           </xsd:sequence>
0839:                //           <xsd:attribute name="handle" type="xsd:string" use="optional"/>
0840:                //        </xsd:complexType>
0841:                private static Element[] elems = new Element[] { new WFSElement(
0842:                        GMLSchema.getInstance().getElements()[0].getName(),
0843:                        GMLSchema.getInstance().getElements()[0].getType(), 1,
0844:                        Integer.MAX_VALUE, GMLSchema.getInstance()
0845:                                .getElements()[0].isAbstract(), GMLSchema
0846:                                .getInstance().getElements()[0]
0847:                                .getSubstitutionGroup()) {
0848:                    public URI getNamespace() {
0849:                        return GMLSchema.NAMESPACE;
0850:                    }
0851:                } };
0852:                private static Sequence child = new SequenceGT(elems);
0853:                private static Attribute[] attrs = new Attribute[] { new WFSAttribute(
0854:                        "handler", XSISimpleTypes.String.getInstance(),
0855:                        Attribute.OPTIONAL), };
0856:
0857:                public static WFSComplexType getInstance() {
0858:                    return instance;
0859:                }
0860:
0861:                /**
0862:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
0863:                 */
0864:                public Attribute[] getAttributes() {
0865:                    return attrs;
0866:                }
0867:
0868:                /**
0869:                 * @see org.geotools.xml.schema.ComplexType#getChild()
0870:                 */
0871:                public ElementGrouping getChild() {
0872:                    return child;
0873:                }
0874:
0875:                /**
0876:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
0877:                 */
0878:                public Element[] getChildElements() {
0879:                    return elems;
0880:                }
0881:
0882:                /**
0883:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
0884:                 *      org.geotools.xml.schema.ElementValue[],
0885:                 *      org.xml.sax.Attributes, java.util.Map)
0886:                 */
0887:                public Object getValue(Element element, ElementValue[] value,
0888:                        Attributes attrs1, Map hints) throws SAXException,
0889:                        SAXNotSupportedException {
0890:                    throw new SAXNotSupportedException("");
0891:                }
0892:
0893:                /**
0894:                 * @see org.geotools.xml.schema.Type#getName()
0895:                 */
0896:                public String getName() {
0897:                    return "InsertElementType";
0898:                }
0899:
0900:                /**
0901:                 * @see org.geotools.xml.schema.Type#getInstanceType()
0902:                 */
0903:                public Class getInstanceType() {
0904:                    return InsertAction.class;
0905:                }
0906:
0907:                /**
0908:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0909:                 *      java.lang.Object, java.util.Map)
0910:                 */
0911:                public boolean canEncode(Element element, Object value,
0912:                        Map hints) {
0913:                    return (element != null) && (element.getType() != null)
0914:                            && getName().equals(element.getType().getName())
0915:                            && (value != null) && value instanceof  InsertAction;
0916:                }
0917:
0918:                /**
0919:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0920:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
0921:                 *      java.util.Map)
0922:                 */
0923:                public void encode(Element element, Object value,
0924:                        PrintHandler output, Map hints) throws IOException,
0925:                        OperationNotSupportedException {
0926:                    if (!canEncode(element, value, hints)) {
0927:                        return;
0928:                    }
0929:
0930:                    output.startElement(element.getNamespace(), element
0931:                            .getName(), null);
0932:
0933:                    InsertAction a = (InsertAction) value;
0934:
0935:                    // find element definition
0936:                    // should exist when original from a WFS ...
0937:                    Feature f = a.getFeature();
0938:                    Schema schema = SchemaFactory.getInstance(f
0939:                            .getFeatureType().getNamespace());
0940:                    Element[] els = schema.getElements();
0941:                    Element e = null;
0942:
0943:                    if (els != null) {
0944:                        for (int i = 0; i < els.length; i++) {
0945:                            String typeName = f.getFeatureType().getTypeName();
0946:                            if (typeName.indexOf(':') >= 0) {
0947:                                typeName = typeName.substring(typeName
0948:                                        .indexOf(':') + 1);
0949:                            }
0950:                            if (typeName.equals(els[i].getName())) {
0951:                                e = els[i];
0952:                                i = els.length;
0953:                            }
0954:                        }
0955:                    }
0956:
0957:                    // write it
0958:                    elems[0].getType().encode(e, f, output, hints);
0959:                    output
0960:                            .endElement(element.getNamespace(), element
0961:                                    .getName());
0962:                }
0963:            }
0964:
0965:            static class UpdateElementType extends WFSComplexType {
0966:                // singleton instance
0967:                private static final WFSComplexType instance = new UpdateElementType();
0968:
0969:                //        <xsd:complexType name="UpdateElementType">
0970:                //	      <xsd:sequence>
0971:                //	         <xsd:element ref="wfs:Property" maxOccurs="unbounded" />
0972:                //	         <xsd:element ref="ogc:Filter" minOccurs="0" maxOccurs="1">
0973:                //	            <xsd:annotation>
0974:                //	               <xsd:documentation>
0975:                //	                  The Filter element is used to constrain the scope
0976:                //	                  of the update operation to those features identified
0977:                //	                  by the filter.  Feature instances can be specified
0978:                //	                  explicitly and individually using the identifier of
0979:                //	                  each feature instance OR a set of features to be
0980:                //	                  operated on can be identified by specifying spatial
0981:                //	                  and non-spatial constraints in the filter.
0982:                //	                  If no filter is specified, then the update operation 
0983:                //	                  applies to all feature instances.
0984:                //	               </xsd:documentation>
0985:                //	            </xsd:annotation>
0986:                //	         </xsd:element>
0987:                //	      </xsd:sequence>
0988:                //	      <xsd:attribute name="handle" type="xsd:string" use="optional"/>
0989:                //	      <xsd:attribute name="typeName" type="xsd:QName" use="required"/>
0990:                //	   </xsd:complexType>
0991:                private static Element[] elems = new Element[] {
0992:                        new WFSElement("Property", PropertyType.getInstance(),
0993:                                0, Integer.MAX_VALUE, true, null),
0994:                        new WFSElement(
0995:                                FilterSchema.getInstance().getElements()[2]
0996:                                        .getName(), FilterSchema.getInstance()
0997:                                        .getElements()[2].getType(), 0, 1,
0998:                                false,
0999:                                FilterSchema.getInstance().getElements()[2]
1000:                                        .getSubstitutionGroup()) {
1001:                            public URI getNamespace() {
1002:                                return FilterSchema.NAMESPACE;
1003:                            }
1004:                        } };
1005:                private static Sequence child = new SequenceGT(elems);
1006:                private static Attribute[] attrs = new Attribute[] {
1007:                        new WFSAttribute("handler", XSISimpleTypes.String
1008:                                .getInstance(), Attribute.OPTIONAL),
1009:                        new WFSAttribute("typeName", XSISimpleTypes.QName
1010:                                .getInstance(), Attribute.REQUIRED), };
1011:
1012:                public static WFSComplexType getInstance() {
1013:                    return instance;
1014:                }
1015:
1016:                /**
1017:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
1018:                 */
1019:                public Attribute[] getAttributes() {
1020:                    return attrs;
1021:                }
1022:
1023:                /**
1024:                 * @see org.geotools.xml.schema.ComplexType#getChild()
1025:                 */
1026:                public ElementGrouping getChild() {
1027:                    return child;
1028:                }
1029:
1030:                /**
1031:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
1032:                 */
1033:                public Element[] getChildElements() {
1034:                    return elems;
1035:                }
1036:
1037:                /**
1038:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1039:                 *      org.geotools.xml.schema.ElementValue[],
1040:                 *      org.xml.sax.Attributes, java.util.Map)
1041:                 */
1042:                public Object getValue(Element element, ElementValue[] value,
1043:                        Attributes attrs1, Map hints) throws SAXException,
1044:                        SAXNotSupportedException {
1045:                    throw new SAXNotSupportedException("");
1046:                }
1047:
1048:                /**
1049:                 * @see org.geotools.xml.schema.Type#getName()
1050:                 */
1051:                public String getName() {
1052:                    return "UpdateElementType";
1053:                }
1054:
1055:                /**
1056:                 * @see org.geotools.xml.schema.Type#getInstanceType()
1057:                 */
1058:                public Class getInstanceType() {
1059:                    return UpdateAction.class;
1060:                }
1061:
1062:                /**
1063:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1064:                 *      java.lang.Object, java.util.Map)
1065:                 */
1066:                public boolean canEncode(Element element, Object value,
1067:                        Map hints) {
1068:                    return (element != null) && (element.getType() != null)
1069:                            && getName().equals(element.getType().getName())
1070:                            && (value != null) && value instanceof  UpdateAction;
1071:                }
1072:
1073:                /**
1074:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1075:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
1076:                 *      java.util.Map)
1077:                 */
1078:                public void encode(Element element, Object value,
1079:                        PrintHandler output, Map hints) throws IOException,
1080:                        OperationNotSupportedException {
1081:                    if (!canEncode(element, value, hints)) {
1082:                        return;
1083:                    }
1084:
1085:                    UpdateAction a = (UpdateAction) value;
1086:
1087:                    AttributesImpl attributes = new AttributesImpl();
1088:                    attributes
1089:                            .addAttribute(WFSSchema.NAMESPACE.toString(),
1090:                                    attrs[1].getName(), null, "string", a
1091:                                            .getTypeName());
1092:
1093:                    output.startElement(element.getNamespace(), element
1094:                            .getName(), attributes);
1095:
1096:                    Object[] prop = new Object[2];
1097:                    String[] names = a.getPropertyNames();
1098:
1099:                    for (int i = 0; i < names.length; i++) {
1100:                        prop[0] = names[i];
1101:                        prop[1] = a.getProperty(names[i]);
1102:                        elems[0].getType()
1103:                                .encode(elems[0], prop, output, hints);
1104:                    }
1105:
1106:                    elems[1].getType().encode(elems[1], a.getFilter(), output,
1107:                            hints);
1108:
1109:                    output
1110:                            .endElement(element.getNamespace(), element
1111:                                    .getName());
1112:                }
1113:            }
1114:
1115:            static class DeleteElementType extends WFSComplexType {
1116:                // singleton instance
1117:                private static final WFSComplexType instance = new DeleteElementType();
1118:
1119:                //        <xsd:complexType name="DeleteElementType">
1120:                //	      <xsd:sequence>
1121:                //	         <xsd:element ref="ogc:Filter" minOccurs="1" maxOccurs="1">
1122:                //	            <xsd:annotation>
1123:                //	               <xsd:documentation>
1124:                //	                  The Filter element is used to constrain the scope
1125:                //	                  of the delete operation to those features identified
1126:                //	                  by the filter.  Feature instances can be specified
1127:                //	                  explicitly and individually using the identifier of
1128:                //	                  each feature instance OR a set of features to be
1129:                //	                  operated on can be identified by specifying spatial
1130:                //	                  and non-spatial constraints in the filter.
1131:                //	                  If no filter is specified then an exception should
1132:                //	                  be raised since it is unlikely that a client application
1133:                //	                  intends to delete all feature instances.
1134:                //	               </xsd:documentation>
1135:                //	            </xsd:annotation>
1136:                //	         </xsd:element>
1137:                //	      </xsd:sequence>
1138:                //	      <xsd:attribute name="handle" type="xsd:string" use="optional"/>
1139:                //	      <xsd:attribute name="typeName" type="xsd:QName" use="required"/>
1140:                //	   </xsd:complexType>
1141:                private static Element[] elems = new Element[] { new WFSElement(
1142:                        FilterSchema.getInstance().getElements()[2].getName(),
1143:                        FilterSchema.getInstance().getElements()[2].getType(),
1144:                        0, 1, false,
1145:                        FilterSchema.getInstance().getElements()[2]
1146:                                .getSubstitutionGroup()) {
1147:                    public URI getNamespace() {
1148:                        return FilterSchema.NAMESPACE;
1149:                    }
1150:                } };
1151:                private static Sequence child = new SequenceGT(elems);
1152:                private static Attribute[] attrs = new Attribute[] {
1153:                        new WFSAttribute("handler", XSISimpleTypes.String
1154:                                .getInstance(), Attribute.OPTIONAL),
1155:                        new WFSAttribute("typeName", XSISimpleTypes.QName
1156:                                .getInstance(), Attribute.REQUIRED), };
1157:
1158:                public static WFSComplexType getInstance() {
1159:                    return instance;
1160:                }
1161:
1162:                /**
1163:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
1164:                 */
1165:                public Attribute[] getAttributes() {
1166:                    return attrs;
1167:                }
1168:
1169:                /**
1170:                 * @see org.geotools.xml.schema.ComplexType#getChild()
1171:                 */
1172:                public ElementGrouping getChild() {
1173:                    return child;
1174:                }
1175:
1176:                /**
1177:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
1178:                 */
1179:                public Element[] getChildElements() {
1180:                    return elems;
1181:                }
1182:
1183:                /**
1184:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1185:                 *      org.geotools.xml.schema.ElementValue[],
1186:                 *      org.xml.sax.Attributes, java.util.Map)
1187:                 */
1188:                public Object getValue(Element element, ElementValue[] value,
1189:                        Attributes attrs1, Map hints) throws SAXException,
1190:                        SAXNotSupportedException {
1191:                    throw new SAXNotSupportedException("");
1192:                }
1193:
1194:                /**
1195:                 * @see org.geotools.xml.schema.Type#getName()
1196:                 */
1197:                public String getName() {
1198:                    return "DeleteElementType";
1199:                }
1200:
1201:                /**
1202:                 * @see org.geotools.xml.schema.Type#getInstanceType()
1203:                 */
1204:                public Class getInstanceType() {
1205:                    return DeleteAction.class;
1206:                }
1207:
1208:                /**
1209:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1210:                 *      java.lang.Object, java.util.Map)
1211:                 */
1212:                public boolean canEncode(Element element, Object value,
1213:                        Map hints) {
1214:                    return (element != null) && (element.getType() != null)
1215:                            && getName().equals(element.getType().getName())
1216:                            && (value != null) && value instanceof  DeleteAction;
1217:                }
1218:
1219:                /**
1220:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1221:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
1222:                 *      java.util.Map)
1223:                 */
1224:                public void encode(Element element, Object value,
1225:                        PrintHandler output, Map hints) throws IOException,
1226:                        OperationNotSupportedException {
1227:                    if (!canEncode(element, value, hints)) {
1228:                        return;
1229:                    }
1230:
1231:                    DeleteAction a = (DeleteAction) value;
1232:
1233:                    AttributesImpl attributes = new AttributesImpl();
1234:                    attributes
1235:                            .addAttribute(WFSSchema.NAMESPACE.toString(),
1236:                                    attrs[1].getName(), null, "string", a
1237:                                            .getTypeName());
1238:
1239:                    output.startElement(element.getNamespace(), element
1240:                            .getName(), attributes);
1241:
1242:                    elems[0].getType().encode(elems[0], a.getFilter(), output,
1243:                            hints);
1244:
1245:                    output
1246:                            .endElement(element.getNamespace(), element
1247:                                    .getName());
1248:                }
1249:            }
1250:
1251:            static class NativeType extends WFSComplexType {
1252:                // singleton instance
1253:                private static final WFSComplexType instance = new NativeType();
1254:
1255:                //        <xsd:complexType name="NativeType">
1256:                //	      <xsd:attribute name="vendorId" type="xsd:string" use="required">
1257:                //	         <xsd:annotation>
1258:                //	            <xsd:documentation>
1259:                //	               The vendorId attribute is used to specify the name of
1260:                //	               vendor who's vendor specific command the client
1261:                //	               application wishes to execute.
1262:                //	            </xsd:documentation>
1263:                //	         </xsd:annotation>
1264:                //	      </xsd:attribute>
1265:                //	      <xsd:attribute name="safeToIgnore" type="xsd:boolean" use="required">
1266:                //	         <xsd:annotation>
1267:                //	            <xsd:documentation>
1268:                //	               In the event that a Web Feature Service does not recognize
1269:                //	               the vendorId or does not recognize the vendor specific command,
1270:                //	               the safeToIgnore attribute is used to indicate whether the 
1271:                //	               exception can be safely ignored.  A value of TRUE means that
1272:                //	               the Web Feature Service may ignore the command.  A value of
1273:                //	               FALSE means that a Web Feature Service cannot ignore the
1274:                //	               command and an exception should be raised if a problem is 
1275:                //	               encountered.
1276:                //	            </xsd:documentation>
1277:                //	         </xsd:annotation>
1278:                //	      </xsd:attribute>
1279:                //	   </xsd:complexType>
1280:                private static Attribute[] attrs = new Attribute[] {
1281:                        new WFSAttribute("vendorId", XSISimpleTypes.String
1282:                                .getInstance(), Attribute.REQUIRED),
1283:                        new WFSAttribute("safeToIgnore", XSISimpleTypes.Boolean
1284:                                .getInstance(), Attribute.REQUIRED), };
1285:
1286:                public static WFSComplexType getInstance() {
1287:                    return instance;
1288:                }
1289:
1290:                /**
1291:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
1292:                 */
1293:                public Attribute[] getAttributes() {
1294:                    return attrs;
1295:                }
1296:
1297:                /**
1298:                 * @see org.geotools.xml.schema.ComplexType#getChild()
1299:                 */
1300:                public ElementGrouping getChild() {
1301:                    return null;
1302:                }
1303:
1304:                /**
1305:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
1306:                 */
1307:                public Element[] getChildElements() {
1308:                    return null;
1309:                }
1310:
1311:                /**
1312:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1313:                 *      org.geotools.xml.schema.ElementValue[],
1314:                 *      org.xml.sax.Attributes, java.util.Map)
1315:                 */
1316:                public Object getValue(Element element, ElementValue[] value,
1317:                        Attributes attrs1, Map hints) throws SAXException,
1318:                        SAXNotSupportedException {
1319:                    throw new SAXNotSupportedException("");
1320:                }
1321:
1322:                /**
1323:                 * @see org.geotools.xml.schema.Type#getName()
1324:                 */
1325:                public String getName() {
1326:                    return "NativeType";
1327:                }
1328:
1329:                /**
1330:                 * @see org.geotools.xml.schema.Type#getInstanceType()
1331:                 */
1332:                public Class getInstanceType() {
1333:                    return Action.class;
1334:                }
1335:
1336:                /**
1337:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1338:                 *      java.lang.Object, java.util.Map)
1339:                 */
1340:                public boolean canEncode(Element element, Object value,
1341:                        Map hints) {
1342:                    return (element != null) && (element.getType() != null)
1343:                            && getName().equals(element.getType().getName())
1344:                            && (value != null) && value instanceof  Action
1345:                            && (((Action) value).getType() == 0);
1346:                }
1347:
1348:                /**
1349:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1350:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
1351:                 *      java.util.Map)
1352:                 */
1353:                public void encode(Element element, Object value,
1354:                        PrintHandler output, Map hints) throws IOException {
1355:                    AttributesImpl attributes = new AttributesImpl();
1356:                    attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
1357:                            attrs[0].getName(), null, "string",
1358:                            "www.refractions.net");
1359:
1360:                    // TODO? force failures on unknown actions? allowing ignores here
1361:                    attributes.addAttribute(WFSSchema.NAMESPACE.toString(),
1362:                            attrs[1].getName(), null, "string", "true");
1363:
1364:                    output.element(element.getNamespace(), element.getName(),
1365:                            attributes);
1366:                }
1367:            }
1368:
1369:            static class PropertyType extends WFSComplexType {
1370:                // singleton instance
1371:                private static final WFSComplexType instance = new PropertyType();
1372:
1373:                //        <xsd:complexType name="PropertyType">
1374:                //	      <xsd:sequence>
1375:                //	         <xsd:element name="Name" type="xsd:string">
1376:                //	            <xsd:annotation>
1377:                //	               <xsd:documentation>
1378:                //	                  The Name element contains the name of a feature property
1379:                //	                  to be updated.
1380:                //	               </xsd:documentation>
1381:                //	            </xsd:annotation>
1382:                //	         </xsd:element>
1383:                //	         <xsd:element name="Value" minOccurs="0">
1384:                //	            <xsd:annotation>
1385:                //	               <xsd:documentation>
1386:                //	                  The Value element contains the replacement value for the
1387:                //	                  named property.
1388:                //	               </xsd:documentation>
1389:                //	            </xsd:annotation>
1390:                //	         </xsd:element>
1391:                //	      </xsd:sequence>
1392:                //	   </xsd:complexType>
1393:                private static Element[] elems = new Element[] {
1394:                        new WFSElement("Name", XSISimpleTypes.String
1395:                                .getInstance()),
1396:                        // TODO correctly represent the value element
1397:                        new WFSElement("Value", WFSEmptyType.getInstance(), 0,
1398:                                1, true, null) {
1399:                            public boolean isMixed() {
1400:                                return true;
1401:                            }
1402:                        }, };
1403:                private static Sequence child = new SequenceGT(elems);
1404:
1405:                public static WFSComplexType getInstance() {
1406:                    return instance;
1407:                }
1408:
1409:                /**
1410:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
1411:                 */
1412:                public Attribute[] getAttributes() {
1413:                    return null;
1414:                }
1415:
1416:                /**
1417:                 * @see org.geotools.xml.schema.ComplexType#getChild()
1418:                 */
1419:                public ElementGrouping getChild() {
1420:                    return child;
1421:                }
1422:
1423:                /**
1424:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
1425:                 */
1426:                public Element[] getChildElements() {
1427:                    return elems;
1428:                }
1429:
1430:                /**
1431:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1432:                 *      org.geotools.xml.schema.ElementValue[],
1433:                 *      org.xml.sax.Attributes, java.util.Map)
1434:                 */
1435:                public Object getValue(Element element, ElementValue[] value,
1436:                        Attributes attrs, Map hints) throws SAXException,
1437:                        SAXNotSupportedException {
1438:                    throw new SAXNotSupportedException("");
1439:                }
1440:
1441:                /**
1442:                 * @see org.geotools.xml.schema.Type#getName()
1443:                 */
1444:                public String getName() {
1445:                    return "PropertyType";
1446:                }
1447:
1448:                /**
1449:                 * @see org.geotools.xml.schema.Type#getInstanceType()
1450:                 */
1451:                public Class getInstanceType() {
1452:                    return Object[].class;
1453:                }
1454:
1455:                /**
1456:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1457:                 *      java.lang.Object, java.util.Map)
1458:                 */
1459:                public boolean canEncode(Element element, Object value,
1460:                        Map hints) {
1461:                    return (element != null) && (element.getType() != null)
1462:                            && getName().equals(element.getType().getName())
1463:                            && (value != null) && value instanceof  Object[]
1464:                            && (((Object[]) value).length == 2);
1465:                }
1466:
1467:                /**
1468:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1469:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
1470:                 *      java.util.Map)
1471:                 */
1472:                public void encode(Element element, Object value,
1473:                        PrintHandler output, Map hints) throws IOException,
1474:                        OperationNotSupportedException {
1475:                    if (!canEncode(element, value, hints)) {
1476:                        throw new OperationNotSupportedException(
1477:                                "Cannot encode " + element + " in PropertyType");
1478:                    }
1479:
1480:                    Object[] t = (Object[]) value;
1481:                    output.startElement(element.getNamespace(), element
1482:                            .getName(), null);
1483:
1484:                    elems[0].getType().encode(elems[0], t[0], output, hints);
1485:
1486:                    if (t[1] != null) {
1487:                        //                elems[1].getType().encode(elems[1], t[1], output, hints);
1488:
1489:                        // can only be a primative, geometry or feature for version 2.0
1490:                        // in the future use output.findElement(t[1]) ... posibly with a newer search order
1491:                        output.startElement(elems[1].getNamespace(), elems[1]
1492:                                .getName(), null);
1493:                        if (t[1] instanceof  Feature) {
1494:                            // Feature
1495:                            GMLSchema.getInstance().getElements()[0].getType()
1496:                                    .encode(
1497:                                            GMLSchema.getInstance()
1498:                                                    .getElements()[0], t[1],
1499:                                            output, hints);
1500:                        } else {
1501:                            if (t[1] instanceof  Geometry) {
1502:                                // Geometry
1503:                                GMLSchema.getInstance().getElements()[29]
1504:                                        .getType().encode(
1505:                                                GMLSchema.getInstance()
1506:                                                        .getElements()[0],
1507:                                                t[1], output, hints);
1508:                            } else {
1509:                                // primative
1510:                                output.characters(t[1].toString());
1511:                            }
1512:                        }
1513:                        output.endElement(elems[1].getNamespace(), elems[1]
1514:                                .getName());
1515:                    }
1516:
1517:                    output
1518:                            .endElement(element.getNamespace(), element
1519:                                    .getName());
1520:                }
1521:            }
1522:
1523:            static class WFS_LockFeatureResponseType extends WFSComplexType {
1524:                // singleton instance
1525:                private static final WFSComplexType instance = new WFS_LockFeatureResponseType();
1526:
1527:                //        <xsd:complexType name="WFS_LockFeatureResponseType">
1528:                //	      <xsd:annotation>
1529:                //	         <xsd:documentation>
1530:                //	            The WFS_LockFeatureResponseType is used to define an
1531:                //	            element to contains the response to a LockFeature
1532:                //	            operation.
1533:                //	         </xsd:documentation>
1534:                //	      </xsd:annotation>
1535:                //	      <xsd:sequence>
1536:                //	         <xsd:element ref="wfs:LockId">
1537:                //	            <xsd:annotation>
1538:                //	               <xsd:documentation>
1539:                //	                  The WFS_LockFeatureResponse includes a LockId element
1540:                //	                  that contains a lock identifier.  The lock identifier
1541:                //	                  can be used by a client, in subsequent operations, to
1542:                //	                  operate upon the locked feature instances.
1543:                //	               </xsd:documentation>
1544:                //	            </xsd:annotation>
1545:                //	         </xsd:element>
1546:                //	         <xsd:element name="FeaturesLocked"
1547:                //	                      type="wfs:FeaturesLockedType" minOccurs="0">
1548:                //	            <xsd:annotation>
1549:                //	               <xsd:documentation>
1550:                //	                  The LockFeature or GetFeatureWithLock operations
1551:                //	                  identify and attempt to lock a set of feature 
1552:                //	                  instances that satisfy the constraints specified 
1553:                //	                  in the request.  In the event that the lockAction
1554:                //	                  attribute (on the LockFeature or GetFeatureWithLock
1555:                //	                  elements) is set to SOME, a Web Feature Service will
1556:                //	                  attempt to lock as many of the feature instances from
1557:                //	                  the result set as possible.
1558:                //
1559:                //	                  The FeaturesLocked element contains list of ogc:FeatureId
1560:                //	                  elements enumerating the feature instances that a WFS
1561:                //	                  actually managed to lock.
1562:                //	               </xsd:documentation>
1563:                //	            </xsd:annotation>
1564:                //	         </xsd:element>
1565:                //	         <xsd:element name="FeaturesNotLocked"
1566:                //	                      type="wfs:FeaturesNotLockedType" minOccurs="0">
1567:                //	            <xsd:annotation>
1568:                //	               <xsd:documentation>
1569:                //	                  In contrast to the FeaturesLocked element, the
1570:                //	                  FeaturesNotLocked element contains a list of 
1571:                //	                  ogc:Filter elements identifying feature instances
1572:                //	                  that a WFS did not manage to lock because they were
1573:                //	                  already locked by another process.
1574:                //	               </xsd:documentation>
1575:                //	            </xsd:annotation>
1576:                //	         </xsd:element>
1577:                //	      </xsd:sequence>
1578:                //	   </xsd:complexType>
1579:                private static Element[] elems = new Element[] {
1580:                        new WFSElement("LockId", XSISimpleTypes.String
1581:                                .getInstance()),
1582:                        new WFSElement("FeaturesLocked", FeaturesLockedType
1583:                                .getInstance(), 0, 1, true, null),
1584:                        new WFSElement("FeaturesNotLocked",
1585:                                FeaturesNotLockedType.getInstance(), 0, 1,
1586:                                true, null) };
1587:                private static Sequence child = new SequenceGT(elems);
1588:
1589:                public static WFSComplexType getInstance() {
1590:                    return instance;
1591:                }
1592:
1593:                /**
1594:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
1595:                 */
1596:                public Attribute[] getAttributes() {
1597:                    return null;
1598:                }
1599:
1600:                /**
1601:                 * @see org.geotools.xml.schema.ComplexType#getChild()
1602:                 */
1603:                public ElementGrouping getChild() {
1604:                    return child;
1605:                }
1606:
1607:                /**
1608:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
1609:                 */
1610:                public Element[] getChildElements() {
1611:                    return elems;
1612:                }
1613:
1614:                /**
1615:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1616:                 *      org.geotools.xml.schema.ElementValue[],
1617:                 *      org.xml.sax.Attributes, java.util.Map)
1618:                 */
1619:                public Object getValue(Element element, ElementValue[] value,
1620:                        Attributes attrs, Map hints) throws SAXException,
1621:                        SAXNotSupportedException {
1622:                    if ((element == null) || (value == null)
1623:                            || (element.getType() == null)) {
1624:                        throw new SAXException(
1625:                                "Invalid parameters : null found");
1626:                    }
1627:
1628:                    if ((value.length < 1) || (value.length > 3)) {
1629:                        throw new SAXException(
1630:                                "Invalid children: too few or too many");
1631:                    }
1632:
1633:                    if (!getName().equals(element.getType().getName())) {
1634:                        throw new SAXException(
1635:                                "Invalid type name for element provided");
1636:                    }
1637:
1638:                    String lockId = (String) value[0].getValue();
1639:                    FidFilter in = null;
1640:                    FidFilter out = null;
1641:                    int i = 1;
1642:
1643:                    if ((i < value.length)
1644:                            && elems[1].getType().getName().equals(
1645:                                    value[i].getElement().getType().getName())) {
1646:                        in = (FidFilter) value[i++];
1647:                    }
1648:
1649:                    if ((i < value.length)
1650:                            && elems[2].getType().getName().equals(
1651:                                    value[i].getElement().getType().getName())) {
1652:                        out = (FidFilter) value[i++];
1653:                    }
1654:
1655:                    return new LockResult(lockId, in, out);
1656:                }
1657:
1658:                /**
1659:                 * @see org.geotools.xml.schema.Type#getName()
1660:                 */
1661:                public String getName() {
1662:                    return "WFS_LockFeatureResponseType";
1663:                }
1664:
1665:                /**
1666:                 * @see org.geotools.xml.schema.Type#getInstanceType()
1667:                 */
1668:                public Class getInstanceType() {
1669:                    return LockResult.class;
1670:                }
1671:
1672:                /**
1673:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1674:                 *      java.lang.Object, java.util.Map)
1675:                 */
1676:                public boolean canEncode(Element element, Object value,
1677:                        Map hints) {
1678:                    return false;
1679:                }
1680:
1681:                /**
1682:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1683:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
1684:                 *      java.util.Map)
1685:                 */
1686:                public void encode(Element element, Object value,
1687:                        PrintHandler output, Map hints)
1688:                        throws OperationNotSupportedException {
1689:                    throw new OperationNotSupportedException();
1690:                }
1691:            }
1692:
1693:            static class FeaturesLockedType extends WFSComplexType {
1694:                // singleton instance
1695:                private static final WFSComplexType instance = new FeaturesLockedType();
1696:
1697:                //     <xsd:complexType name="FeaturesLockedType">
1698:                //	     <xsd:sequence maxOccurs="unbounded">
1699:                //	       <xsd:element ref="ogc:FeatureId"/>
1700:                //	     </xsd:sequence>
1701:                //	   </xsd:complexType>
1702:                private static Element[] elems = new Element[] { FilterSchema
1703:                        .getInstance().getElements()[1], };
1704:                private static Sequence child = new SequenceGT(null, elems, 1,
1705:                        Integer.MAX_VALUE);
1706:
1707:                public static WFSComplexType getInstance() {
1708:                    return instance;
1709:                }
1710:
1711:                /**
1712:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
1713:                 */
1714:                public Attribute[] getAttributes() {
1715:                    return null;
1716:                }
1717:
1718:                /**
1719:                 * @see org.geotools.xml.schema.ComplexType#getChild()
1720:                 */
1721:                public ElementGrouping getChild() {
1722:                    return child;
1723:                }
1724:
1725:                /**
1726:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
1727:                 */
1728:                public Element[] getChildElements() {
1729:                    return elems;
1730:                }
1731:
1732:                /**
1733:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1734:                 *      org.geotools.xml.schema.ElementValue[],
1735:                 *      org.xml.sax.Attributes, java.util.Map)
1736:                 */
1737:                public Object getValue(Element element, ElementValue[] value,
1738:                        Attributes attrs, Map hints) throws SAXException,
1739:                        SAXNotSupportedException {
1740:                    if ((element == null) || (value == null)
1741:                            || (element.getType() == null)) {
1742:                        throw new SAXException(
1743:                                "Invalid parameters : null found");
1744:                    }
1745:
1746:                    if (value.length < 1) {
1747:                        throw new SAXException("Invalid children: too few");
1748:                    }
1749:
1750:                    if (!getName().equals(element.getType().getName())) {
1751:                        throw new SAXException(
1752:                                "Invalid type name for element provided");
1753:                    }
1754:
1755:                    Set fidSet = new HashSet();
1756:
1757:                    for (int i = 0; i < value.length; i++)
1758:                        fidSet.addAll(Arrays.asList(((FidFilter) value[i]
1759:                                .getValue()).getFids()));
1760:
1761:                    FidFilter r = FilterFactoryFinder.createFilterFactory()
1762:                            .createFidFilter();
1763:                    r.addAllFids(fidSet);
1764:
1765:                    return r;
1766:                }
1767:
1768:                /**
1769:                 * @see org.geotools.xml.schema.Type#getName()
1770:                 */
1771:                public String getName() {
1772:                    return "FeaturesLockedType";
1773:                }
1774:
1775:                /**
1776:                 * @see org.geotools.xml.schema.Type#getInstanceType()
1777:                 */
1778:                public Class getInstanceType() {
1779:                    return FidFilter.class;
1780:                }
1781:
1782:                /**
1783:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1784:                 *      java.lang.Object, java.util.Map)
1785:                 */
1786:                public boolean canEncode(Element element, Object value,
1787:                        Map hints) {
1788:                    return false;
1789:                }
1790:
1791:                /**
1792:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1793:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
1794:                 *      java.util.Map)
1795:                 */
1796:                public void encode(Element element, Object value,
1797:                        PrintHandler output, Map hints)
1798:                        throws OperationNotSupportedException {
1799:                    throw new OperationNotSupportedException();
1800:                }
1801:            }
1802:
1803:            static class FeaturesNotLockedType extends WFSComplexType {
1804:                // singleton instance
1805:                private static final WFSComplexType instance = new FeaturesNotLockedType();
1806:
1807:                //        <xsd:complexType name="FeaturesNotLockedType">
1808:                //	     <xsd:sequence maxOccurs="unbounded">
1809:                //	       <xsd:element ref="ogc:FeatureId"/>
1810:                //	     </xsd:sequence>
1811:                //	   </xsd:complexType>
1812:                private static Element[] elems = new Element[] { FilterSchema
1813:                        .getInstance().getElements()[1], };
1814:                private static Sequence child = new SequenceGT(null, elems, 1,
1815:                        Integer.MAX_VALUE);
1816:
1817:                public static WFSComplexType getInstance() {
1818:                    return instance;
1819:                }
1820:
1821:                /**
1822:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
1823:                 */
1824:                public Attribute[] getAttributes() {
1825:                    return null;
1826:                }
1827:
1828:                /**
1829:                 * @see org.geotools.xml.schema.ComplexType#getChild()
1830:                 */
1831:                public ElementGrouping getChild() {
1832:                    return child;
1833:                }
1834:
1835:                /**
1836:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
1837:                 */
1838:                public Element[] getChildElements() {
1839:                    return elems;
1840:                }
1841:
1842:                /**
1843:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1844:                 *      org.geotools.xml.schema.ElementValue[],
1845:                 *      org.xml.sax.Attributes, java.util.Map)
1846:                 */
1847:                public Object getValue(Element element, ElementValue[] value,
1848:                        Attributes attrs, Map hints) throws SAXException,
1849:                        SAXNotSupportedException {
1850:                    if ((element == null) || (value == null)
1851:                            || (element.getType() == null)) {
1852:                        throw new SAXException(
1853:                                "Invalid parameters : null found");
1854:                    }
1855:
1856:                    if (value.length < 1) {
1857:                        throw new SAXException("Invalid children: too few");
1858:                    }
1859:
1860:                    if (!getName().equals(element.getType().getName())) {
1861:                        throw new SAXException(
1862:                                "Invalid type name for element provided");
1863:                    }
1864:
1865:                    Set fidSet = new HashSet();
1866:
1867:                    for (int i = 0; i < value.length; i++)
1868:                        fidSet.addAll(Arrays.asList(((FidFilter) value[i]
1869:                                .getValue()).getFids()));
1870:
1871:                    FidFilter r = FilterFactoryFinder.createFilterFactory()
1872:                            .createFidFilter();
1873:                    r.addAllFids(fidSet);
1874:
1875:                    return r;
1876:                }
1877:
1878:                /**
1879:                 * @see org.geotools.xml.schema.Type#getName()
1880:                 */
1881:                public String getName() {
1882:                    return "FeaturesNotLockedType";
1883:                }
1884:
1885:                /**
1886:                 * @see org.geotools.xml.schema.Type#getInstanceType()
1887:                 */
1888:                public Class getInstanceType() {
1889:                    return FidFilter.class;
1890:                }
1891:
1892:                /**
1893:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1894:                 *      java.lang.Object, java.util.Map)
1895:                 */
1896:                public boolean canEncode(Element element, Object value,
1897:                        Map hints) {
1898:                    return false;
1899:                }
1900:
1901:                /**
1902:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1903:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
1904:                 *      java.util.Map)
1905:                 */
1906:                public void encode(Element element, Object value,
1907:                        PrintHandler output, Map hints)
1908:                        throws OperationNotSupportedException {
1909:                    throw new OperationNotSupportedException();
1910:                }
1911:            }
1912:
1913:            static class WFS_TransactionResponseType extends WFSComplexType {
1914:                // singleton instance
1915:                private static final WFSComplexType instance = new WFS_TransactionResponseType();
1916:
1917:                //        <xsd:complexType name="WFS_TransactionResponseType">
1918:                //	      <xsd:annotation>
1919:                //	         <xsd:documentation>
1920:                //	            The WFS_TransactionResponseType defines the format of
1921:                //	            the XML document that a Web Feature Service generates 
1922:                //	            in response to a Transaction request.  The response 
1923:                //	            includes the completion status of the transaction 
1924:                //	            and the feature identifiers of any newly created
1925:                //	            feature instances.
1926:                //	         </xsd:documentation>
1927:                //	      </xsd:annotation>
1928:                //	      <xsd:sequence>
1929:                //	         <xsd:element name="InsertResult"
1930:                //	                      type="wfs:InsertResultType"
1931:                //	                      minOccurs="0" maxOccurs="unbounded">
1932:                //	            <xsd:annotation>
1933:                //	               <xsd:documentation>
1934:                //	                  The InsertResult element contains a list of ogc:FeatureId
1935:                //	                  elements that identify any newly created feature instances.
1936:                //	               </xsd:documentation>
1937:                //	            </xsd:annotation>
1938:                //	         </xsd:element>
1939:                //	         <xsd:element name="TransactionResult"
1940:                //	                      type="wfs:TransactionResultType">
1941:                //	            <xsd:annotation>
1942:                //	               <xsd:documentation>
1943:                //	                  The TransactionResult element contains a Status element
1944:                //	                  indicating the completion status of a transaction.  In
1945:                //	                  the event that the transaction fails, additional element
1946:                //	                  may be included to help locate which part of the transaction
1947:                //	                  failed and why.
1948:                //	               </xsd:documentation>
1949:                //	            </xsd:annotation>
1950:                //	         </xsd:element>
1951:                //	      </xsd:sequence>
1952:                //	      <xsd:attribute name="version"
1953:                //	                     type="xsd:string" use="required" fixed="1.0.0"/>
1954:                //	   </xsd:complexType>
1955:                private static Element[] elems = new Element[] {
1956:                        new WFSElement("InsertResult", InsertResultType
1957:                                .getInstance(), 0, Integer.MAX_VALUE, true,
1958:                                null),
1959:                        new WFSElement("TransactionResult",
1960:                                TransactionResultType.getInstance()), };
1961:                private static Sequence child = new SequenceGT(elems);
1962:                private static Attribute[] attrs = new Attribute[] { new WFSAttribute(
1963:                        "version", XSISimpleTypes.String.getInstance(),
1964:                        Attribute.REQUIRED) {
1965:                    public String getFixed() {
1966:                        return "1.0.0";
1967:                    }
1968:                }, };
1969:
1970:                public static WFSComplexType getInstance() {
1971:                    return instance;
1972:                }
1973:
1974:                /**
1975:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
1976:                 */
1977:                public Attribute[] getAttributes() {
1978:                    return attrs;
1979:                }
1980:
1981:                /**
1982:                 * @see org.geotools.xml.schema.ComplexType#getChild()
1983:                 */
1984:                public ElementGrouping getChild() {
1985:                    return child;
1986:                }
1987:
1988:                /**
1989:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
1990:                 */
1991:                public Element[] getChildElements() {
1992:                    return elems;
1993:                }
1994:
1995:                /**
1996:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1997:                 *      org.geotools.xml.schema.ElementValue[],
1998:                 *      org.xml.sax.Attributes, java.util.Map)
1999:                 */
2000:                public Object getValue(Element element, ElementValue[] value,
2001:                        Attributes attrs1, Map hints) throws SAXException,
2002:                        SAXNotSupportedException {
2003:                    if ((element == null) || (value == null)
2004:                            || (element.getType() == null)) {
2005:                        throw new SAXException(
2006:                                "Invalid parameters : null found");
2007:                    }
2008:
2009:                    if (value.length < 1) {
2010:                        throw new SAXException("Invalid children: too few");
2011:                    }
2012:
2013:                    if (!getName().equals(element.getType().getName())) {
2014:                        throw new SAXException(
2015:                                "Invalid type name for element provided");
2016:                    }
2017:
2018:                    List fidSet = new ArrayList();
2019:
2020:                    for (int i = 0; i < (value.length - 1); i++)
2021:                        fidSet.addAll((Collection) value[i].getValue());
2022:
2023:                    Object[] t = (Object[]) value[value.length - 1].getValue();
2024:                    int status = ((Integer) t[0]).intValue();
2025:                    SAXException error = (SAXException) ((t.length < 2) ? null
2026:                            : t[1]);
2027:
2028:                    return new TransactionResult(status, fidSet, error);
2029:                }
2030:
2031:                /**
2032:                 * @see org.geotools.xml.schema.Type#getName()
2033:                 */
2034:                public String getName() {
2035:                    return "WFS_TransactionResponseType";
2036:                }
2037:
2038:                /**
2039:                 * @see org.geotools.xml.schema.Type#getInstanceType()
2040:                 */
2041:                public Class getInstanceType() {
2042:                    return TransactionResult.class;
2043:                }
2044:
2045:                /**
2046:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
2047:                 *      java.lang.Object, java.util.Map)
2048:                 */
2049:                public boolean canEncode(Element element, Object value,
2050:                        Map hints) {
2051:                    return false;
2052:                }
2053:
2054:                /**
2055:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
2056:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
2057:                 *      java.util.Map)
2058:                 */
2059:                public void encode(Element element, Object value,
2060:                        PrintHandler output, Map hints)
2061:                        throws OperationNotSupportedException {
2062:                    throw new OperationNotSupportedException();
2063:                }
2064:            }
2065:
2066:            static class TransactionResultType extends WFSComplexType {
2067:                // singleton instance
2068:                private static final WFSComplexType instance = new TransactionResultType();
2069:
2070:                //        <xsd:complexType name="TransactionResultType">
2071:                //	      <xsd:sequence>
2072:                //	         <xsd:element name="Status" type="wfs:StatusType">
2073:                //	            <xsd:annotation>
2074:                //	               <xsd:documentation>
2075:                //	                  The Status element contains an element indicating the
2076:                //	                  completion status of a transaction.  The SUCCESS element
2077:                //	                  is used to indicate successful completion.  The FAILED
2078:                //	                  element is used to indicate that an exception was 
2079:                //	                  encountered.
2080:                //	               </xsd:documentation>
2081:                //	            </xsd:annotation>
2082:                //	         </xsd:element>
2083:                //	         <xsd:element name="Locator" type="xsd:string" minOccurs="0">
2084:                //	            <xsd:annotation>
2085:                //	               <xsd:documentation>
2086:                //	                  In the event that an exception was encountered while 
2087:                //	                  processing a transaction, a Web Feature Service may
2088:                //	                  use the Locator element to try and identify the part
2089:                //	                  of the transaction that failed.  If the element(s)
2090:                //	                  contained in a Transaction element included a handle
2091:                //	                  attribute, then a Web Feature Service may report the
2092:                //	                  handle to identify the offending element.
2093:                //	               </xsd:documentation>
2094:                //	            </xsd:annotation>
2095:                //	         </xsd:element>
2096:                //	         <xsd:element name="Message" type="xsd:string" minOccurs="0">
2097:                //	            <xsd:annotation>
2098:                //	               <xsd:documentation>
2099:                //	                  The Message element may contain an exception report
2100:                //	                  generated by a Web Feature Service when an exception
2101:                //	                  is encountered.
2102:                //	               </xsd:documentation>
2103:                //	            </xsd:annotation>
2104:                //	         </xsd:element>
2105:                //	      </xsd:sequence>
2106:                //	      <xsd:attribute name="handle" type="xsd:string" use="optional"/>
2107:                //	   </xsd:complexType>
2108:                private static Element[] elems = new Element[] {
2109:                        new WFSElement("Status", StatusType.getInstance()),
2110:                        new WFSElement("Locator", XSISimpleTypes.String
2111:                                .getInstance(), 0, 1, true, null),
2112:                        new WFSElement("Message", XSISimpleTypes.String
2113:                                .getInstance(), 0, 1, true, null) };
2114:                private static Sequence child = new SequenceGT(elems);
2115:                private static Attribute[] attrs = new Attribute[] { new WFSAttribute(
2116:                        "handle", XSISimpleTypes.String.getInstance(),
2117:                        Attribute.OPTIONAL), };
2118:
2119:                public static WFSComplexType getInstance() {
2120:                    return instance;
2121:                }
2122:
2123:                /**
2124:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
2125:                 */
2126:                public Attribute[] getAttributes() {
2127:                    return attrs;
2128:                }
2129:
2130:                /**
2131:                 * @see org.geotools.xml.schema.ComplexType#getChild()
2132:                 */
2133:                public ElementGrouping getChild() {
2134:                    return child;
2135:                }
2136:
2137:                /**
2138:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
2139:                 */
2140:                public Element[] getChildElements() {
2141:                    return elems;
2142:                }
2143:
2144:                /**
2145:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
2146:                 *      org.geotools.xml.schema.ElementValue[],
2147:                 *      org.xml.sax.Attributes, java.util.Map)
2148:                 */
2149:                public Object getValue(Element element, ElementValue[] value,
2150:                        Attributes attrs1, Map hints) throws SAXException,
2151:                        SAXNotSupportedException {
2152:                    if ((element == null) || (value == null)
2153:                            || (element.getType() == null)) {
2154:                        throw new SAXException(
2155:                                "Invalid parameters : null found");
2156:                    }
2157:
2158:                    if (value.length < 1) {
2159:                        throw new SAXException("Invalid children: too few");
2160:                    }
2161:
2162:                    if (!getName().equals(element.getType().getName())) {
2163:                        throw new SAXException(
2164:                                "Invalid type name for element provided");
2165:                    }
2166:
2167:                    Object[] t = new Object[2];
2168:
2169:                    t[0] = value[0].getValue();
2170:
2171:                    String locator = null;
2172:                    String message = null;
2173:
2174:                    if (value.length > 1) {
2175:                        if ((value[1].getElement() != null)
2176:                                && elems[1].getName().equals(
2177:                                        value[1].getElement().getName())) {
2178:                            locator = (String) value[1].getValue();
2179:
2180:                            if ((value[2].getElement() != null)
2181:                                    && elems[2].getName().equals(
2182:                                            value[2].getElement().getName())) {
2183:                                message = (String) value[2].getValue();
2184:                            }
2185:                        } else {
2186:                            if ((value[1].getElement() != null)
2187:                                    && elems[2].getName().equals(
2188:                                            value[1].getElement().getName())) {
2189:                                message = (String) value[1].getValue();
2190:                            }
2191:                        }
2192:                    }
2193:
2194:                    t[1] = (message == null) ? ((locator == null) ? null
2195:                            : new SAXException(locator))
2196:                            : ((locator == null) ? new SAXException(message)
2197:                                    : new SAXException(message + ":" + locator));
2198:
2199:                    return t;
2200:                }
2201:
2202:                /**
2203:                 * @see org.geotools.xml.schema.Type#getName()
2204:                 */
2205:                public String getName() {
2206:                    return "TransactionResultType";
2207:                }
2208:
2209:                /**
2210:                 * @see org.geotools.xml.schema.Type#getInstanceType()
2211:                 */
2212:                public Class getInstanceType() {
2213:                    // [int][SAXException]
2214:                    return Object[].class;
2215:                }
2216:
2217:                /**
2218:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
2219:                 *      java.lang.Object, java.util.Map)
2220:                 */
2221:                public boolean canEncode(Element element, Object value,
2222:                        Map hints) {
2223:                    return false;
2224:                }
2225:
2226:                /**
2227:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
2228:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
2229:                 *      java.util.Map)
2230:                 */
2231:                public void encode(Element element, Object value,
2232:                        PrintHandler output, Map hints)
2233:                        throws OperationNotSupportedException {
2234:                    throw new OperationNotSupportedException();
2235:                }
2236:            }
2237:
2238:            static class InsertResultType extends WFSComplexType {
2239:                // singleton instance
2240:                private static final WFSComplexType instance = new InsertResultType();
2241:
2242:                //        <xsd:complexType name="InsertResultType">
2243:                //	      <xsd:sequence>
2244:                //	         <xsd:element ref="ogc:FeatureId" maxOccurs="unbounded"/>
2245:                //	      </xsd:sequence>
2246:                //	      <xsd:attribute name="handle" type="xsd:string" use="optional"/>
2247:                //	   </xsd:complexType>
2248:                private static Element[] elems = new Element[] { new FilterElement(
2249:                        FilterSchema.getInstance().getElements()[1].getName(),
2250:                        FilterSchema.getInstance().getElements()[1].getType(),
2251:                        FilterSchema.getInstance().getElements()[1]
2252:                                .getSubstitutionGroup()) {
2253:                    public int getMaxOccurs() {
2254:                        return Integer.MAX_VALUE;
2255:                    }
2256:                }, };
2257:                private static Sequence child = new SequenceGT(null, elems, 1,
2258:                        Integer.MAX_VALUE);
2259:                private static Attribute[] attrs = new Attribute[] { new WFSAttribute(
2260:                        "handle", XSISimpleTypes.String.getInstance(),
2261:                        Attribute.OPTIONAL), };
2262:
2263:                public static WFSComplexType getInstance() {
2264:                    return instance;
2265:                }
2266:
2267:                /**
2268:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
2269:                 */
2270:                public Attribute[] getAttributes() {
2271:                    return attrs;
2272:                }
2273:
2274:                /**
2275:                 * @see org.geotools.xml.schema.ComplexType#getChild()
2276:                 */
2277:                public ElementGrouping getChild() {
2278:                    return child;
2279:                }
2280:
2281:                /**
2282:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
2283:                 */
2284:                public Element[] getChildElements() {
2285:                    return elems;
2286:                }
2287:
2288:                /**
2289:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
2290:                 *      org.geotools.xml.schema.ElementValue[],
2291:                 *      org.xml.sax.Attributes, java.util.Map)
2292:                 */
2293:                public Object getValue(Element element, ElementValue[] value,
2294:                        Attributes attrs1, Map hints) throws SAXException,
2295:                        SAXNotSupportedException {
2296:                    if ((element == null) || (value == null)
2297:                            || (element.getType() == null)) {
2298:                        throw new SAXException(
2299:                                "Invalid parameters : null found");
2300:                    }
2301:
2302:                    if (value.length < 1) {
2303:                        throw new SAXException("Invalid children: too few");
2304:                    }
2305:
2306:                    if (!getName().equals(element.getType().getName())) {
2307:                        throw new SAXException(
2308:                                "Invalid type name for element provided");
2309:                    }
2310:
2311:                    List fidList = new ArrayList();
2312:
2313:                    for (int i = 0; i < value.length; i++)
2314:                        fidList.addAll(Arrays.asList(((FidFilter) value[i]
2315:                                .getValue()).getFids()));
2316:
2317:                    return fidList;
2318:                }
2319:
2320:                /**
2321:                 * @see org.geotools.xml.schema.Type#getName()
2322:                 */
2323:                public String getName() {
2324:                    return "InsertResultType";
2325:                }
2326:
2327:                /**
2328:                 * @see org.geotools.xml.schema.Type#getInstanceType()
2329:                 */
2330:                public Class getInstanceType() {
2331:                    return FidFilter.class;
2332:                }
2333:
2334:                /**
2335:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
2336:                 *      java.lang.Object, java.util.Map)
2337:                 */
2338:                public boolean canEncode(Element element, Object value,
2339:                        Map hints) {
2340:                    return false;
2341:                }
2342:
2343:                /**
2344:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
2345:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
2346:                 *      java.util.Map)
2347:                 */
2348:                public void encode(Element element, Object value,
2349:                        PrintHandler output, Map hints)
2350:                        throws OperationNotSupportedException {
2351:                    throw new OperationNotSupportedException();
2352:                }
2353:            }
2354:
2355:            static class StatusType extends WFSComplexType {
2356:                // singleton instance
2357:                private static final WFSComplexType instance = new StatusType();
2358:
2359:                //        <xsd:complexType name="StatusType">
2360:                //	      <xsd:choice>
2361:                //	         <xsd:element ref="wfs:SUCCESS"/>
2362:                //	         <xsd:element ref="wfs:FAILED"/>
2363:                //	         <xsd:element ref="wfs:PARTIAL"/>
2364:                //	      </xsd:choice>
2365:                //	   </xsd:complexType>
2366:                private static Element[] elems = new Element[] {
2367:                        new WFSElement("SUCCESS", WFSEmptyType.getInstance()),
2368:                        new WFSElement("FAILED", WFSEmptyType.getInstance()),
2369:                        new WFSElement("FAILED", WFSEmptyType.getInstance()), };
2370:                private static Choice child = new ChoiceGT(elems);
2371:
2372:                public static WFSComplexType getInstance() {
2373:                    return instance;
2374:                }
2375:
2376:                /**
2377:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
2378:                 */
2379:                public Attribute[] getAttributes() {
2380:                    return null;
2381:                }
2382:
2383:                /**
2384:                 * @see org.geotools.xml.schema.ComplexType#getChild()
2385:                 */
2386:                public ElementGrouping getChild() {
2387:                    return child;
2388:                }
2389:
2390:                /**
2391:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
2392:                 */
2393:                public Element[] getChildElements() {
2394:                    return elems;
2395:                }
2396:
2397:                /**
2398:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
2399:                 *      org.geotools.xml.schema.ElementValue[],
2400:                 *      org.xml.sax.Attributes, java.util.Map)
2401:                 */
2402:                public Object getValue(Element element, ElementValue[] value,
2403:                        Attributes attrs, Map hints) throws SAXException,
2404:                        SAXNotSupportedException {
2405:                    if ((element == null) || (value == null)
2406:                            || (element.getType() == null)) {
2407:                        throw new SAXException(
2408:                                "Invalid parameters : null found");
2409:                    }
2410:
2411:                    if ((value.length < 1) || (value.length > 1)) {
2412:                        throw new SAXException(
2413:                                "Invalid children: too few or too many");
2414:                    }
2415:
2416:                    if (!getName().equals(element.getType().getName())) {
2417:                        throw new SAXException(
2418:                                "Invalid type name for element provided");
2419:                    }
2420:
2421:                    if ((value[0].getElement() == null)
2422:                            || (value[0].getElement().getName() == null)) {
2423:                        throw new SAXException(
2424:                                "Invalid child element: no name was provided");
2425:                    }
2426:
2427:                    return new Integer(TransactionResult.parseStatus(value[0]
2428:                            .getElement().getName()));
2429:                }
2430:
2431:                /**
2432:                 * @see org.geotools.xml.schema.Type#getName()
2433:                 */
2434:                public String getName() {
2435:                    return "StatusType";
2436:                }
2437:
2438:                /**
2439:                 * @see org.geotools.xml.schema.Type#getInstanceType()
2440:                 */
2441:                public Class getInstanceType() {
2442:                    return Integer.class;
2443:                }
2444:
2445:                /**
2446:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
2447:                 *      java.lang.Object, java.util.Map)
2448:                 */
2449:                public boolean canEncode(Element element, Object value,
2450:                        Map hints) {
2451:                    return false;
2452:                }
2453:
2454:                /**
2455:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
2456:                 *      java.lang.Object, org.geotools.xml.PrintHandler,
2457:                 *      java.util.Map)
2458:                 */
2459:                public void encode(Element element, Object value,
2460:                        PrintHandler output, Map hints)
2461:                        throws OperationNotSupportedException {
2462:                    throw new OperationNotSupportedException();
2463:                }
2464:            }
2465:
2466:            private static class WFSEmptyType extends WFSComplexType {
2467:                private static WFSComplexType instance = new WFSEmptyType();
2468:
2469:                public static WFSComplexType getInstance() {
2470:                    return instance;
2471:                }
2472:
2473:                // 	   <xsd:complexType name="EmptyType"/>
2474:
2475:                /**
2476:                 * @see org.geotools.xml.schema.ComplexType#getAttributes()
2477:                 */
2478:                public Attribute[] getAttributes() {
2479:                    return null;
2480:                }
2481:
2482:                /**
2483:                 * @see org.geotools.xml.schema.ComplexType#getChild()
2484:                 */
2485:                public ElementGrouping getChild() {
2486:                    return null;
2487:                }
2488:
2489:                /**
2490:                 * @see org.geotools.xml.schema.ComplexType#getChildElements()
2491:                 */
2492:                public Element[] getChildElements() {
2493:                    return null;
2494:                }
2495:
2496:                /**
2497:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element, org.geotools.xml.schema.ElementValue[], org.xml.sax.Attributes, java.util.Map)
2498:                 */
2499:                public Object getValue(Element element, ElementValue[] value,
2500:                        Attributes attrs, Map hints) {
2501:                    return null;
2502:                }
2503:
2504:                /**
2505:                 * @see org.geotools.xml.schema.Type#getName()
2506:                 */
2507:                public String getName() {
2508:                    return "EmptyType";
2509:                }
2510:
2511:                /**
2512:                 * @see org.geotools.xml.schema.Type#getInstanceType()
2513:                 */
2514:                public Class getInstanceType() {
2515:                    return null;
2516:                }
2517:
2518:                /**
2519:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element, java.lang.Object, java.util.Map)
2520:                 */
2521:                public boolean canEncode(Element element, Object value,
2522:                        Map hints) {
2523:                    return element != null;
2524:                }
2525:
2526:                /**
2527:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element, java.lang.Object, org.geotools.xml.PrintHandler, java.util.Map)
2528:                 */
2529:                public void encode(Element element, Object value,
2530:                        PrintHandler output, Map hints) throws IOException {
2531:                    output.element(element.getNamespace(), element.getName(),
2532:                            null);
2533:                }
2534:            }
2535:
2536:            private static class AllSomeType implements  SimpleType {
2537:                private static SimpleType instance = new AllSomeType();
2538:                private static Facet[] facets = new Facet[] {
2539:                        new FacetGT(Facet.ENUMERATION, "ALL"),
2540:                        new FacetGT(Facet.ENUMERATION, "SOME") };
2541:
2542:                public static SimpleType getInstance() {
2543:                    return instance;
2544:                }
2545:
2546:                //    	   <xsd:simpleType name="AllSomeType">
2547:                //    	      <xsd:restriction base="xsd:string">
2548:                //    	         <xsd:enumeration value="ALL"/>
2549:                //    	         <xsd:enumeration value="SOME"/>
2550:                //    	      </xsd:restriction>
2551:                //    	   </xsd:simpleType>
2552:
2553:                /**
2554:                 * @see org.geotools.xml.schema.SimpleType#getFinal()
2555:                 */
2556:                public int getFinal() {
2557:                    return 0;
2558:                }
2559:
2560:                /**
2561:                 * @see org.geotools.xml.schema.SimpleType#getId()
2562:                 */
2563:                public String getId() {
2564:                    return null;
2565:                }
2566:
2567:                /**
2568:                 * @see org.geotools.xml.schema.SimpleType#toAttribute(org.geotools.xml.schema.Attribute, java.lang.Object, java.util.Map)
2569:                 */
2570:                public AttributeValue toAttribute(Attribute attribute,
2571:                        Object value, Map hints) {
2572:                    return null;
2573:                }
2574:
2575:                /**
2576:                 * @see org.geotools.xml.schema.SimpleType#canCreateAttributes(org.geotools.xml.schema.Attribute, java.lang.Object, java.util.Map)
2577:                 */
2578:                public boolean canCreateAttributes(Attribute attribute,
2579:                        Object value, Map hints) {
2580:                    return false;
2581:                }
2582:
2583:                /**
2584:                 * @see org.geotools.xml.schema.SimpleType#getChildType()
2585:                 */
2586:                public int getChildType() {
2587:                    return RESTRICTION;
2588:                }
2589:
2590:                /**
2591:                 * @see org.geotools.xml.schema.SimpleType#getParents()
2592:                 */
2593:                public SimpleType[] getParents() {
2594:                    return new SimpleType[] { XSISimpleTypes.String
2595:                            .getInstance(), };
2596:                }
2597:
2598:                /**
2599:                 * @see org.geotools.xml.schema.SimpleType#getFacets()
2600:                 */
2601:                public Facet[] getFacets() {
2602:                    return facets;
2603:                }
2604:
2605:                /**
2606:                 * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element, org.geotools.xml.schema.ElementValue[], org.xml.sax.Attributes, java.util.Map)
2607:                 */
2608:                public Object getValue(Element element, ElementValue[] value,
2609:                        Attributes attrs, Map hints) throws SAXException,
2610:                        SAXNotSupportedException {
2611:                    if ((value == null) || (value.length != 1)
2612:                            || (element == null) || (element.getType() == null)) {
2613:                        throw new SAXNotSupportedException("invalid inputs");
2614:                    }
2615:
2616:                    if (value[0].getValue() instanceof  String) {
2617:                        String t = (String) value[0].getValue();
2618:
2619:                        if ("ALL".equals(t) || "SOME".equals(t)) {
2620:                            return t;
2621:                        }
2622:
2623:                        throw new SAXException("Invalid value: not ALL or NONE");
2624:                    }
2625:
2626:                    throw new SAXNotSupportedException(
2627:                            "Invalid child value type.");
2628:                }
2629:
2630:                /**
2631:                 * @see org.geotools.xml.schema.Type#getName()
2632:                 */
2633:                public String getName() {
2634:                    return "AllSomeType";
2635:                }
2636:
2637:                /**
2638:                 * @see org.geotools.xml.schema.Type#getNamespace()
2639:                 */
2640:                public URI getNamespace() {
2641:                    return WFSSchema.NAMESPACE;
2642:                }
2643:
2644:                /**
2645:                 * @see org.geotools.xml.schema.Type#getInstanceType()
2646:                 */
2647:                public Class getInstanceType() {
2648:                    return String.class;
2649:                }
2650:
2651:                /**
2652:                 * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element, java.lang.Object, java.util.Map)
2653:                 */
2654:                public boolean canEncode(Element element, Object value,
2655:                        Map hints) {
2656:                    return (element != null) && (element.getType() != null)
2657:                            && getName().equals(element.getType().getName())
2658:                            && value instanceof  String
2659:                            && ("ALL".equals(value) || "SOME".equals(value));
2660:                }
2661:
2662:                /**
2663:                 * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element, java.lang.Object, org.geotools.xml.PrintHandler, java.util.Map)
2664:                 */
2665:                public void encode(Element element, Object value,
2666:                        PrintHandler output, Map hints) throws IOException {
2667:                    if (canEncode(element, value, hints)) {
2668:                        output.startElement(element.getNamespace(), element
2669:                                .getName(), null);
2670:                    }
2671:
2672:                    output.characters((String) value);
2673:                    output
2674:                            .endElement(element.getNamespace(), element
2675:                                    .getName());
2676:                }
2677:
2678:                /**
2679:                 * @see org.geotools.xml.schema.Type#findChildElement(java.lang.String)
2680:                 */
2681:                public Element findChildElement(String name) {
2682:                    return null;
2683:                }
2684:            }
2685:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.