Class TextList

  • All Implemented Interfaces:
    Converter, Repeater

    class TextList
    extends java.lang.Object
    implements Repeater
    This TextList object is a converter that is used to read free text and insert that text in to a list. Collecting free text in this way allows unstructured XML to be processed and stored in an ordered way, which will allow it to be written as identical XML during the serialization process.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private CollectionFactory factory
      This is the factory that is used to create the containing list.
      private Primitive primitive
      This is the primitive object used to read the free text.
      private Type type
      This is a string type which is used for all free text data.
    • Constructor Summary

      Constructors 
      Constructor Description
      TextList​(Context context, Type list, Label label)
      Constructor for the TextList object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object read​(InputNode node)
      The read method reads an object to a specific type from the provided node.
      java.lang.Object read​(InputNode node, java.lang.Object result)
      The read method reads an object to a specific type from the provided node.
      boolean validate​(InputNode node)
      The validate method is used to validate the class XML schema against an input source.
      void write​(OutputNode node, java.lang.Object object)
      The write method writes the fields from the given object to the XML element.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • factory

        private final CollectionFactory factory
        This is the factory that is used to create the containing list.
      • primitive

        private final Primitive primitive
        This is the primitive object used to read the free text.
      • type

        private final Type type
        This is a string type which is used for all free text data.
    • Constructor Detail

      • TextList

        public TextList​(Context context,
                        Type list,
                        Label label)
        Constructor for the TextList object. This is used to create a converter that can read free text from between elements in an ElementListUnion. Converting the free text in this way allows unstructured XML to be processed.
        Parameters:
        context - this is the context that is used for this
        list - this is the list type this will be used with
        label - this is the label this the text is declared with
    • Method Detail

      • read

        public java.lang.Object read​(InputNode node)
                              throws java.lang.Exception
        The read method reads an object to a specific type from the provided node. If the node provided is an attribute then the object must be a primitive such as a string, integer, boolean, or any of the other Java primitive types.
        Specified by:
        read in interface Converter
        Parameters:
        node - contains the details used to deserialize the object
        Returns:
        a fully deserialized object will all its fields
        Throws:
        java.lang.Exception - if a deserialized type cannot be instantiated
      • read

        public java.lang.Object read​(InputNode node,
                                     java.lang.Object result)
                              throws java.lang.Exception
        The read method reads an object to a specific type from the provided node. If the node provided is an attribute then the object must be a primitive such as a string, integer, boolean, or any of the other Java primitive types.
        Specified by:
        read in interface Converter
        Specified by:
        read in interface Repeater
        Parameters:
        node - contains the details used to deserialize the object
        value - this is the value to read the objects in to
        Returns:
        a fully deserialized object will all its fields
        Throws:
        java.lang.Exception - if a deserialized type cannot be instantiated
      • validate

        public boolean validate​(InputNode node)
                         throws java.lang.Exception
        The validate method is used to validate the class XML schema against an input source. This will traverse the class fields and methods ensuring that the input XML document contains a valid structure when compared against the class XML schema.
        Specified by:
        validate in interface Converter
        Parameters:
        node - contains the details used to validate the object
        Returns:
        true if the document matches the class XML schema
        Throws:
        java.lang.Exception - if the class XML schema does not fully match
      • write

        public void write​(OutputNode node,
                          java.lang.Object object)
                   throws java.lang.Exception
        The write method writes the fields from the given object to the XML element. After this has finished the element contains all attributes and sub-elements from the object.
        Specified by:
        write in interface Converter
        Parameters:
        object - this is the object to be written to the element
        node - this is the element that is to be populated
        Throws:
        java.lang.Exception - throw if the object cannot be serialized