org.geotools.xml
Interface Binding
- All Known Subinterfaces:
- ComplexBinding, SimpleBinding
- All Known Implementing Classes:
- _DCPBinding, _ExceptionReportBinding, _Filter_CapabilitiesBinding, _Filter_CapabilitiesBinding, _HTTPBinding, _OperationBinding, _OperationsMetadataBinding, _ServiceIdentificationBinding, _ServiceProviderBinding, _XlinkPropertyNameBinding, AbstractComplexBinding, AbstractComplexEMFBinding, AbstractFeatureCollectionTypeBinding, AbstractFeatureTypeBinding, AbstractGeometryTypeBinding, AbstractRingPropertyTypeBinding, AbstractSimpleBinding, AbstractSimpleContentComplexBinding, AbstractSurfaceTypeBinding, AcceptFormatsTypeBinding, AcceptVersionsTypeBinding, ActionTypeBinding, AddressTypeBinding, AllSomeTypeBinding, Arithmetic_OperatorsTypeBinding, Base_TypeNameListTypeBinding, BaseRequestTypeBinding, BoundaryTypeBinding, BoundingBoxTypeBinding, BoundingShapeTypeBinding, CapabilitiesBaseTypeBinding, CodeTypeBinding, ColorBinding, ColorStyleTypeBinding, Comparison_OperatorsTypeBinding, ComparisonOperatorsTypeBinding, ComparisonOperatorTypeBinding, ComplexDataTypeBinding, ComplexEMFBinding, ContactTypeBinding, ContainerTypeBinding, CoordinatesTypeBinding, CurveArrayPropertyTypeBinding, CurvePropertyTypeBinding, CurveSegmentArrayPropertyTypeBinding, CurveTypeBinding, DateTimeTypeBinding, DeleteElementTypeBinding, DescribeFeatureTypeTypeBinding, DescriptionTypeBinding, DirectPositionListTypeBinding, DirectPositionTypeBinding, DocumentTypeBinding, DomainTypeBinding, DoubleListBinding, EnvelopeTypeBinding, ExceptionTypeBinding, FeatureArrayPropertyTypeBinding, FeatureCollectionTypeBinding, FeaturePropertyTypeBinding, FeaturesLockedTypeBinding, FeaturesNotLockedTypeBinding, FeatureTypeBinding, FeatureTypeListTypeBinding, FeatureTypeType_NoSRSBinding, FeatureTypeTypeBinding, FilterTypeBinding, FolderTypeBinding, Function_NamesTypeBinding, Function_NameTypeBinding, FunctionsTypeBinding, GeometryOperandsTypeBinding, GeometryOperandTypeBinding, GeometryPropertyTypeBinding, GeometryTypeBinding, GetCapabilitiesTypeBinding, GetCapabilitiesTypeBinding, GetFeatureTypeBinding, GetFeatureWithLockTypeBinding, GetGmlObjectTypeBinding, GMLAbstractFeatureCollectionBaseTypeBinding, GMLAbstractFeatureCollectionTypeBinding, GMLAbstractFeatureTypeBinding, GMLAbstractGeometryCollectionBaseTypeBinding, GMLAbstractGeometryTypeBinding, GMLBoundingShapeTypeBinding, GMLBoxTypeBinding, GMLCoordinatesTypeBinding, GMLCoordTypeBinding, GMLFeatureAssociationTypeBinding, GMLGeometryAssociationTypeBinding, GMLGeometryCollectionTypeBinding, GMLGeometryPropertyTypeBinding, GMLLinearRingMemberTypeBinding, GMLLinearRingTypeBinding, GMLLineStringMemberTypeBinding, GMLLineStringPropertyTypeBinding, GMLLineStringTypeBinding, GMLMultiGeometryPropertyTypeBinding, GMLMultiLineStringPropertyTypeBinding, GMLMultiLineStringTypeBinding, GMLMultiPointPropertyTypeBinding, GMLMultiPointTypeBinding, GMLMultiPolygonPropertyTypeBinding, GMLMultiPolygonTypeBinding, GMLNullTypeBinding, GmlObjectIdTypeBinding, GMLObjectTypeListTypeBinding, GMLObjectTypeTypeBinding, GMLPointMemberTypeBinding, GMLPointPropertyTypeBinding, GMLPointTypeBinding, GMLPolygonMemberTypeBinding, GMLPolygonPropertyTypeBinding, GMLPolygonTypeBinding, Id_CapabilitiesTypeBinding, IdentificationTypeBinding, IdentifierGenerationOptionTypeBinding, InputReferenceTypeBinding, InsertedFeatureTypeBinding, InsertElementTypeBinding, InsertResultsTypeBinding, IntegerListBinding, IonicStrategy.IonicGML2BoxTypeBinding, KeywordsTypeBinding, KmlTypeBinding, LabelStyleTypeBinding, LanguagesBinding, LatLonBoxTypeBinding, LinearRingPropertyTypeBinding, LinearRingTypeBinding, LinearRingTypeBinding, LineStringPropertyTypeBinding, LineStringSegmentTypeBinding, LineStringTypeBinding, LineStringTypeBinding, LineStyleTypeBinding, LocationPropertyTypeBinding, LocationTypeBinding, LockFeatureResponseTypeBinding, LockFeatureTypeBinding, LockTypeBinding, LookAtTypeBinding, MeasureTypeBinding, MetadataTypeBinding, MetadataTypeBinding, MetadataURLTypeBinding, MimeTypeBinding, MultiCurvePropertyTypeBinding, MultiCurveTypeBinding, MultiGeometryPropertyTypeBinding, MultiGeometryTypeBinding, MultiGeometryTypeBinding, MultiLineStringPropertyTypeBinding, MultiLineStringTypeBinding, MultiPointPropertyTypeBinding, MultiPointTypeBinding, MultiPolygonPropertyTypeBinding, MultiPolygonTypeBinding, MultiSurfacePropertyTypeBinding, MultiSurfaceTypeBinding, NativeTypeBinding, NullTypeBinding, ObjectTypeBinding, OGCAddBinding, OGCAndBinding, OGCBBOXTypeBinding, OGCBeyondBinding, OGCBinaryComparisonOpTypeBinding, OGCBinaryLogicOpTypeBinding, OGCBinaryOperatorTypeBinding, OGCBinarySpatialOpTypeBinding, OGCComparisonOpsTypeBinding, OGCContainsBinding, OGCCrossesBinding, OGCDisjointBinding, OGCDistanceBufferTypeBinding, OGCDistanceTypeBinding, OGCDivBinding, OGCDWithinBinding, OGCEqualsBinding, OGCExpressionTypeBinding, OGCFeatureIdTypeBinding, OGCFilterTypeBinding, OGCFunctionTypeBinding, OGCIntersectsBinding, OGCLiteralTypeBinding, OGCLogicOpsTypeBinding, OGCLowerBoundaryTypeBinding, OGCMulBinding, OGCNotBinding, OGCOrBinding, OGCOverlapsBinding, OGCPropertyIsBetweenTypeBinding, OGCPropertyIsEqualToBinding, OGCPropertyIsGreaterThanBinding, OGCPropertyIsGreaterThanOrEqualToBinding, OGCPropertyIsLessThanBinding, OGCPropertyIsLessThanOrEqualToBinding, OGCPropertyIsLikeTypeBinding, OGCPropertyIsNotEqualToBinding, OGCPropertyIsNullTypeBinding, OGCPropertyNameTypeBinding, OGCSpatialOpsTypeBinding, OGCSubBinding, OGCTouchesBinding, OGCUpperBoundaryTypeBinding, OGCWithinBinding, OnlineResourceTypeBinding, OperationsTypeBinding, OperationTypeBinding, OutputFormatListTypeBinding, PlacemarkTypeBinding, PointArrayPropertyTypeBinding, PointPropertyTypeBinding, PointTypeBinding, PointTypeBinding, PolygonPatchTypeBinding, PolygonPropertyTypeBinding, PolygonTypeBinding, PolygonTypeBinding, PolyStyleTypeBinding, PositionType2DBinding, PositionTypeBinding, PropertyTypeBinding, QueryTypeBinding, ReferenceTypeBinding, RegionTypeBinding, RequestMethodTypeBinding, ResponsiblePartySubsetTypeBinding, ResponsiblePartyTypeBinding, ResultTypeTypeBinding, Scalar_CapabilitiesTypeBinding, SectionsTypeBinding, ServiceTypeBinding, SimpleContentComplexEMFBinding, SLDAnchorPointBinding, SLDBlueChannelBinding, SLDChannelSelectionBinding, SLDColorMapBinding, SLDColorMapEntryBinding, SLDContrastEnhancementBinding, SLDCssParameterBinding, SLDDisplacementBinding, SLDExtentBinding, SLDExternalGraphicBinding, SLDFeatureTypeConstraintBinding, SLDFeatureTypeStyleBinding, SLDFillBinding, SLDFontBinding, SLDFormatBinding, SLDGammaValueBinding, SLDGeometryBinding, SLDGraphicBinding, SLDGraphicFillBinding, SLDGraphicStrokeBinding, SLDGrayChannelBinding, SLDGreenChannelBinding, SLDHaloBinding, SLDHistogramBinding, SLDImageOutlineBinding, SLDLabelPlacementBinding, SLDLayerFeatureConstraintsBinding, SLDLegendGraphicBinding, SLDLinePlacementBinding, SLDLineSymbolizerBinding, SLDMarkBinding, SLDNamedLayerBinding, SLDNamedStyleBinding, SLDNormalizeBinding, SLDOnlineResourceBinding, SLDOverlapBehaviorBinding, SLDParameterValueTypeBinding, SLDPerpendicularOffsetBinding, SLDPointPlacementBinding, SLDPointSymbolizerBinding, SLDPolygonSymbolizerBinding, SLDRasterSymbolizerBinding, SLDRedChannelBinding, SLDRemoteOWSBinding, SLDRuleBinding, SLDSelectedChannelTypeBinding, SLDShadedReliefBinding, SLDStrokeBinding, SLDStyledLayerDescriptorBinding, SLDSymbolizerBinding, SLDSymbolizerTypeBinding, SLDTextSymbolizerBinding, SLDUserLayerBinding, SLDUserStyleBinding, SortByTypeBinding, SortOrderTypeBinding, SortPropertyTypeBinding, Spatial_CapabilitiesTypeBinding, Spatial_CapabilitiesTypeBinding, Spatial_OperatorsTypeBinding, SpatialOperatorsTypeBinding, SpatialOperatorTypeBinding, StyleTypeBinding, SubstitutionGroupXSAnyTypeBinding, SurfaceArrayPropertyTypeBinding, SurfacePatchArrayPropertyTypeBinding, SurfacePropertyTypeBinding, SurfaceTypeBinding, TelephoneTypeBinding, TransactionResponseTypeBinding, TransactionResultsTypeBinding, TransactionSummaryTypeBinding, TransactionTypeBinding, TypeNameListTypeBinding, UnitBinding, UpdateElementTypeBinding, UpdateSequenceTypeBinding, VersionTypeBinding, WFS_CapabilitiesTypeBinding, WGS84BoundingBoxTypeBinding, XSAllBinding, XSAllNNIBinding, XSAnnotatedBinding, XSAnySimpleTypeBinding, XSAnyTypeBinding, XSAnyURIBinding, XSAttributeBinding, XSAttributeGroupBinding, XSAttributeGroupRefBinding, XSBase64BinaryBinding, XSBlockSetBinding, XSBooleanBinding, XSByteBinding, XSComplexRestrictionTypeBinding, XSComplexTypeBinding, XSDateBinding, XSDateTimeBinding, XSDecimalBinding, XSDerivationControlBinding, XSDerivationSetBinding, XSDoubleBinding, XSDurationBinding, XSElementBinding, XSENTITIESBinding, XSENTITYBinding, XSExplicitGroupBinding, XSExtensionTypeBinding, XSFacetBinding, XSFloatBinding, XSFormChoiceBinding, XSFullDerivationSetBinding, XSGDayBinding, XSGMonthBinding, XSGMonthDayBinding, XSGroupBinding, XSGroupRefBinding, XSGYearBinding, XSGYearMonthBinding, XSHexBinaryBinding, XSIDBinding, XSIDREFBinding, XSIDREFSBinding, XSIntBinding, XSIntegerBinding, XSKeybaseBinding, XSLanguageBinding, XSLocalComplexTypeBinding, XSLocalElementBinding, XSLocalSimpleTypeBinding, XSLongBinding, XSNameBinding, XSNamedAttributeGroupBinding, XSNamedGroupBinding, XSNamespaceListBinding, XSNarrowMaxMinBinding, XSNCNameBinding, XSNegativeIntegerBinding, XSNMTOKENBinding, XSNMTOKENSBinding, XSNoFixedFacetBinding, XSNonNegativeIntegerBinding, XSNonPositiveIntegerBinding, XSNormalizedStringBinding, XSNOTATIONBinding, XSNumFacetBinding, XSOpenAttrsBinding, XSPositiveIntegerBinding, XSPublicBinding, XSQNameBinding, XSRealGroupBinding, XSReducedDerivationControlBinding, XSRestrictionTypeBinding, XSShortBinding, XSSimpleDerivationSetBinding, XSSimpleExplicitGroupBinding, XSSimpleExtensionTypeBinding, XSSimpleRestrictionTypeBinding, XSSimpleTypeBinding, XSStringBinding, XSTimeBinding, XSTokenBinding, XSTopLevelAttributeBinding, XSTopLevelComplexTypeBinding, XSTopLevelElementBinding, XSTopLevelSimpleTypeBinding, XSTypeDerivationControlBinding, XSUnsignedByteBinding, XSUnsignedIntBinding, XSUnsignedLongBinding, XSUnsignedShortBinding, XSWildcardBinding
public interface Binding
A specialized handler for a specific type in an xml schema.
Bindings have the following responsibilities.
- Parsing components from an instance document (elements and attributes)
into model objects
- Encoding model objects as xml components
- Sorting themselves in case multiple bindings target the same type
Type Binding
Binding objects correspond to xml schema types. A binding declares
it target type by advertising the qualified name of the type it binds to.
For instance, the following strategy binds itself to type xsd:string.
class XSDStringStrategy {
QName getTarget() {
return new QName("http://www.w3.org/2001/XMLSchema","string");
}
...
The upshot is that whenever an element or attribute is encountered in an
instance document that is of type xsd:string, this binding will be used to
turn the string into an object representation.
And on the other side of coin, when an instanceof String is encountered when
serializing an object model, the binding will be used to encode the string as
xml.
Inheritance
XML Schema supports Inheritance. As a concrete example, consider the simple
xml schema simple types decimal and integer.
<xs:simpleType name="decimal" id="decimal">
<xs:annotation>
<xs:appinfo>
<hfp:hasFacet name="totalDigits"/>
<hfp:hasFacet name="fractionDigits"/>
<hfp:hasFacet name="pattern"/>
<hfp:hasFacet name="whiteSpace"/>
<hfp:hasFacet name="enumeration"/>
<hfp:hasFacet name="maxInclusive"/>
<hfp:hasFacet name="maxExclusive"/>
<hfp:hasFacet name="minInclusive"/>
<hfp:hasFacet name="minExclusive"/>
<hfp:hasProperty name="ordered" value="total"/>
<hfp:hasProperty name="bounded" value="false"/>
<hfp:hasProperty name="cardinality" value="countably infinite"/>
<hfp:hasProperty name="numeric" value="true"/>
</xs:appinfo>
<xs:documentation source="http://www.w3.org/TR/xmlschema-2/#decimal"/>
</xs:annotation>
<xs:restriction base="xs:anySimpleType">
<xs:whiteSpace fixed="true" value="collapse" id="decimal.whiteSpace"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="integer" id="integer">
<xs:annotation>
<xs:documentation source="http://www.w3.org/TR/xmlschema-2/#integer"/>
</xs:annotation>
<xs:restriction base="xs:decimal">
<xs:fractionDigits fixed="true" value="0" id="integer.fractionDigits"/>
<xs:pattern value="[\-+]?[0-9]+"/>
</xs:restriction>
</xs:simpleType>
The above types define an inheiretance hierarcy. To model this relationship
among the corresponding binding objects, an execution mode must be
declared by each binding. The execution mode specifies wether a binding
should be executed before, after, or totally override the binding for a
direct parent.
class DecimalBinding implements Binding {
...
int getExecutionMode() {
return OVERRIDE;
}
...
}
class IntegerBinding implemnts Binding {
...
int getExecutionMode() {
return AFTER;
}
...
}
In the above example, the decimal bidning declares its execution mode to
be override. This means that no bindings for any of the base types of
decimal will be executed. The integer binding declares its execution mode
as AFTER. This means that the integer binding will be executed after the
decimal strategy.
Context
Bindings are executed within a particular context or container. A binding
can use its context to obtain objects that it depends on to perform a parse
or encoding. A binding can declare a dependency by simply adding it to its
constructor.
This is known as
Constructor Injection.
When the binding is created it is injected with all dependencies. The context is
responsible for satisfying the dependencies of the binding. As an example
consider the following complex type defintion.
<xsd:complexType name="collection">
<xsd:sequence>
<xsd:element name="item" type="xsd:any" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
The associated binding must turn instances of this type into objects of
type Collection
. However, the question remains what
concrete subclass of Collection to use. And perhaps we need this type to
vary in different situations. The solution is to take the decision out of
the hands of this binding, and into the hands of someone else. To acheive
this the collection binding adds a dependency of type Collection.
class CollectionStrategy implements ComplexBinding {
Collection collection;
CollectionStrategy(Collection collection) {
this.collection = collection;
}
QName getTarget() {
return new QName("http://org/geotools/","collection");
}
int getExecutionMode() {
return OVERRIDE;
}
Object parse(Element instance, Node[] children, Node[] atts, Object value)
throws Exception {
for (int i = 0; i < children.length; i++) {
collection.add(children[i].getValue());
}
return collection;
}
}
Conflict resolution
In some cases multiple bindings are targetting the same java class. This happens, for example,
in GML3 where MultiPolygon
is associated to two different elements, gml:MultiPolygon
and gml:MultiSurface (the former being deprecated and kept for backwards compatibility).
In such occasions, binding implementations must implement the Comparable
interface,
in case of doubt the bindings associated to a specific class will be sorted and the first
element in the resulting List
will be used.
- Author:
- Justin Deoliveira,Refractions Research Inc.,jdeolive@refractions.net
- Module:
modules/extension/xsd-core (gt-xsd-core.jar)
Field Summary |
static int |
AFTER
Specifies that a binding should be executed after its direct parent |
static int |
BEFORE
Specifes that a binding should be executed before its direct parent.d |
static int |
OVERRIDE
Specifies that a binding should totally override the execution of its
direct parent. |
AFTER
static final int AFTER
- Specifies that a binding should be executed after its direct parent
- See Also:
- Constant Field Values
BEFORE
static final int BEFORE
- Specifes that a binding should be executed before its direct parent.d
- See Also:
- Constant Field Values
OVERRIDE
static final int OVERRIDE
- Specifies that a binding should totally override the execution of its
direct parent.
- See Also:
- Constant Field Values
getTarget
QName getTarget()
- Returns:
- The qualified name of the target for the binding.
getType
Class getType()
- Returns:
- The java type this binding maps to.
getExecutionMode
int getExecutionMode()
- Returns:
- The execution mode of the binding, one of the constants AFTER,
BEFORE, or OVERRIDE.
- See Also:
AFTER
,
BEFORE
,
OVERRIDE
Copyright © 1996-2009 Geotools. All Rights Reserved.