Package org.simpleframework.xml.core
Class Entry
java.lang.Object
org.simpleframework.xml.core.Entry
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
FieldsModifier and TypeFieldDescriptionprivate 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 -
Method Summary
Modifier and TypeMethodDescriptionThis 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.getEntry()
This is used to provide a the name of the entry XML element that wraps the key and value elements.getKey()
This is used to provide a key XML element for each of the keys within the map.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.getValue()
This is used to provide a value XML element for each of the values within the map.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
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.toString()
This provides a textual representation of the annotated field or method for the map.
-
Field Details
-
DEFAULT_NAME
Provides the default name for entry XML elements of the map.- See Also:
-
label
Represents the annotation that the map object is labeled with. -
contact
Provides the point of contact in the object to the map. -
valueType
Provides the class XML schema used for the value objects. -
keyType
Provides the class XML schema used for the key objects. -
entry
Specifies the name of the XML entry element used by the map. -
value
Specifies the name of the XML value element used by the map. -
key
Specifies the name of the XML key node used by the map. -
attribute
private boolean attributeDetermines whether the key object is written as an attribute.
-
-
Constructor Details
-
Entry
Constructor for theEntry
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 objectlabel
- the annotation the map method or field uses
-
-
Method Details
-
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 ajava.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
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
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
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
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
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
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
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
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
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
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
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.
-