Class Entry

java.lang.Object
org.simpleframework.xml.core.Entry

class Entry extends 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
    Determines whether the key object is written as an attribute.
    private Contact
    Provides the point of contact in the object to the map.
    private static final String
    Provides the default name for entry XML elements of the map.
    private String
    Specifies the name of the XML entry element used by the map.
    private String
    Specifies the name of the XML key node used by the map.
    private Class
    Provides the class XML schema used for the key objects.
    private ElementMap
    Represents the annotation that the map object is labeled with.
    private String
    Specifies the name of the XML value element used by the map.
    private Class
    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

    Modifier and Type
    Method
    Description
    This represents the field or method that has been annotated as a map.
    private Class
    getDependent(int index)
    Provides the dependent class for the map as taken from the specified index.
    This is used to provide a the name of the entry XML element that wraps the key and value elements.
    This is used to provide a key XML element for each of the keys within the map.
    getKey(Context context)
    This is used to get the key converter for the entry.
    protected Type
    This is used to acquire the dependent key for the annotated map.
    This is used to provide a value XML element for each of the values within the map.
    getValue(Context context)
    This is used to get the value converter for the entry.
    protected Type
    This is used to acquire the dependent value for the annotated map.
    boolean
    Represents whether the key value is to be an attribute or an element.
    private boolean
    isEmpty(String value)
    This method is used to determine if a root annotation value is an empty value.
    boolean
    Represents whether the value is to be written as an inline text value within the element.
    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 Details

    • DEFAULT_NAME

      private static final String DEFAULT_NAME
      Provides the default name for entry XML elements of the map.
      See Also:
    • 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 Class valueType
      Provides the class XML schema used for the value objects.
    • keyType

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

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

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

      private 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 Details

    • 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 Details

    • 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 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:
      Exception
    • getKey

      public Converter getKey(Context context) throws 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:
      Exception
    • getValue

      public Converter getValue(Context context) throws 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:
      Exception
    • getKeyType

      protected Type getKeyType() throws 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:
      Exception
    • getValueType

      protected Type getValueType() throws 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:
      Exception
    • getDependent

      private Class getDependent(int index) throws 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:
      Exception
    • getKey

      public String getKey() throws 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:
      Exception
    • getValue

      public String getValue() throws 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:
      Exception
    • getEntry

      public String getEntry() throws 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:
      Exception
    • isEmpty

      private boolean isEmpty(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 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 Object
      Returns:
      this returns the textual representation of the label