|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.topologi.diffx.format.SmartXMLFormatter
public final class SmartXMLFormatter
An XML formatter that tries to rectify the errors affecting the well-formedness of the XML.
This class will always close the elements correctly by maintaining a stack of parent elements.
Implementation note: this classes uses the namespace prefixes 'dfx' and 'del', in the future it should be possible to configure which prefixes to use for each namespace, but in this version the namespace prefix mapping is hardcoded.
Constructor Summary | |
---|---|
SmartXMLFormatter()
Creates a new formatter on the standard output. |
|
SmartXMLFormatter(Writer w)
Creates a new formatter using the specified writer. |
Method Summary | |
---|---|
void |
declarePrefixMapping(PrefixMapping mapping)
Adds the prefix mapping to this class. |
void |
delete(DiffXEvent e)
Formats the specified deleted event. |
void |
format(DiffXEvent e)
Formats the specified event. |
void |
insert(DiffXEvent e)
Formats the specified inserted event. |
void |
setConfig(DiffXConfig config)
Sets the configuration to use with this formatter. |
void |
setWriteXMLDeclaration(boolean show)
Set whether the formatter should include the XML declaration or not. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SmartXMLFormatter() throws IOException
This constructor is equivalent to:
new SmartXMLFormatter(new PrintWriter(System.out));.
IOException
- should an I/O exception occurs.System.out
,
SmartXMLFormatter(Writer)
public SmartXMLFormatter(Writer w) throws IOException
w
- The writer to use.
IOException
- should an I/O exception occurs.Method Detail |
---|
public void format(DiffXEvent e) throws IOException
DiffXFormatter
format
in interface DiffXFormatter
e
- The event to format
IOException
- Should an I/O exception occurs while formatting.public void insert(DiffXEvent e) throws IOException
DiffXFormatter
insert
in interface DiffXFormatter
e
- The event to format
IOException
- Should an I/O exception occurs while formatting.public void delete(DiffXEvent e) throws IOException
DiffXFormatter
delete
in interface DiffXFormatter
e
- The event to format
IOException
- Should an I/O exception occurs while formatting.public void setConfig(DiffXConfig config)
DiffXFormatter
setConfig
in interface DiffXFormatter
config
- The configuration to use.public void setWriteXMLDeclaration(boolean show)
XMLDiffXFormatter
setWriteXMLDeclaration
in interface XMLDiffXFormatter
show
- true
to get the formatter to write the XML declaration;
false
otherwise.public void declarePrefixMapping(PrefixMapping mapping)
declarePrefixMapping
in interface XMLDiffXFormatter
mapping
- The prefix mapping to add.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |