Package org.simpleframework.xml.stream
Class CamelCaseStyle
java.lang.Object
org.simpleframework.xml.stream.CamelCaseStyle
- All Implemented Interfaces:
Style
The
CamelCaseStyle
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.
This styles can be used to generate camel case XML.
<ExampleElement> <ChildElement exampleAttribute='example'> <InnerElement>example</InnerElement> </ChildElement> </ExampleElement>Above the camel case 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 -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for theCamelCaseStyle
object.CamelCaseStyle
(boolean element) Constructor for theCamelCaseStyle
object.CamelCaseStyle
(boolean element, boolean attribute) Constructor for theCamelCaseStyle
object. -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute
(String name) This is used to generate the XML attribute representation of the specified name.getElement
(String name) This is used to generate the XML element representation of the specified name.void
setAttribute
(String name, String value) This is used to set the attribute values within this builder.void
setElement
(String name, String value) This is used to set the element values within this builder.
-
Field Details
-
builder
This is used to perform the actual building of tokens. -
style
This is the strategy used to generate the style tokens.
-
-
Constructor Details
-
CamelCaseStyle
public CamelCaseStyle()Constructor for theCamelCaseStyle
object. This is used to create a style that will create camel case XML attributes and elements allowing a consistent format for generated XML. By default the elements have an upper case initial character and a lower case attribute. -
CamelCaseStyle
public CamelCaseStyle(boolean element) Constructor for theCamelCaseStyle
object. This is used to create a style that will create camel case XML attributes and elements allowing a consistent format for generated XML. By default the attributes have a lower case initial character and an configurable element.- Parameters:
element
- if true the element will start as upper case
-
CamelCaseStyle
public CamelCaseStyle(boolean element, boolean attribute) Constructor for theCamelCaseStyle
object. This is used to create a style that will create camel case XML attributes and elements allowing a consistent format for generated XML. Both the attribute an elements are configurable.- Parameters:
element
- if true the element will start as upper caseattribute
- if true the attribute starts as upper case
-
-
Method Details
-
getAttribute
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
-
setAttribute
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
-
getElement
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
-
setElement
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
-