logahawk.formatters
Class XmlNodeParentArgFormatter
java.lang.Object
logahawk.formatters.AbstractArgumentFormatter
logahawk.formatters.ParentObjectArgFormatter
logahawk.formatters.XmlNodeParentArgFormatter
- All Implemented Interfaces:
- ArgumentFormatter
public class XmlNodeParentArgFormatter
- extends ParentObjectArgFormatter
Uses a XmlNodeArgFormatter
to format XML Nodes to show their full path.
Note the formatting for an Attribute is a little different than one might expect. Given the XML document:
<root><element key="value"></root>
This will print out:
<root><element>key="value"
where the attribute is outside of the containing Element
. This preserves a true tree-based approach to the
formatting but is not quite what one might expect. (Implementing the correct behavior is involved and unless there
are significant downsides to the current implementation that I'm not aware of I'm not inclined to attempt to fix it
and unintentionally create more problems.)
This should not be added in an ArgumentFormatterContainer
with a XmlNodeArgFormatter
because both
classes have the same implementation of ParentObjectArgFormatter.canFormat(Object)
. (That means calls to AbstractArgumentFormatter.getChildObjectFormat(Object, Collection, int)
from this class, which the default of implementation of ParentObjectArgFormatter
uses, will be unable to distinguish which class should be used to format the objects.)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XmlNodeParentArgFormatter
public XmlNodeParentArgFormatter()
- Defaults the
CollectionArgFormatter
to using "" for the separator, prefix, and suffix.
XmlNodeParentArgFormatter
public XmlNodeParentArgFormatter(CollectionArgFormatter collectionArgFormatter)
- Parameters:
collectionArgFormatter
- Used to formats the final result after formatting the logged object and parents.
XmlNodeParentArgFormatter
public XmlNodeParentArgFormatter(ArgumentFormatter formatter,
CollectionArgFormatter collectionArgFormatter)
- Parameters:
formatter
- Used to format the child and parent XmlNode objects.collectionArgFormatter
- Used to formats the final result after formatting the logged object and parents.
getParent
protected Object getParent(Object obj)
- Description copied from class:
ParentObjectArgFormatter
- Returns the parent of the provided object. If there is no parent, this should return null.
- Specified by:
getParent
in class ParentObjectArgFormatter
- Parameters:
obj
- Either the original object or another parent.