Package de.hybris.bootstrap.xml
Class XMLTagWriter
- java.lang.Object
-
- de.hybris.bootstrap.xml.XMLTagWriter
-
- Direct Known Subclasses:
SimpleTagWriter
public abstract class XMLTagWriter extends java.lang.ObjectBase 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
Constructors Constructor Description XMLTagWriter(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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddSubTagWriter(XMLTagWriter tagWriter)Here you can add or replace an sub-XMLTagWriterto thisXMLTagWriter.voidaddSubTagWriter(XMLTagWriter tagWriter, java.lang.String type)Here you can add or replace an sub-XMLTagWriterto thisXMLTagWriter.voidaddSubTagWriter(java.lang.String tagName, java.util.Map typeMap)Here you can add or replace an sub-XMLTagWriterto thisXMLTagWriter.protected voiddebug(java.lang.String message)Logging method.protected voiderror(java.lang.String message)Logging method.java.util.CollectiongetAllSubTagWriter()Returns all tagwriter of thisXMLTagWriterprotected java.util.MapgetAttributesMap(java.lang.Object object)Overwrite this method, if you want to specify xml attributes at the actual tag.protected XMLWritergetEnclosingWriter()protected XMLTagWritergetParent()Returns the parent of thisXMLTagWriterXMLTagWritergetSubTagWriter(java.lang.String tagName)Returns theXMLTagWriterwith the given tagNameXMLTagWritergetSubTagWriter(java.lang.String tagName, java.lang.String type)Returns theXMLTagWriterwith the given tagName.protected java.util.MapgetSubTagWriterMap(boolean create)protected abstract java.lang.StringgetTagName()Override to provide a name for the actual tag to be written.protected voidinfo(java.lang.String message)Logging method.protected booleanisDebugEnabled()Logging method.protected booleanisErrorEnabled()Logging method.protected booleanisInfoEnabled()Logging method.booleanisMandatory()Returns true if the tag is mandatory which means a non-null value must be provided when writing it.protected booleanisWarnEnabled()Logging method.protected voidwarn(java.lang.String message)Logging method.voidwrite(org.znerd.xmlenc.XMLOutputter xmlOut, java.lang.Object object)This method write the start- and endtag of your tag.protected abstract voidwriteContent(org.znerd.xmlenc.XMLOutputter xmlOut, java.lang.Object object)Here you can write out the data to the givenXMLOutputter.
-
-
-
Constructor Detail
-
XMLTagWriter
public XMLTagWriter(XMLTagWriter parent)
Creates a new optional tag writer.- Parameters:
parent- the parentXMLTagWriterof this instance, optional
-
XMLTagWriter
public XMLTagWriter(XMLTagWriter parent, boolean mandatory)
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 Detail
-
getEnclosingWriter
protected XMLWriter 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
protected void info(java.lang.String message)
Logging method.
-
debug
protected void debug(java.lang.String message)
Logging method.
-
warn
protected void warn(java.lang.String message)
Logging method.
-
error
protected void error(java.lang.String message)
Logging method.
-
getTagName
protected abstract java.lang.String getTagName()
Override to provide a name for the actual tag to be written.
-
writeContent
protected abstract void writeContent(org.znerd.xmlenc.XMLOutputter xmlOut, java.lang.Object object) throws java.io.IOExceptionHere 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:
java.io.IOException
-
getAttributesMap
protected java.util.Map getAttributesMap(java.lang.Object object)
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, java.lang.Object object) throws XMLWriteExceptionThis 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
protected XMLTagWriter getParent()
Returns the parent of thisXMLTagWriter- Returns:
- the parent
XMLTagWriterornullif no parent was declared
-
getSubTagWriterMap
protected java.util.Map getSubTagWriterMap(boolean create)
-
addSubTagWriter
public void addSubTagWriter(XMLTagWriter tagWriter)
Here you can add or replace an sub-XMLTagWriterto thisXMLTagWriter.- Parameters:
tagWriter- the newXMLTagWriter
-
addSubTagWriter
public void addSubTagWriter(XMLTagWriter tagWriter, java.lang.String type)
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
public void addSubTagWriter(java.lang.String tagName, java.util.Map typeMap)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
public java.util.Collection getAllSubTagWriter()
Returns all tagwriter of thisXMLTagWriter- Returns:
- all tagwriter of this
XMLTagWriter
-
getSubTagWriter
public XMLTagWriter getSubTagWriter(java.lang.String tagName)
Returns theXMLTagWriterwith the given tagName- Parameters:
tagName- name of the tag- Returns:
- the
XMLTagWriterwith the given tagName - Throws:
java.lang.IllegalArgumentException- if noXMLTagWriterwas found for the given tag name
-
getSubTagWriter
public XMLTagWriter getSubTagWriter(java.lang.String tagName, java.lang.String type)
Returns theXMLTagWriterwith the given tagName.- Parameters:
tagName- name of the tagtype- type of theXMLTagWriter- Returns:
- the
XMLTagWriterwith the given tagName - Throws:
java.lang.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.
-
-