Class DateTimeAdapter
- java.lang.Object
-
- gov.nist.secauto.metaschema.core.datatype.AbstractDataTypeAdapter<TYPE,ITEM_TYPE>
-
- gov.nist.secauto.metaschema.core.datatype.AbstractCustomJavaDataTypeAdapter<DateTime,IDateTimeItem>
-
- gov.nist.secauto.metaschema.core.datatype.adapter.DateTimeAdapter
-
- All Implemented Interfaces:
IDataTypeAdapter<DateTime>
public class DateTimeAdapter extends AbstractCustomJavaDataTypeAdapter<DateTime,IDateTimeItem>
-
-
Field Summary
-
Fields inherited from class gov.nist.secauto.metaschema.core.datatype.AbstractDataTypeAdapter
DEFAULT_JSON_FIELD_NAME
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringasString(Object obj)Gets the value as a string suitable for writing as text.protected IDateTimeItemcastInternal(IAnyAtomicItem item)Attempt to cast the provided item to this adapter's item type.Class<IDateTimeItem>getItemClass()Get the java type of the associated item.com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypesgetJsonRawType()The JSON primative type of the data type.List<String>getNames()Get the metaschema type names associated with this adapter.IDateTimeItemnewItem(Object value)Construct a new item of this type using the provided value.DateTimeparse(String value)Parses a provided string.-
Methods inherited from class gov.nist.secauto.metaschema.core.datatype.AbstractCustomJavaDataTypeAdapter
copy
-
Methods inherited from class gov.nist.secauto.metaschema.core.datatype.AbstractDataTypeAdapter
canHandleQName, cast, getDefaultJsonValueKey, getJavaClass, isParsingStartElement, isUnrappedValueAllowedInXml, isXmlMixed, parse, parse, toValue, writeJsonValue, writeXmlValue, writeXmlValue
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nist.secauto.metaschema.core.datatype.IDataTypeAdapter
getPreferredName, isAtomic, parseAndSupply, parseAndSupply, parseAndSupply
-
-
-
-
Method Detail
-
getNames
public List<String> getNames()
Description copied from interface:IDataTypeAdapterGet the metaschema type names associated with this adapter. This name must be unique with respect to all other metaschema types.At least one name must be provided, with the first name being the most preferred name.
- Returns:
- the name
-
getJsonRawType
public com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes getJsonRawType()
Description copied from interface:IDataTypeAdapterThe JSON primative type of the data type.- Returns:
- the JSON data type
-
parse
public DateTime parse(String value)
Description copied from interface:IDataTypeAdapterParses a provided string. Used to parse XML attributes, simple XML character data, and JSON/YAML property values.- Parameters:
value- the string value to parse- Returns:
- the parsed data as the adapter's type
-
asString
public String asString(Object obj)
Description copied from interface:IDataTypeAdapterGets the value as a string suitable for writing as text. This is intended for data types that have a simple string-based structure in XML and JSON, such as for XML attributes or JSON keys. An adapter for a complex data structures that consist of XML elements will throw anUnsupportedOperationExceptionwhen this is called.- Specified by:
asStringin interfaceIDataTypeAdapter<DateTime>- Overrides:
asStringin classAbstractDataTypeAdapter<DateTime,IDateTimeItem>- Parameters:
obj- the data to formatted as a string- Returns:
- a string
-
getItemClass
public Class<IDateTimeItem> getItemClass()
Description copied from interface:IDataTypeAdapterGet the java type of the associated item.- Specified by:
getItemClassin interfaceIDataTypeAdapter<DateTime>- Specified by:
getItemClassin classAbstractDataTypeAdapter<DateTime,IDateTimeItem>- Returns:
- the java associated item type
-
newItem
public IDateTimeItem newItem(Object value)
Description copied from interface:IDataTypeAdapterConstruct a new item of this type using the provided value.- Specified by:
newItemin interfaceIDataTypeAdapter<DateTime>- Specified by:
newItemin classAbstractDataTypeAdapter<DateTime,IDateTimeItem>- Parameters:
value- the item's value- Returns:
- a new item
-
castInternal
protected IDateTimeItem castInternal(@NonNull IAnyAtomicItem item)
Description copied from class:AbstractDataTypeAdapterAttempt to cast the provided item to this adapter's item type.The default implementation of this will attempt to parse the provided item as a string using the
IDataTypeAdapter.parse(String)method. If this behavior is undesirable, then a subclass should override this method.- Overrides:
castInternalin classAbstractDataTypeAdapter<DateTime,IDateTimeItem>- Parameters:
item- the item to cast- Returns:
- the item casted to this adapter's item type
-
-