Interface IDataTypeHandler
-
public interface IDataTypeHandler
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Object
copyItem(Object item, Object parentInstance)
Build and return a deep copy of the provided item.IClassBinding
getClassBinding()
Get the class binding associated with this handler.IDataTypeAdapter<?>
getJavaTypeAdapter()
Get the associatedIDataTypeAdapter
, if the data type is not a complex bound object.boolean
isJsonKeyRequired()
boolean
isUnwrappedValueAllowedInXml()
Indicate if the value supported by this handler allows values without an XML element wrapper.static IDataTypeHandler
newDataTypeHandler(IBoundFieldInstance property)
static IDataTypeHandler
newDataTypeHandler(IBoundNamedModelInstance targetInstance, IClassBinding classBinding)
static IDataTypeHandler
newDataTypeHandler(IClassBinding classBinding)
<T> T
readItem(Object parentObject, IJsonParsingContext context)
Parse and return the set of items from the JSON stream.Object
readItem(Object parentObject, StartElement parentName, IXmlParsingContext context)
Parse and return the set of items from the XML stream.void
writeItem(Object targetObject, IJsonWritingContext context)
Write the providedtargetObject
as JSON.void
writeItem(Object value, QName currentParentName, IXmlWritingContext context)
Write the provided value as XML.
-
-
-
Method Detail
-
newDataTypeHandler
@NonNull static IDataTypeHandler newDataTypeHandler(@NonNull IBoundNamedModelInstance targetInstance, @NonNull IClassBinding classBinding)
-
newDataTypeHandler
@NonNull static IDataTypeHandler newDataTypeHandler(@NonNull IClassBinding classBinding)
-
newDataTypeHandler
@NonNull static IDataTypeHandler newDataTypeHandler(@NonNull IBoundFieldInstance property)
-
getClassBinding
IClassBinding getClassBinding()
Get the class binding associated with this handler.- Returns:
- the class binding or
null
if the property's item type is not a bound class
-
getJavaTypeAdapter
IDataTypeAdapter<?> getJavaTypeAdapter()
Get the associatedIDataTypeAdapter
, if the data type is not a complex bound object.- Returns:
- the adpater, or
null
otherwise
-
isUnwrappedValueAllowedInXml
boolean isUnwrappedValueAllowedInXml()
Indicate if the value supported by this handler allows values without an XML element wrapper.Implementations may proxy this request to the JavaTypeAdapter if it is used or return
false
otherwise.- Returns:
true
if the underlying data type is allowed to be unwrapped, orfalse
otherwise
-
isJsonKeyRequired
boolean isJsonKeyRequired()
-
readItem
@NonNull <T> T readItem(@Nullable Object parentObject, @NonNull IJsonParsingContext context) throws IOException
Parse and return the set of items from the JSON stream.An item is a complete value, which can be a
JsonToken.START_OBJECT
, or a value token.- Type Parameters:
T
- the Java type of the bound object described by this class- Parameters:
parentObject
- the parent Java object to use for serialization callbacks, ornull
if there is no parentcontext
- the JSON/YAML parser- Returns:
- the Java object representing the set of parsed items
- Throws:
IOException
- if an error occurred while parsing
-
readItem
@NonNull Object readItem(@NonNull Object parentObject, @NonNull StartElement parentName, @NonNull IXmlParsingContext context) throws IOException, XMLStreamException
Parse and return the set of items from the XML stream.- Parameters:
parentObject
- the parent Java object to use for serialization callbacksparentName
- the name of the parent (containing) elementcontext
- the XML writing context- Returns:
- the Java object representing the set of parsed items
- Throws:
IOException
- if an error occurred while writingXMLStreamException
- if an error occurred while generating the XML
-
writeItem
void writeItem(@NonNull Object targetObject, @NonNull IJsonWritingContext context) throws IOException
Write the providedtargetObject
as JSON.- Parameters:
targetObject
- the data to writecontext
- the JSON writing context- Throws:
IOException
- if an error occurred while writing
-
writeItem
void writeItem(@NonNull Object value, @NonNull QName currentParentName, @NonNull IXmlWritingContext context) throws IOException, XMLStreamException
Write the provided value as XML.- Parameters:
value
- the item to writecurrentParentName
- the name of the parent (containing) elementcontext
- the JSON serializer- Throws:
IOException
- if an error occurred while writingXMLStreamException
- if an error occurred while generating the XML
-
copyItem
@NonNull Object copyItem(@NonNull Object item, @Nullable Object parentInstance) throws BindingException
Build and return a deep copy of the provided item.- Parameters:
item
- the item to copyparentInstance
- an optional parent object to use for serialization callbacks- Returns:
- the new deep copy
- Throws:
BindingException
- if an error occurred while analyzing the bound objects
-
-