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
abstract class TemplateLabel extends java.lang.Object implements Label
TheTemplateLabel
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 eachLabel implementation.
-
-
Field Summary
Fields Modifier and Type Field Description private KeyBuilder
builder
This is the builder that is used to generate label keys.
-
Constructor Summary
Constructors Modifier Constructor Description protected
TemplateLabel()
Constructor for theTemplateLabel
is used to create a template for other labels.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Type
getDependent()
This is used to acquire the dependent class for this label.java.lang.String
getEntry()
This is typically used to acquire the entry value as acquired from the annotation.java.lang.Object
getKey()
This is the key used to represent this label.Label
getLabel(java.lang.Class type)
This is used to acquire theLabel
that the type provided is represented by.java.lang.String[]
getNames()
This returns aCollection
of element names.java.lang.String[]
getPaths()
This returns aCollection
of element paths.Type
getType(java.lang.Class type)
This is used to acquire theType
that the type provided is represented by.boolean
isAttribute()
This method is used to determine if the label represents an attribute.boolean
isCollection()
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
isTextList()
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 Detail
-
builder
private final KeyBuilder builder
This is the builder that is used to generate label keys.
-
-
Method Detail
-
getType
public Type getType(java.lang.Class type) throws java.lang.Exception
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
public Label getLabel(java.lang.Class type) throws java.lang.Exception
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
public java.lang.String[] getNames() throws java.lang.Exception
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
public java.lang.String[] getPaths() throws java.lang.Exception
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
public java.lang.Object getKey() throws java.lang.Exception
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
public java.lang.String getEntry() throws java.lang.Exception
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
public Type getDependent() throws java.lang.Exception
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:
java.lang.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
-
-