org.hydrateframework
Interface XMLDocWriterParser.TestOutput

All Known Implementing Classes:
XMLDocWriterParser.TestOutputHandler
Enclosing class:
XMLDocWriterParser

public static interface XMLDocWriterParser.TestOutput

This interface is called at various points when the framework is writing out the xml document. It can be used to both prevent certain portions of the XML tree from appearing according to user defined criteria (e.g. whether a certain object meets certain criteria). It can also be used to insert user defined pieces of XML within an XML document that is being written, for example to append an additional attribute to an existing object, override 'afterAttributes' and make the necessary SAX calls on the handler to write the desired XML fragment.


Method Summary
 void afterAttributes(org.xml.sax.ContentHandler hnd, java.lang.Object o, java.lang.String xPath)
          This method is called after the attributes of an object have been written but before the object element is closed.
 void afterObject(org.xml.sax.ContentHandler hnd, java.lang.Object o, java.lang.String xPath)
          This method is called after an object has been written.
 java.lang.String[] beforeAttributes(org.xml.sax.ContentHandler hnd, java.lang.Object o, java.lang.String xPath, java.lang.String[] exclude)
          This method is called after the object element has been written, but before any of its attributes or sub-objects have been written.
 org.xml.sax.Attributes beforeObject(org.xml.sax.ContentHandler hnd, java.lang.Object o, java.lang.String xPath, org.xml.sax.Attributes attrs)
          This method is called just before an object is to be written to the SAX stream.
 java.util.Comparator getComparator(java.lang.String xPath)
          This method is called before writing out a collection of objects to determine the order they should be written in.
 

Method Detail

getComparator

java.util.Comparator getComparator(java.lang.String xPath)
This method is called before writing out a collection of objects to determine the order they should be written in.

Parameters:
xPath - the X-Path (see http://www.w3.org/TR/xpath) that indicates where we are in the object hierarchy. The final element of this path is the name of the object instance that is to be sorted.
Returns:
a comparator that can be used to order objects of the given type. Return null if the objects should not be sorted

beforeObject

org.xml.sax.Attributes beforeObject(org.xml.sax.ContentHandler hnd,
                                    java.lang.Object o,
                                    java.lang.String xPath,
                                    org.xml.sax.Attributes attrs)
This method is called just before an object is to be written to the SAX stream.

Parameters:
hnd - the content handler that is being used to write out the SAX stream. Use this if you want to write anything out before the object is written.
o - the hydrate object that is about to be written.
xPath - the X-Path (see http://www.w3.org/TR/xpath) that represents the location of the object in the XML tree.
attrs - the attributes that are about to be written as part of the object element.
Returns:
the attributes that should be written as part of the object element or null. You can do one of the following
  1. Return the attrs value as is to just write the object normally.
  2. Create a new, modified version of attrs, to remove, modify or append attributes.
  3. return null to prevent the object from being written at all.

beforeAttributes

java.lang.String[] beforeAttributes(org.xml.sax.ContentHandler hnd,
                                    java.lang.Object o,
                                    java.lang.String xPath,
                                    java.lang.String[] exclude)
This method is called after the object element has been written, but before any of its attributes or sub-objects have been written.

Parameters:
hnd - the content handler that is being used to write out the SAX stream. Use this if you want to write anything out before the object is written.
o - the hydrate object whose attributes are about to be written.
xPath - the X-Path (see http://www.w3.org/TR/xpath) that represents the location of the object in the XML tree.
exclude - the list of attribute names that will be excluded from the output. By default, this includes those attributes that form part of the key, but this list can be modified by implementations of this interface.
Returns:
the list of attribute names that should be excluded from the output file. You can do one of the following
  1. Return the exclude value as is to just write the object normally.
  2. Create a new, modified version of exclude, to remove, modify or append attributes.
  3. return null to prevent the object attributes (including sub-objects) from being written at all.

afterAttributes

void afterAttributes(org.xml.sax.ContentHandler hnd,
                     java.lang.Object o,
                     java.lang.String xPath)
This method is called after the attributes of an object have been written but before the object element is closed.

Parameters:
hnd - the content handler that is being used to write out the SAX stream. Use this if you want to write anything out before the object is written.
o - the hydrate object whose attributes are about to be written.
xPath - the X-Path (see http://www.w3.org/TR/xpath) that represents the location of the object in the XML tree.

afterObject

void afterObject(org.xml.sax.ContentHandler hnd,
                 java.lang.Object o,
                 java.lang.String xPath)
This method is called after an object has been written.

Parameters:
hnd - the content handler that is being used to write out the SAX stream. Use this if you want to write anything out before the object is written.
o - the hydrate object whose attributes are about to be written.
xPath - the X-Path (see http://www.w3.org/TR/xpath) that represents the location of the object in the XML tree.


Copyright © 2000 The Hydrate Project. All Rights Reserved.