Package org.simpleframework.xml.core
Class TemplateLabel
java.lang.Object
org.simpleframework.xml.core.TemplateLabel
- All Implemented Interfaces:
Label
- Direct Known Subclasses:
AttributeLabel
,ElementArrayLabel
,ElementLabel
,ElementListLabel
,ElementListUnionLabel
,ElementMapLabel
,ElementMapUnionLabel
,ElementUnionLabel
,TextLabel
,TextListLabel
,VersionLabel
The Label implementation.
TemplateLabel
object is used to provide stock
functions that can be used by all implementations. This ensures
there is a consistent set of behaviours for each label. It also
reduces the number of methods that need to be maintained for
each -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final KeyBuilder
This is the builder that is used to generate label keys. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor for theTemplateLabel
is used to create a template for other labels. -
Method Summary
Modifier and TypeMethodDescriptionThis is used to acquire the dependent class for this label.getEntry()
This is typically used to acquire the entry value as acquired from the annotation.getKey()
This is the key used to represent this label.This is used to acquire theLabel
that the type provided is represented by.String[]
getNames()
This returns aCollection
of element names.String[]
getPaths()
This returns aCollection
of element paths.This is used to acquire theType
that the type provided is represented by.boolean
This method is used to determine if the label represents an attribute.boolean
This is used to determine if the label is a collection.boolean
isInline()
This is used to determine whether the label represents an inline XML entity.boolean
isText()
This is used to determine if the label represents text.boolean
This is used to determine if an annotated list is a text list.boolean
isUnion()
This is used to determine if this label is a union.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.simpleframework.xml.core.Label
getAnnotation, getContact, getConverter, getDecorator, getEmpty, getExpression, getName, getOverride, getPath, getType, isData, isRequired, toString
-
Field Details
-
builder
This is the builder that is used to generate label keys.
-
-
Constructor Details
-
TemplateLabel
protected TemplateLabel()Constructor for theTemplateLabel
is used to create a template for other labels. If any of the method implementations are not as required or they should be overridden by the subclass.
-
-
Method Details
-
getType
This is used to acquire theType
that the type provided is represented by. Typically this will return the field or method represented by the label. However, in the case of unions this will provide an override type. -
getLabel
This is used to acquire theLabel
that the type provided is represented by. Typically this will return the same instance. However, in the case of unions this will look for an individual label to match the type provided. -
getNames
This returns aCollection
of element names. This will typically contain both the name and path of the label. However, if this is a union it can contain many names and paths. This method should never return null. -
getPaths
This returns aCollection
of element paths. This will typically contain only the path of the label, which is composed using thePath
annotation and the name of the label. However, if this is a union it can contain many paths. This method should never return null. -
getKey
This is the key used to represent this label. The key is used to store the parameter in hash containers. Typically the key is generated from the paths associated with the label. -
getEntry
This is typically used to acquire the entry value as acquired from the annotation. However given that the annotation this represents does not have a entry attribute this will always provide a null value for the entry string. -
getDependent
This is used to acquire the dependent class for this label. This returns null as there are no dependents to the element annotation as it can only hold primitives with no dependents.- Specified by:
getDependent
in interfaceLabel
- Returns:
- this is used to return the dependent type of null
- Throws:
Exception
-
isAttribute
public boolean isAttribute()This method is used to determine if the label represents an attribute. This is used to style the name so that elements are styled as elements and attributes are styled as required.- Specified by:
isAttribute
in interfaceLabel
- Returns:
- this is used to determine if this is an attribute
-
isCollection
public boolean isCollection()This is used to determine if the label is a collection. If the label represents a collection then any original assignment to the field or method can be written to without the need to create a new collection. This allows obscure collections to be used and also allows initial entries to be maintained.- Specified by:
isCollection
in interfaceLabel
- Returns:
- true if the label represents a collection value
-
isInline
public boolean isInline()This is used to determine whether the label represents an inline XML entity. TheElementList
annotation and theText
annotation represent inline items. This means that they contain no containing element and so can not specify overrides or special attributes. -
isText
public boolean isText()This is used to determine if the label represents text. If a label represents text it typically does not have a name, instead the empty string represents the name. Also text labels can not exist with other text labels, or elements. -
isTextList
public boolean isTextList()This is used to determine if an annotated list is a text list. A text list is a list of elements that also accepts free text. Typically this will be an element list union that will allow unstructured XML such as XHTML to be parsed.- Specified by:
isTextList
in interfaceLabel
- Returns:
- returns true if the label represents a text list
-
isUnion
public boolean isUnion()This is used to determine if this label is a union. If this is true then this label represents a number of labels and is simply a wrapper for these labels.
-