001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.geoserver.wfs.xml.v1_1_0;
006:
007: import net.opengis.wfs.BaseRequestType;
008: import net.opengis.wfs.WfsFactory;
009: import org.eclipse.emf.ecore.EObject;
010: import org.geotools.xml.AbstractComplexBinding;
011: import org.geotools.xml.EMFUtils;
012: import org.geotools.xml.ElementInstance;
013: import org.geotools.xml.Node;
014: import javax.xml.namespace.QName;
015:
016: /**
017: * Binding object for the type http://www.opengis.net/wfs:BaseRequestType.
018: *
019: * <p>
020: * <pre>
021: * <code>
022: * <xsd:complexType abstract="true" name="BaseRequestType">
023: * <xsd:annotation>
024: * <xsd:documentation>
025: * XML encoded WFS operation request base, for all operations
026: * except GetCapabilities.
027: * </xsd:documentation>
028: * </xsd:annotation>
029: * <xsd:attribute default="WFS" name="service" type="ows:ServiceType" use="optional">
030: * <xsd:annotation>
031: * <xsd:documentation>
032: * The service attribute is included to support service
033: * endpoints that implement more than one OGC service.
034: * For example, a single CGI that implements WMS, WFS
035: * and WCS services.
036: * The endpoint can inspect the value of this attribute
037: * to figure out which service should process the request.
038: * The value WFS indicates that a web feature service should
039: * process the request.
040: * This parameter is somewhat redundant in the XML encoding
041: * since the request namespace can be used to determine
042: * which service should process any give request. For example,
043: * wfs:GetCapabilities and easily be distinguished from
044: * wcs:GetCapabilities using the namespaces.
045: * </xsd:documentation>
046: * </xsd:annotation>
047: * </xsd:attribute>
048: * <xsd:attribute default="1.1.0" name="version" type="xsd:string" use="optional">
049: * <xsd:annotation>
050: * <xsd:documentation>
051: * The version attribute is used to indicate the version of the
052: * WFS specification that a request conforms to. All requests in
053: * this schema conform to V1.1 of the WFS specification.
054: * For WFS implementations that support more than one version of
055: * a WFS sepcification ... if the version attribute is not
056: * specified then the service should assume that the request
057: * conforms to greatest available specification version.
058: * </xsd:documentation>
059: * </xsd:annotation>
060: * </xsd:attribute>
061: * <xsd:attribute name="handle" type="xsd:string" use="optional">
062: * <xsd:annotation>
063: * <xsd:documentation>
064: * The handle attribute allows a client application
065: * to assign a client-generated request identifier
066: * to a WFS request. The handle is included to
067: * facilitate error reporting. A WFS may report the
068: * handle in an exception report to identify the
069: * offending request or action. If the handle is not
070: * present, then the WFS may employ other means to
071: * localize the error (e.g. line numbers).
072: * </xsd:documentation>
073: * </xsd:annotation>
074: * </xsd:attribute>
075: * </xsd:complexType>
076: *
077: * </code>
078: * </pre>
079: * </p>
080: *
081: * @generated
082: */
083: public class BaseRequestTypeBinding extends AbstractComplexBinding {
084: WfsFactory wfsfactory;
085:
086: public BaseRequestTypeBinding(WfsFactory wfsfactory) {
087: this .wfsfactory = wfsfactory;
088: }
089:
090: /**
091: * @generated
092: */
093: public QName getTarget() {
094: return WFS.BASEREQUESTTYPE;
095: }
096:
097: /**
098: * <!-- begin-user-doc -->
099: * <!-- end-user-doc -->
100: *
101: * @generated modifiable
102: */
103: public Class getType() {
104: return BaseRequestType.class;
105: }
106:
107: /**
108: * <!-- begin-user-doc -->
109: * <!-- end-user-doc -->
110: *
111: * @generated modifiable
112: */
113: public Object parse(ElementInstance instance, Node node,
114: Object value) throws Exception {
115: //this binding needs to be executed after the child
116: EObject request = (EObject) value;
117:
118: //<xsd:attribute default="WFS" name="service" type="ows:ServiceType" use="optional">
119: if (node.hasAttribute("service")) {
120: String service = (String) node.getAttributeValue("service");
121:
122: if ((service != null) && !"".equals(service.trim())) {
123: EMFUtils.set(request, "service", node
124: .getAttributeValue("service"));
125: } else {
126: EMFUtils.set(request, "service", "WFS");
127: }
128: } else {
129: EMFUtils.set(request, "service", "WFS");
130: }
131:
132: //<xsd:attribute default="1.1.0" name="version" type="xsd:string" use="optional">
133: if (node.hasAttribute("version")) {
134: String version = (String) node.getAttributeValue("version");
135:
136: if ((version != null) && !"".equals(version.trim())) {
137: EMFUtils.set(request, "version", node
138: .getAttributeValue("version"));
139: } else {
140: EMFUtils.set(request, "version", "1.1.0");
141: }
142: } else {
143: EMFUtils.set(request, "version", "1.1.0");
144: }
145:
146: //<xsd:attribute name="handle" type="xsd:string" use="optional">
147: if (node.hasAttribute("handle")) {
148: EMFUtils.set(request, "handle", node
149: .getAttributeValue("handle"));
150: }
151:
152: return request;
153: }
154: }
|