Package org.simpleframework.xml.stream
Class Builder
- java.lang.Object
-
- org.simpleframework.xml.stream.Builder
-
- All Implemented Interfaces:
Style
class Builder extends java.lang.Object implements Style
TheBuilder
class is used to represent an XML style that can be applied to a serialized object. A style can be used to modify the element and attribute names for the generated document. Styles can be used to generate hyphenated or camel case XML.<example-element> <child-element example-attribute='example'> <inner-element>example</inner-element> </child-element> </example-element>
Above the hyphenated XML elements and attributes can be generated from a style implementation. Styles enable the same objects to be serialized in different ways, generating different styles of XML without having to modify the class schema for that object.
-
-
Field Summary
Fields Modifier and Type Field Description private Cache<java.lang.String>
attributes
This is the cache for the constructed attribute values.private Cache<java.lang.String>
elements
This is the cache for the constructed element values.private Style
style
This is the style object used to create the values used.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getAttribute(java.lang.String name)
This is used to generate the XML attribute representation of the specified name.java.lang.String
getElement(java.lang.String name)
This is used to generate the XML element representation of the specified name.void
setAttribute(java.lang.String name, java.lang.String value)
This is used to set the attribute values within this builder.void
setElement(java.lang.String name, java.lang.String value)
This is used to set the element values within this builder.
-
-
-
Field Detail
-
attributes
private final Cache<java.lang.String> attributes
This is the cache for the constructed attribute values.
-
elements
private final Cache<java.lang.String> elements
This is the cache for the constructed element values.
-
style
private final Style style
This is the style object used to create the values used.
-
-
Constructor Detail
-
Builder
public Builder(Style style)
Constructor for theBuilder
object. This will cache values constructed from the inner style object, which allows the results from the style to retrieved quickly the second time.- Parameters:
style
- this is the internal style object to be used
-
-
Method Detail
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
This is used to generate the XML attribute representation of the specified name. Attribute names should ensure to keep the uniqueness of the name such that two different names will be styled in to two different strings.- Specified by:
getAttribute
in interfaceStyle
- Parameters:
name
- this is the attribute name that is to be styled- Returns:
- this returns the styled name of the XML attribute
-
getElement
public java.lang.String getElement(java.lang.String name)
This is used to generate the XML element representation of the specified name. Element names should ensure to keep the uniqueness of the name such that two different names will be styled in to two different strings.- Specified by:
getElement
in interfaceStyle
- Parameters:
name
- this is the element name that is to be styled- Returns:
- this returns the styled name of the XML element
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.String value)
This is used to set the attribute values within this builder. Overriding the attribute values ensures that the default algorithm does not need to determine each of the values. It allows special behaviour that the user may require for XML.- Parameters:
name
- the name of the XML attribute to be overriddenvalue
- the value that is to be used for that attribute
-
setElement
public void setElement(java.lang.String name, java.lang.String value)
This is used to set the element values within this builder. Overriding the element values ensures that the default algorithm does not need to determine each of the values. It allows special behaviour that the user may require for XML.- Parameters:
name
- the name of the XML element to be overriddenvalue
- the value that is to be used for that element
-
-