Class PrimitiveInlineList

  • All Implemented Interfaces:
    Converter, Repeater

    class PrimitiveInlineList
    extends java.lang.Object
    implements Repeater
    The PrimitiveInlineList object is used to convert a group of elements in to a collection of element entries. This is used when a containing element for a list is not required. It extracts the elements by matching elements to name of the type that the annotated field or method requires. This enables these element entries to exist as siblings to other objects within the object. One restriction is that the Root annotation for each of the types within the list must be the same.
     
        
        <entry>example one</entry>
        <entry>example two</entry>
        <entry>example three</entry>
        <entry>example four</entry>      
     
     
    For the above XML element list the element entry is used to wrap the primitive string value. This wrapping XML element is configurable and defaults to the lower case string for the name of the class it represents. So, for example, if the primitive type is an int the enclosing element will be called int.
    See Also:
    Primitive, ElementList
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Type entry
      This is the type of object that will be held in the list.
      private CollectionFactory factory
      This factory is used to create a suitable collection list.
      private java.lang.String parent
      This is the name that each list element is wrapped with.
      private Primitive root
      This performs the traversal used for object serialization.
    • Constructor Summary

      Constructors 
      Constructor Description
      PrimitiveInlineList​(Context context, Type type, Type entry, java.lang.String parent)
      Constructor for the PrimitiveInlineList object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private boolean isOverridden​(OutputNode node, java.lang.Object value)
      This is used to determine whether the specified value has been overridden by the strategy.
      java.lang.Object read​(InputNode node)
      This read method wll read the XML element list from the provided node and deserialize its children as entry types.
      java.lang.Object read​(InputNode node, java.lang.Object value)
      This read method wll read the XML element list from the provided node and deserialize its children as entry types.
      private java.lang.Object read​(InputNode node, java.util.Collection list)
      This read method wll read the XML element list from the provided node and deserialize its children as entry types.
      boolean validate​(InputNode node)
      This read method wll read the XML element list from the provided node and deserialize its children as entry types.
      void write​(OutputNode node, java.lang.Object source)
      This write method will write the specified object to the given XML element as as list entries.
      private void write​(OutputNode node, java.lang.Object source, Mode mode)
      This write method will write the specified object to the given XML element as as list entries.
      • 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 factory is used to create a suitable collection list.
      • root

        private final Primitive root
        This performs the traversal used for object serialization.
      • parent

        private final java.lang.String parent
        This is the name that each list element is wrapped with.
      • entry

        private final Type entry
        This is the type of object that will be held in the list.
    • Constructor Detail

      • PrimitiveInlineList

        public PrimitiveInlineList​(Context context,
                                   Type type,
                                   Type entry,
                                   java.lang.String parent)
        Constructor for the PrimitiveInlineList object. This is given the list type and entry type to be used. The list type is the Collection implementation that is used to collect the deserialized entry objects from the XML source.
        Parameters:
        context - this is the context object used for serialization
        type - this is the collection type for the list used
        entry - the entry type to be stored within the list
        parent - this is the name to wrap the list element with
    • Method Detail

      • read

        public java.lang.Object read​(InputNode node)
                              throws java.lang.Exception
        This read method wll read the XML element list from the provided node and deserialize its children as entry types. This will deserialize each entry type as a primitive value. In order to do this the parent string provided forms the element.
        Specified by:
        read in interface Converter
        Parameters:
        node - this is the XML element that is to be deserialized
        Returns:
        this returns the item to attach to the object contact
        Throws:
        java.lang.Exception - if a deserialized type cannot be instantiated
      • read

        public java.lang.Object read​(InputNode node,
                                     java.lang.Object value)
                              throws java.lang.Exception
        This read method wll read the XML element list from the provided node and deserialize its children as entry types. This will deserialize each entry type as a primitive value. In order to do this the parent string provided forms the element.
        Specified by:
        read in interface Converter
        Specified by:
        read in interface Repeater
        Parameters:
        node - this is the XML element that is to be deserialized
        value - this is the value to read the objects in to
        Returns:
        this returns the item to attach to the object contact
        Throws:
        java.lang.Exception - if a deserialized type cannot be instantiated
      • read

        private java.lang.Object read​(InputNode node,
                                      java.util.Collection list)
                               throws java.lang.Exception
        This read method wll read the XML element list from the provided node and deserialize its children as entry types. This will deserialize each entry type as a primitive value. In order to do this the parent string provided forms the element.
        Parameters:
        node - this is the XML element that is to be deserialized
        list - this is the collection that is to be populated
        Returns:
        this returns the item to attach to the object contact
        Throws:
        java.lang.Exception
      • validate

        public boolean validate​(InputNode node)
                         throws java.lang.Exception
        This read method wll read the XML element list from the provided node and deserialize its children as entry types. This will deserialize each entry type as a primitive value. In order to do this the parent string provided forms the element.
        Specified by:
        validate in interface Converter
        Parameters:
        node - this is the XML element that is to be deserialized
        Returns:
        this returns the item to attach to the object contact
        Throws:
        java.lang.Exception - if the class XML schema does not fully match
      • write

        public void write​(OutputNode node,
                          java.lang.Object source)
                   throws java.lang.Exception
        This write method will write the specified object to the given XML element as as list entries. Each entry within the given list must be assignable to the given primitive type. This will deserialize each entry type as a primitive value. In order to do this the parent string provided forms the element.
        Specified by:
        write in interface Converter
        Parameters:
        source - this is the source collection to be serialized
        node - this is the XML element container to be populated
        Throws:
        java.lang.Exception - throw if the object cannot be serialized
      • write

        private void write​(OutputNode node,
                           java.lang.Object source,
                           Mode mode)
                    throws java.lang.Exception
        This write method will write the specified object to the given XML element as as list entries. Each entry within the given list must be assignable to the given primitive type. This will deserialize each entry type as a primitive value. In order to do this the parent string provided forms the element.
        Parameters:
        node - this is the parent output node to write values to
        source - this is the source collection to be serialized
        mode - this is used to determine whether to output CDATA
        Throws:
        java.lang.Exception
      • isOverridden

        private boolean isOverridden​(OutputNode node,
                                     java.lang.Object value)
                              throws java.lang.Exception
        This is used to determine whether the specified value has been overridden by the strategy. If the item has been overridden then no more serialization is require for that value, this is effectively telling the serialization process to stop writing.
        Parameters:
        node - the node that a potential override is written to
        value - this is the object instance to be serialized
        Returns:
        returns true if the strategy overrides the object
        Throws:
        java.lang.Exception