Package com.day.cq.commons
Class SimpleXml.Element
- java.lang.Object
-
- com.day.cq.commons.SimpleXml.Element
-
- Enclosing class:
- SimpleXml
public class SimpleXml.Element extends java.lang.ObjectTheSimpleXml.Elementreperesents an XML element.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleXml.ElementaddAttribute(java.lang.String uri, java.lang.String localName, java.lang.String name, java.lang.String value, java.lang.String type)Adds a new attribute to the XML element.SimpleXml.Elementattr(java.lang.String name, java.lang.String value)Adds a new attribute to the XML element.SimpleXml.Elementattr(java.lang.String localName, java.lang.String name, java.lang.String value)Adds a new attribute to the XML element.SimpleXml.Elementattr(java.lang.String uri, java.lang.String localName, java.lang.String name, java.lang.String value, java.lang.String type)Adds a new attribute to the XML element.SimpleXml.Elementattrs(java.lang.String[]... atts)Adds the specified attributes to the XML element.SimpleXmlclose()Explicitly closes the XML element.booleanhasCDATA()States whether the XML element has a CDATA block.SimpleXmlopen()Explicitly opens the XML element.SimpleXml.Elementopen(java.lang.String name)Opens and returns a new XML element with the specified name.SimpleXml.Elementopen(java.lang.String localName, java.lang.String name)Opens and returns a new XML element with the specified name.SimpleXml.Elementopen(java.lang.String name, java.lang.String content, boolean cdata)Opens and returns a new XML element with the specified name and content.SimpleXml.Elementopen(java.lang.String uri, java.lang.String localName, java.lang.String name)Opens and returns a new XML element with the specified name.SimpleXml.ElementsetCDATA(boolean cdata)Defines whether the XML element has a CDATA block.SimpleXml.ElementsetText(java.lang.String text, boolean cdata)Sets the content of the XML element.SimpleXml.Elementtext(java.lang.String text)Sets the content of the XML element.SimpleXml.Elementtext(java.lang.String text, boolean cdata)Sets the content of the XML element.
-
-
-
Method Detail
-
attr
public SimpleXml.Element attr(java.lang.String name, java.lang.String value)
Adds a new attribute to the XML element. This method is a shorthand foraddAttribute(String, String, String, String, String).- Parameters:
name- The name of the attributevalue- The value of the attribute- Returns:
- The XML element
-
attr
public SimpleXml.Element attr(java.lang.String localName, java.lang.String name, java.lang.String value)
Adds a new attribute to the XML element. This method is a shorthand foraddAttribute(String, String, String, String, String).- Parameters:
localName- The local name of the attributename- The name of the attributevalue- The value of the attribute- Returns:
- The XML element
-
attr
public SimpleXml.Element attr(java.lang.String uri, java.lang.String localName, java.lang.String name, java.lang.String value, java.lang.String type)
Adds a new attribute to the XML element. This method is a shorthand foraddAttribute(String, String, String, String, String).- Parameters:
uri- The URI of the attributelocalName- The local name of the attributename- The name of the attributevalue- The value of the attributetype- The type of the attribute- Returns:
- The XML element
-
attrs
public SimpleXml.Element attrs(java.lang.String[]... atts)
Adds the specified attributes to the XML element.- Parameters:
atts- The attributes- Returns:
- The XML element
-
addAttribute
public SimpleXml.Element addAttribute(java.lang.String uri, java.lang.String localName, java.lang.String name, java.lang.String value, java.lang.String type)
Adds a new attribute to the XML element.- Parameters:
uri- The URI of the attributelocalName- The local name of the attributename- The name of the attributevalue- The value of the attributetype- The type of the attribute- Returns:
- The XML element
-
text
public SimpleXml.Element text(java.lang.String text)
Sets the content of the XML element. This method is a shorthand forsetText(String, boolean).- Parameters:
text- The content- Returns:
- The XML element
-
text
public SimpleXml.Element text(java.lang.String text, boolean cdata)
Sets the content of the XML element. This method is a shorthand forsetText(String, boolean).- Parameters:
text- The contentcdata-trueif content should be in a CDATA block,falseotherwise- Returns:
- The XML element
-
setText
public SimpleXml.Element setText(java.lang.String text, boolean cdata)
Sets the content of the XML element.- Parameters:
text- The contentcdata-trueif content should be in a CDATA block,falseotherwise- Returns:
- The XML element
-
setCDATA
public SimpleXml.Element setCDATA(boolean cdata)
Defines whether the XML element has a CDATA block.- Parameters:
cdata-trueif the XML element has a CDATA block,falseotherwise- Returns:
- The XML element
-
open
public SimpleXml open() throws java.io.IOException
Explicitly opens the XML element. No more attributes can be added to the XML element after calling this method.- Returns:
- The XML writer
- Throws:
java.io.IOException- If output fails
-
open
public SimpleXml.Element open(java.lang.String name) throws java.io.IOException
Opens and returns a new XML element with the specified name. This method can be used for chaining. It opens the current XML element, then calls its equivalent inSimpleXml.- Parameters:
name- The name of the XML element- Returns:
- The XML element
- Throws:
java.io.IOException- If output fails- See Also:
SimpleXml.open(String)
-
open
public SimpleXml.Element open(java.lang.String localName, java.lang.String name) throws java.io.IOException
Opens and returns a new XML element with the specified name. This method can be used for chaining. It opens the current XML element, then calls its equivalent inSimpleXml.- Parameters:
localName- The local name of the XML elementname- The name of the XML element- Returns:
- The XML element
- Throws:
java.io.IOException- If output fails- See Also:
SimpleXml.open(String, String)
-
open
public SimpleXml.Element open(java.lang.String uri, java.lang.String localName, java.lang.String name) throws java.io.IOException
Opens and returns a new XML element with the specified name. This method can be used for chaining. It opens the current XML element, then calls its equivalent inSimpleXml.- Parameters:
uri- The URI of the XML elementlocalName- The local name of the XML elementname- The name of the XML element- Returns:
- The XML element
- Throws:
java.io.IOException- If output fails- See Also:
SimpleXml.open(String, String, String)
-
open
public SimpleXml.Element open(java.lang.String name, java.lang.String content, boolean cdata) throws java.io.IOException
Opens and returns a new XML element with the specified name and content. This method can be used for chaining. It opens the current XML element, then calls its equivalent inSimpleXml.- Parameters:
name- The name of the XML elementcontent- The content of the XML elementcdata-trueif content should be in a CDATA block,falseotherwise- Returns:
- The XML element
- Throws:
java.io.IOException- If output fails- See Also:
SimpleXml.open(String, String, boolean)
-
close
public SimpleXml close() throws java.io.IOException
Explicitly closes the XML element. This method will write the XML element and consequently render it immutable.- Returns:
- The XML writer
- Throws:
java.io.IOException- If output fails
-
hasCDATA
public boolean hasCDATA()
States whether the XML element has a CDATA block.- Returns:
trueif the XML element has a CDATA block,falseotherwise
-
-