public abstract class XMLTagWriter extends Object
This class provides the following functionality:
getParent()getSubTagWriter(String) etcdebug(String) etc
| Constructor and 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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addSubTagWriter(String tagName,
Map typeMap)
Here you can add or replace an sub-
XMLTagWriter to this XMLTagWriter. |
void |
addSubTagWriter(XMLTagWriter tagWriter)
Here you can add or replace an sub-
XMLTagWriter to this XMLTagWriter. |
void |
addSubTagWriter(XMLTagWriter tagWriter,
String type)
Here you can add or replace an sub-
XMLTagWriter to this XMLTagWriter. |
protected void |
debug(String message)
Logging method.
|
protected void |
error(String message)
Logging method.
|
Collection |
getAllSubTagWriter()
Returns all tagwriter of this
XMLTagWriter |
protected Map |
getAttributesMap(Object object)
Overwrite this method, if you want to specify xml attributes at the actual tag.
|
protected XMLWriter |
getEnclosingWriter() |
protected XMLTagWriter |
getParent()
Returns the parent of this
XMLTagWriter |
XMLTagWriter |
getSubTagWriter(String tagName)
Returns the
XMLTagWriter with the given tagName |
XMLTagWriter |
getSubTagWriter(String tagName,
String type)
Returns the
XMLTagWriter with the given tagName. |
protected Map |
getSubTagWriterMap(boolean create) |
protected abstract String |
getTagName()
Override to provide a name for the actual tag to be written.
|
protected void |
info(String message)
Logging method.
|
protected boolean |
isDebugEnabled()
Logging method.
|
protected boolean |
isErrorEnabled()
Logging method.
|
protected boolean |
isInfoEnabled()
Logging method.
|
boolean |
isMandatory()
Returns true if the tag is mandatory which means a non-null value must be provided when writing it.
|
protected boolean |
isWarnEnabled()
Logging method.
|
protected void |
warn(String message)
Logging method.
|
void |
write(XMLOutputter xmlOut,
Object object)
This method write the start- and endtag of your tag.
|
protected abstract void |
writeContent(XMLOutputter xmlOut,
Object object)
Here you can write out the data to the given
XMLOutputter. |
public XMLTagWriter(XMLTagWriter parent)
parent - the parent XMLTagWriter of this instance, optionalpublic XMLTagWriter(XMLTagWriter parent, boolean mandatory)
null value!parent - the parent XMLTagWriter of this instancemandatory - true if this is a mandatory tag, false otherwiseprotected XMLWriter getEnclosingWriter()
protected boolean isInfoEnabled()
protected boolean isDebugEnabled()
protected boolean isWarnEnabled()
protected boolean isErrorEnabled()
protected void info(String message)
protected void debug(String message)
protected void warn(String message)
protected void error(String message)
protected abstract String getTagName()
protected abstract void writeContent(XMLOutputter xmlOut,
Object object)
throws IOException
XMLOutputter. This method is called to fill in the
content between the start and end tag.xmlOut - the XMLOutputter to write toobject - the data object provided by the parent tag writer, may be nullIOExceptionprotected Map getAttributesMap(Object object)
Map.object - the data object provided by the parent tag writer, may be nullMappublic final void write(XMLOutputter xmlOut,
Object object)
throws XMLWriteException
writeContent(XMLOutputter, Object) to fill in data between these two tags.xmlOut - the XMLOutputter to write toobject - the data object, it depends on the parent what kind of object you get hereXMLWriteExceptionprotected XMLTagWriter getParent()
XMLTagWriterXMLTagWriter or null if no parent was declaredprotected Map getSubTagWriterMap(boolean create)
public void addSubTagWriter(XMLTagWriter tagWriter)
XMLTagWriter to this XMLTagWriter.tagWriter - the new XMLTagWriterpublic void addSubTagWriter(XMLTagWriter tagWriter, String type)
XMLTagWriter to this XMLTagWriter. 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 the getSubTagWriter-method.tagWriter - tagWriter the new XMLTagWritertype - the type of this XMLTagWriterpublic void addSubTagWriter(String tagName, Map typeMap)
XMLTagWriter to this XMLTagWriter. 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 the getSubTagWriter-method.tagName - name of the tagtypeMap - key of the Map is a type (String) and value is a XMLTagWriterpublic Collection getAllSubTagWriter()
XMLTagWriterXMLTagWriterpublic XMLTagWriter getSubTagWriter(String tagName)
XMLTagWriter with the given tagNametagName - name of the tagXMLTagWriter with the given tagNameIllegalArgumentException - if no XMLTagWriter was found for the given tag namepublic XMLTagWriter getSubTagWriter(String tagName, String type)
XMLTagWriter with the given tagName.tagName - name of the tagtype - type of the XMLTagWriterXMLTagWriter with the given tagNameIllegalArgumentException - if no XMLTagWriter was found for the given tag name and typepublic boolean isMandatory()
Copyright © 2017 SAP SE. All Rights Reserved.