Package de.hybris.bootstrap.xml
Class XMLTagWriter
java.lang.Object
de.hybris.bootstrap.xml.XMLTagWriter
- Direct Known Subclasses:
SimpleTagWriter
Base class of XML tag writer classes.
This class provides the following functionality:
- tree structure - see
getParent() - sub writer methods - see
getSubTagWriter(String)etc - logging methods - see
debug(String)etc
-
Constructor Summary
ConstructorsConstructorDescriptionXMLTagWriter(XMLTagWriter parent) Creates a new optional tag writer.XMLTagWriter(XMLTagWriter parent, boolean mandatory) Creates a new tag writer which is either optional or mandatory. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSubTagWriter(XMLTagWriter tagWriter) Here you can add or replace an sub-XMLTagWriterto thisXMLTagWriter.voidaddSubTagWriter(XMLTagWriter tagWriter, String type) Here you can add or replace an sub-XMLTagWriterto thisXMLTagWriter.voidaddSubTagWriter(String tagName, Map typeMap) Here you can add or replace an sub-XMLTagWriterto thisXMLTagWriter.protected voidLogging method.protected voidLogging method.Returns all tagwriter of thisXMLTagWriterprotected MapgetAttributesMap(Object object) Overwrite this method, if you want to specify xml attributes at the actual tag.protected XMLWriterprotected XMLTagWriterReturns the parent of thisXMLTagWritergetSubTagWriter(String tagName) Returns theXMLTagWriterwith the given tagNamegetSubTagWriter(String tagName, String type) Returns theXMLTagWriterwith the given tagName.protected MapgetSubTagWriterMap(boolean create) protected abstract StringOverride to provide a name for the actual tag to be written.protected voidLogging method.protected booleanLogging method.protected booleanLogging method.protected booleanLogging method.booleanReturns true if the tag is mandatory which means a non-null value must be provided when writing it.protected booleanLogging method.protected voidLogging method.final voidThis method write the start- and endtag of your tag.protected abstract voidwriteContent(org.znerd.xmlenc.XMLOutputter xmlOut, Object object) Here you can write out the data to the givenXMLOutputter.
-
Constructor Details
-
XMLTagWriter
Creates a new optional tag writer.- Parameters:
parent- the parentXMLTagWriterof this instance, optional
-
XMLTagWriter
Creates a new tag writer which is either optional or mandatory. Mandatory tag writer report an error when trying to export anullvalue!- Parameters:
parent- the parentXMLTagWriterof this instancemandatory-trueif this is a mandatory tag,falseotherwise
-
-
Method Details
-
getEnclosingWriter
-
isInfoEnabled
protected boolean isInfoEnabled()Logging method. -
isDebugEnabled
protected boolean isDebugEnabled()Logging method. -
isWarnEnabled
protected boolean isWarnEnabled()Logging method. -
isErrorEnabled
protected boolean isErrorEnabled()Logging method. -
info
Logging method. -
debug
Logging method. -
warn
Logging method. -
error
Logging method. -
getTagName
Override to provide a name for the actual tag to be written. -
writeContent
protected abstract void writeContent(org.znerd.xmlenc.XMLOutputter xmlOut, Object object) throws IOException Here you can write out the data to the givenXMLOutputter. This method is called to fill in the content between the start and end tag.- Parameters:
xmlOut- theXMLOutputterto write toobject- the data object provided by the parent tag writer, may be null- Throws:
IOException
-
getAttributesMap
Overwrite this method, if you want to specify xml attributes at the actual tag. The name of the attribute has to be the key of theMap.- Parameters:
object- the data object provided by the parent tag writer, may be null- Returns:
- the attributes
Map
-
write
public final void write(org.znerd.xmlenc.XMLOutputter xmlOut, Object object) throws XMLWriteException This method write the start- and endtag of your tag. It calls the methodwriteContent(XMLOutputter, Object)to fill in data between these two tags.- Parameters:
xmlOut- theXMLOutputterto write toobject- the data object, it depends on the parent what kind of object you get here- Throws:
XMLWriteException
-
getParent
Returns the parent of thisXMLTagWriter- Returns:
- the parent
XMLTagWriterornullif no parent was declared
-
getSubTagWriterMap
-
addSubTagWriter
Here you can add or replace an sub-XMLTagWriterto thisXMLTagWriter.- Parameters:
tagWriter- the newXMLTagWriter
-
addSubTagWriter
Here you can add or replace an sub-XMLTagWriterto thisXMLTagWriter. If you have more than one subtagwriter with the same tagname, than you have to specify a type for the tagwriter, so you can indentify it in thegetSubTagWriter-method.- Parameters:
tagWriter- tagWriter the newXMLTagWritertype- the type of thisXMLTagWriter
-
addSubTagWriter
Here you can add or replace an sub-XMLTagWriterto thisXMLTagWriter. If you have more than one subtagwriter with the same tagname, than you have to specify a type for the tagwriter, so you can indentify it in thegetSubTagWriter-method.- Parameters:
tagName- name of the tagtypeMap- key of theMapis a type (String) and value is aXMLTagWriter
-
getAllSubTagWriter
Returns all tagwriter of thisXMLTagWriter- Returns:
- all tagwriter of this
XMLTagWriter
-
getSubTagWriter
Returns theXMLTagWriterwith the given tagName- Parameters:
tagName- name of the tag- Returns:
- the
XMLTagWriterwith the given tagName - Throws:
IllegalArgumentException- if noXMLTagWriterwas found for the given tag name
-
getSubTagWriter
Returns theXMLTagWriterwith the given tagName.- Parameters:
tagName- name of the tagtype- type of theXMLTagWriter- Returns:
- the
XMLTagWriterwith the given tagName - Throws:
IllegalArgumentException- if noXMLTagWriterwas found for the given tag name and type
-
isMandatory
public boolean isMandatory()Returns true if the tag is mandatory which means a non-null value must be provided when writing it.
-