Interface SimpleBinding
- All Superinterfaces:
Binding
- All Known Implementing Classes:
AbstractSimpleBinding
,AcceptedFormatsTypeBinding
,AllSomeTypeBinding
,Base_TypeNameListTypeBinding
,BrightnessOnlyBinding
,CapabilitiesSectionTypeBinding
,ColorBinding
,ComparisonOperatorTypeBinding
,CoordinatesTypeBinding
,CoverageNameBinding
,DataTransmissionModeTypeBinding
,DateTimeTypeBinding
,DirectionTypeBinding
,DoubleListBinding
,DoubleListBinding
,DoubleListBinding
,EnumSimpleBinding
,GeometryOperandTypeBinding
,GetCapabilitiesValueTypeBinding
,GetFeatureInfoValueTypeBinding
,GetTileValueTypeBinding
,GMLNullTypeBinding
,IdentifierGenerationOptionTypeBinding
,IntegerListBinding
,IntegerListBinding
,InterpolationMethodTypeBinding
,JobControlOptionsTypeBinding
,LayerBinding
,MatchActionBinding
,MethodTypeBinding
,MimeTypeBinding
,ModeTypeBinding
,NameListBinding
,NullTypeBinding
,OperationTypeBinding
,OverlapBehaviorBinding
,PositionType2DBinding
,PositionTypeBinding
,RangeClosureBinding
,RequestServiceTypeBinding
,ResultTypeTypeBinding
,ReturnFeatureTypesListTypeBinding
,SearchDirectionTypeBinding
,SectionsTypeBinding
,ServiceTypeBinding
,SLDFormatBinding
,SLDGammaValueBinding
,SortOrderTypeBinding
,StripOffPositionTypeBinding
,TemporalPositionTypeBinding
,ThreshholdsBelongToTypeBinding
,TimeDurationTypeBinding
,TimeIndeterminateValueTypeBinding
,TimePositionUnionBinding
,TypeNameListTypeBinding
,UnitBinding
,UpdateSequenceTypeBinding
,ValueReferenceBinding
,VersionTypeBinding
,VersionTypeBinding
,VersionTypeBinding
,XSAllNNIBinding
,XSAnySimpleTypeBinding
,XSAnyURIBinding
,XSBase64BinaryBinding
,XSBlockSetBinding
,XSBooleanBinding
,XSByteBinding
,XSDateBinding
,XSDateTimeBinding
,XSDecimalBinding
,XSDerivationControlBinding
,XSDerivationSetBinding
,XSDoubleBinding
,XSDurationBinding
,XSENTITIESBinding
,XSENTITYBinding
,XSFloatBinding
,XSFormChoiceBinding
,XSFullDerivationSetBinding
,XSGDayBinding
,XSGMonthBinding
,XSGMonthDayBinding
,XSGYearBinding
,XSGYearMonthBinding
,XSHexBinaryBinding
,XSIDBinding
,XSIDREFBinding
,XSIDREFSBinding
,XSIntBinding
,XSIntegerBinding
,XSLanguageBinding
,XSLongBinding
,XSNameBinding
,XSNamespaceListBinding
,XSNCNameBinding
,XSNegativeIntegerBinding
,XSNMTOKENBinding
,XSNMTOKENSBinding
,XSNonNegativeIntegerBinding
,XSNonPositiveIntegerBinding
,XSNormalizedStringBinding
,XSNOTATIONBinding
,XSPositiveIntegerBinding
,XSPublicBinding
,XSQNameBinding
,XSReducedDerivationControlBinding
,XSShortBinding
,XSSimpleDerivationSetBinding
,XSStringBinding
,XSTimeBinding
,XSTokenBinding
,XSTypeDerivationControlBinding
,XSUnsignedByteBinding
,XSUnsignedIntBinding
,XSUnsignedLongBinding
,XSUnsignedShortBinding
Simple types can be manifested in elements and in attributes. Simple type strategies must be capable of parsing simple values regardless of the form.
Strategy objects must declare how they relate to other strategy objects in the type hierarchy of the type they parse. To allow strategy objects which relate through a type hiearchy to communicate, a value is passed along to strategies as they are executed. As an example, consider the strategies for integer and decimal.
class DecimalStrategy implements Strategy {
...
int getExecutionMode() {
return OVERRIDE;
}
Object parse(InstanceComponent instance, Object value)
throws Exception {
BigDecimal decimal = new BigDecimal(instance.getText());
return decimal;
}
...
}
class IntegerStrategy implements Strategy {
...
int getExecutionMode() {
return AFTER;
}
Object parse(InstanceComponent instance, Object value)
throws Exception {
BigDecimal decimal = (BigDecimal)value;
return decimal.toBigInteger();
}
...
}
In the above example, the decimal strategy is at the top of the hierarchy as it declares its execution mode as
Binding.OVERRIDE
. Therefore it must process the raw text of the instance being parsed, and transform it into
the specific object, in this case an object of type BigDecimal.
The integer strategy extends the decimal strategy as it declares its execution mode as Binding.AFTER
.
Therefore the integer strategy has access to the result of the decimal strategy, and can simply transform the result
of the decimal strategy into its specific type. In this case an object of type BigInteger.
- Author:
- Justin Deoliveira,Refractions Research Inc.,jdeolive@refractions.net
-
Field Summary
-
Method Summary
Methods inherited from interface Binding
getExecutionMode, getTarget, getType
-
Method Details
-
parse
Parses an instance component (element or attribute) into an object representation.- Parameters:
instance
- The component being parsed.value
- The result of the parse from another strategy in the type hierarchy. Could be null if this is the first strategy being executed.- Returns:
- The parsed object, or null if the component could not be parsed.
- Throws:
Delegate
- objects should not attempt to handle any exceptions.Exception
-
encode
Performs the encoding of the object as a String.- Parameters:
object
- The object being encoded, never null.value
- The string returned from another binding in the type hierachy, which could be null.- Returns:
- A String representing the object.
- Throws:
Exception
-