public abstract class ALcdGMLTypeMappingAnnotation extends Object implements ILcdAnnotation
As an example, you could define and use a GregorianCalender type in your data model. You can map the type to an XML date type as follows:
dataModelBuilder.typeBuilder("DateType").primitive(true).instanceClass(GregorianCalendar.class);
TLcdDataModel dataModel = dataModelBuilder.createDataModel();
TLcdDataType dateType = dataModel.getDeclaredType("DateType");
dateType.addAnnotation(new TLcdGML32TypeMappingAnnotation(
TLcdXMLBuiltInDataTypes.DateTime, new ALcdObjectTransformation() {
public Object transform(Object aValue, Map<Object, Object> aContext) {
return DatatypeFactory.newInstance().newXMLGregorianCalendar((GregorianCalendar) aValue);
}
protected Object invert(Object aValue, Map<Object, Object> aContext) {
return ((XMLGregorianCalendar) aValue).toGregorianCalendar();
}
}
TLcdGMLTransformer
Constructor and Description |
---|
ALcdGMLTypeMappingAnnotation(TLcdDataType aType,
ILcdObjectTransformation aTransformation)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
ILcdObjectTransformation |
getTransformation()
Returns the transformation that is capable of transforming instances of the annotated type
to instances of
getType() . |
TLcdDataType |
getType()
Returns the GML representation of the annotated type.
|
public ALcdGMLTypeMappingAnnotation(TLcdDataType aType, ILcdObjectTransformation aTransformation)
aType
should be
annotated with TLcdXMLSchemaMappingAnnotation
and TLcdXMLSchemaTypeMappingAnnotation
such that instances can be properly marshalled from and to XML.aType
- the type that is the GML representation of the type to which this annotation is addedaTransformation
- a transformation that can transform instances from the annotated type to the given typepublic TLcdDataType getType()
public ILcdObjectTransformation getTransformation()
getType()
.