Class XMLTagWriter

java.lang.Object
de.hybris.bootstrap.xml.XMLTagWriter
Direct Known Subclasses:
SimpleTagWriter

public abstract class XMLTagWriter extends Object
Base class of XML tag writer classes.

This class provides the following functionality:

  • Constructor Details

    • XMLTagWriter

      public XMLTagWriter(XMLTagWriter parent)
      Creates a new optional tag writer.
      Parameters:
      parent - the parent XMLTagWriter of 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 a null value!
      Parameters:
      parent - the parent XMLTagWriter of this instance
      mandatory - true if this is a mandatory tag, false otherwise
  • Method Details

    • 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(String message)
      Logging method.
    • debug

      protected void debug(String message)
      Logging method.
    • warn

      protected void warn(String message)
      Logging method.
    • error

      protected void error(String message)
      Logging method.
    • getTagName

      protected abstract String 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 given XMLOutputter. This method is called to fill in the content between the start and end tag.
      Parameters:
      xmlOut - the XMLOutputter to write to
      object - the data object provided by the parent tag writer, may be null
      Throws:
      IOException
    • getAttributesMap

      protected Map getAttributesMap(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 the Map.
      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 method writeContent(XMLOutputter, Object) to fill in data between these two tags.
      Parameters:
      xmlOut - the XMLOutputter to write to
      object - 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 this XMLTagWriter
      Returns:
      the parent XMLTagWriter or null if no parent was declared
    • getSubTagWriterMap

      protected Map getSubTagWriterMap(boolean create)
    • addSubTagWriter

      public void addSubTagWriter(XMLTagWriter tagWriter)
      Here you can add or replace an sub-XMLTagWriter to this XMLTagWriter.
      Parameters:
      tagWriter - the new XMLTagWriter
    • addSubTagWriter

      public void addSubTagWriter(XMLTagWriter tagWriter, String type)
      Here you can add or replace an sub-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.
      Parameters:
      tagWriter - tagWriter the new XMLTagWriter
      type - the type of this XMLTagWriter
    • addSubTagWriter

      public void addSubTagWriter(String tagName, Map typeMap)
      Here you can add or replace an sub-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.
      Parameters:
      tagName - name of the tag
      typeMap - key of the Map is a type (String) and value is a XMLTagWriter
    • getAllSubTagWriter

      public Collection getAllSubTagWriter()
      Returns all tagwriter of this XMLTagWriter
      Returns:
      all tagwriter of this XMLTagWriter
    • getSubTagWriter

      public XMLTagWriter getSubTagWriter(String tagName)
      Returns the XMLTagWriter with the given tagName
      Parameters:
      tagName - name of the tag
      Returns:
      the XMLTagWriter with the given tagName
      Throws:
      IllegalArgumentException - if no XMLTagWriter was found for the given tag name
    • getSubTagWriter

      public XMLTagWriter getSubTagWriter(String tagName, String type)
      Returns the XMLTagWriter with the given tagName.
      Parameters:
      tagName - name of the tag
      type - type of the XMLTagWriter
      Returns:
      the XMLTagWriter with the given tagName
      Throws:
      IllegalArgumentException - if no XMLTagWriter was 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.