Interface IDataTypeHandler

    • Method Detail

      • 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
      • 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, or false otherwise
      • 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, or null if there is no parent
        context - 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 callbacks
        parentName - the name of the parent (containing) element
        context - the XML writing context
        Returns:
        the Java object representing the set of parsed items
        Throws:
        IOException - if an error occurred while writing
        XMLStreamException - if an error occurred while generating the XML
      • writeItem

        void writeItem​(@NonNull
                       Object targetObject,
                       @NonNull
                       IJsonWritingContext context)
                throws IOException
        Write the provided targetObject as JSON.
        Parameters:
        targetObject - the data to write
        context - the JSON writing context
        Throws:
        IOException - if an error occurred while writing
      • 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 copy
        parentInstance - 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