Package org.simpleframework.xml.core
Class PrimitiveScanner.EmptySection
- java.lang.Object
-
- org.simpleframework.xml.core.PrimitiveScanner.EmptySection
-
- All Implemented Interfaces:
java.lang.Iterable<java.lang.String>,Section
- Enclosing class:
- PrimitiveScanner
private static class PrimitiveScanner.EmptySection extends java.lang.Object implements Section
TheEmptySectionobject creates a section for used with primitives that has no values. No primitive can have annotations as they will be processed by a transform rather than by a schema object, this object saves memory and time.
-
-
Constructor Summary
Constructors Constructor Description EmptySection(Scanner scanner)Constructor for theEmptySectionobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAttribute(java.lang.String name)This is used to acquire the full attribute path for this section.LabelMapgetAttributes()Returns aLabelMapthat contains the details for all fields and methods marked with XML annotations.LabelgetElement(java.lang.String name)Returns the named element as aLabelobject.LabelMapgetElements()Returns aLabelMapthat contains the details for all fields and methods marked with XML annotations.java.lang.StringgetName()This is used to return the name of the section.java.lang.StringgetPath(java.lang.String name)This is used to acquire the full element path for this section.java.lang.StringgetPrefix()This is used to acquire the path prefix for the section.SectiongetSection(java.lang.String name)Returns the named section as aSectionobject.LabelgetText()This is used to acquire the text label for this section if one has been specified.booleanisSection(java.lang.String name)To differentiate between a section and an element this can be used.java.util.Iterator<java.lang.String>iterator()This will produce an interator with no elements.
-
-
-
Field Detail
-
list
private final java.util.List<java.lang.String> list
This is an empty list used to create empty iterators.
-
scanner
private final Scanner scanner
This is the source scanner object this is created for.
-
-
Constructor Detail
-
EmptySection
public EmptySection(Scanner scanner)
Constructor for theEmptySectionobject. This is used to represent a primitive where thare are no other parts to the object. This acts as a lightweight container.- Parameters:
scanner- this is the owning scanner for the section
-
-
Method Detail
-
iterator
public java.util.Iterator<java.lang.String> iterator()
This will produce an interator with no elements. No elements are returned because this represents an empty section. A non-null value is best as it avoids possible exceptions.- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.String>- Returns:
- this returns an empty iterator for the section
-
getName
public java.lang.String getName()
This is used to return the name of the section. The name is must be a valid XML element name. It is used when a style is applied to a path as the section name must be styled.
-
getPrefix
public java.lang.String getPrefix()
This is used to acquire the path prefix for the section. The path prefix is used when the section is transformed in to an XML structure. This ensures that the XML element created to represent the section contains the optional prefix.
-
getText
public Label getText()
This is used to acquire the text label for this section if one has been specified. A text label can only exist in a section if there are no elements associated with the section and the section is not composite, as in it does not contain any further sections.
-
getElements
public LabelMap getElements()
Returns aLabelMapthat contains the details for all fields and methods marked with XML annotations. All of the element annotations are considered and gathered by name in this map. Also, if there is an associatedStylefor serialization the element names are renamed with this.- Specified by:
getElementsin interfaceSection- Returns:
- returns the elements associated with this section
-
getAttributes
public LabelMap getAttributes()
Returns aLabelMapthat contains the details for all fields and methods marked with XML annotations. All of the attribute annotations are considered and gathered by name in this map. Also, if there is an associatedStylefor serialization the attribute names are renamed with this.- Specified by:
getAttributesin interfaceSection- Returns:
- returns the attributes associated with this section
-
getElement
public Label getElement(java.lang.String name)
Returns the named element as aLabelobject. For convenience this method is provided so that when iterating over the names of the elements in the section a specific one of interest can be acquired.- Specified by:
getElementin interfaceSection- Parameters:
name- the name of the element that is to be acquired- Returns:
- this returns the label associated with the name
-
getSection
public Section getSection(java.lang.String name)
Returns the named section as aSectionobject. For convenience this method is provided so that when iterating over the names of the elements in the section a specific one of interest can be acquired.- Specified by:
getSectionin interfaceSection- Parameters:
name- the name of the element that is to be acquired- Returns:
- this returns the section associated with the name
-
getPath
public java.lang.String getPath(java.lang.String name)
This is used to acquire the full element path for this section. The element path is simply the fully qualified path for this expression with the provided name appended. If this is an empty path, the provided name is returned.
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
This is used to acquire the full attribute path for this section. The attribute path is simply the fully qualified path for this expression with the provided name appended. If this is an empty path, the provided name is returned.- Specified by:
getAttributein interfaceSection- Parameters:
name- this is the name of the attribute to be used- Returns:
- a fully qualified path for the specified name
-
isSection
public boolean isSection(java.lang.String name)
To differentiate between a section and an element this can be used. When iterating over the elements within the section the names of both elements and sections are provided. So in order to determine how to interpret the structure this can be used.
-
-