Class Entry


  • class Entry
    extends java.lang.Object
    The Entry object is used to provide configuration for the serialization and deserialization of a map. Values taken from the ElementMap annotation provide a means to specify how to read and write the map as an XML element. Key and value objects can be written as composite or primitive values. Primitive key values can be written as attributes of the resulting entry and value objects can be written inline if desired.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean attribute
      Determines whether the key object is written as an attribute.
      private Contact contact
      Provides the point of contact in the object to the map.
      private static java.lang.String DEFAULT_NAME
      Provides the default name for entry XML elements of the map.
      private java.lang.String entry
      Specifies the name of the XML entry element used by the map.
      private java.lang.String key
      Specifies the name of the XML key node used by the map.
      private java.lang.Class keyType
      Provides the class XML schema used for the key objects.
      private ElementMap label
      Represents the annotation that the map object is labeled with.
      private java.lang.String value
      Specifies the name of the XML value element used by the map.
      private java.lang.Class valueType
      Provides the class XML schema used for the value objects.
    • Constructor Summary

      Constructors 
      Constructor Description
      Entry​(Contact contact, ElementMap label)
      Constructor for the Entry object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Contact getContact()
      This represents the field or method that has been annotated as a map.
      private java.lang.Class getDependent​(int index)
      Provides the dependent class for the map as taken from the specified index.
      java.lang.String getEntry()
      This is used to provide a the name of the entry XML element that wraps the key and value elements.
      java.lang.String getKey()
      This is used to provide a key XML element for each of the keys within the map.
      Converter getKey​(Context context)
      This is used to get the key converter for the entry.
      protected Type getKeyType()
      This is used to acquire the dependent key for the annotated map.
      java.lang.String getValue()
      This is used to provide a value XML element for each of the values within the map.
      Converter getValue​(Context context)
      This is used to get the value converter for the entry.
      protected Type getValueType()
      This is used to acquire the dependent value for the annotated map.
      boolean isAttribute()
      Represents whether the key value is to be an attribute or an element.
      private boolean isEmpty​(java.lang.String value)
      This method is used to determine if a root annotation value is an empty value.
      boolean isInline()
      Represents whether the value is to be written as an inline text value within the element.
      java.lang.String toString()
      This provides a textual representation of the annotated field or method for the map.
      • Methods inherited from class java.lang.Object

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

      • DEFAULT_NAME

        private static final java.lang.String DEFAULT_NAME
        Provides the default name for entry XML elements of the map.
        See Also:
        Constant Field Values
      • label

        private ElementMap label
        Represents the annotation that the map object is labeled with.
      • contact

        private Contact contact
        Provides the point of contact in the object to the map.
      • valueType

        private java.lang.Class valueType
        Provides the class XML schema used for the value objects.
      • keyType

        private java.lang.Class keyType
        Provides the class XML schema used for the key objects.
      • entry

        private java.lang.String entry
        Specifies the name of the XML entry element used by the map.
      • value

        private java.lang.String value
        Specifies the name of the XML value element used by the map.
      • key

        private java.lang.String key
        Specifies the name of the XML key node used by the map.
      • attribute

        private boolean attribute
        Determines whether the key object is written as an attribute.
    • Constructor Detail

      • Entry

        public Entry​(Contact contact,
                     ElementMap label)
        Constructor for the Entry object. This takes the element map annotation that provides configuration as to how the map is serialized and deserialized from the XML document. The entry object provides a convenient means to access the XML schema configuration using defaults where necessary.
        Parameters:
        contact - this is the point of contact to the map object
        label - the annotation the map method or field uses
    • Method Detail

      • getContact

        public Contact getContact()
        This represents the field or method that has been annotated as a map. This can be used to acquire information on the field or method. Also, as a means of reporting errors this can be used.
        Returns:
        this returns the contact associated with the map
      • isAttribute

        public boolean isAttribute()
        Represents whether the key value is to be an attribute or an element. This allows the key to be embedded within the entry XML element allowing for a more compact representation. Only primitive key objects can be represented as an attribute. For example a java.util.Date or a string could be represented as an attribute key for the generated XML.
        Returns:
        true if the key is to be inlined as an attribute
      • isInline

        public boolean isInline()
                         throws java.lang.Exception
        Represents whether the value is to be written as an inline text value within the element. This is only possible if the key has been specified as an attribute. Also, the value can only be inline if there is no wrapping value XML element specified.
        Returns:
        this returns true if the value can be written inline
        Throws:
        java.lang.Exception
      • getKey

        public Converter getKey​(Context context)
                         throws java.lang.Exception
        This is used to get the key converter for the entry. This knows whether the key type is a primitive or composite object and will provide the appropriate converter implementation. This allows the root composite map converter to concern itself with only the details of the surrounding entry object.
        Parameters:
        context - this is the root context for the serialization
        Returns:
        returns the converter used for serializing the key
        Throws:
        java.lang.Exception
      • getValue

        public Converter getValue​(Context context)
                           throws java.lang.Exception
        This is used to get the value converter for the entry. This knows whether the value type is a primitive or composite object and will provide the appropriate converter implementation. This allows the root composite map converter to concern itself with only the details of the surrounding entry object.
        Parameters:
        context - this is the root context for the serialization
        Returns:
        returns the converter used for serializing the value
        Throws:
        java.lang.Exception
      • getKeyType

        protected Type getKeyType()
                           throws java.lang.Exception
        This is used to acquire the dependent key for the annotated map. This will simply return the type that the map object is composed to hold. This must be a serializable type, that is, it must be a composite or supported primitive type.
        Returns:
        this returns the key object type for the map object
        Throws:
        java.lang.Exception
      • getValueType

        protected Type getValueType()
                             throws java.lang.Exception
        This is used to acquire the dependent value for the annotated map. This will simply return the type that the map object is composed to hold. This must be a serializable type, that is, it must be a composite or supported primitive type.
        Returns:
        this returns the value object type for the map object
        Throws:
        java.lang.Exception
      • getDependent

        private java.lang.Class getDependent​(int index)
                                      throws java.lang.Exception
        Provides the dependent class for the map as taken from the specified index. This allows the entry to fall back on generic declarations of the map if no explicit dependent types are given within the element map annotation.
        Parameters:
        index - this is the index to acquire the parameter from
        Returns:
        this returns the generic type at the specified index
        Throws:
        java.lang.Exception
      • getKey

        public java.lang.String getKey()
                                throws java.lang.Exception
        This is used to provide a key XML element for each of the keys within the map. This essentially wraps the entity to be serialized such that there is an extra XML element present. This can be used to override the default names of primitive keys, however it can also be used to wrap composite keys.
        Returns:
        this returns the key XML element for each key
        Throws:
        java.lang.Exception
      • getValue

        public java.lang.String getValue()
                                  throws java.lang.Exception
        This is used to provide a value XML element for each of the values within the map. This essentially wraps the entity to be serialized such that there is an extra XML element present. This can be used to override the default names of primitive values, however it can also be used to wrap composite values.
        Returns:
        this returns the value XML element for each value
        Throws:
        java.lang.Exception
      • getEntry

        public java.lang.String getEntry()
                                  throws java.lang.Exception
        This is used to provide a the name of the entry XML element that wraps the key and value elements. If specified the entry value specified will be used instead of the default name of the element. This is used to ensure the resulting XML is configurable to the requirements of the generated XML.
        Returns:
        this returns the entry XML element for each entry
        Throws:
        java.lang.Exception
      • isEmpty

        private boolean isEmpty​(java.lang.String value)
        This method is used to determine if a root annotation value is an empty value. Rather than determining if a string is empty be comparing it to an empty string this method allows for the value an empty string represents to be changed in future.
        Parameters:
        value - this is the value to determine if it is empty
        Returns:
        true if the string value specified is an empty value
      • toString

        public java.lang.String toString()
        This provides a textual representation of the annotated field or method for the map. Providing a textual representation allows exception messages to be reported with sufficient information.
        Overrides:
        toString in class java.lang.Object
        Returns:
        this returns the textual representation of the label