com.jrefinery.report.io.ext.writer
Class AbstractXMLDefinitionWriter

java.lang.Object
  |
  +--com.jrefinery.report.io.ext.writer.AbstractXMLDefinitionWriter
Direct Known Subclasses:
FunctionsWriter, ObjectWriter, ParserConfigWriter, ReportConfigWriter, ReportDefinitionWriter, ReportDescriptionWriter, StylesWriter, StyleWriter, TemplatesWriter

public abstract class AbstractXMLDefinitionWriter
extends java.lang.Object

A base class for writer classes for the JFreeReport XML report files.

Author:
Thomas Morgner

Field Summary
static boolean CLOSE
          A constant for close.
protected static int CLOSE_TAG_DECREASE
          A int constant for controling the indent function.
protected static int INDENT_ONLY
          A int constant for controling the indent function.
static boolean OPEN
          A constant for open.
protected static int OPEN_TAG_INCREASE
          A int constant for controling the indent function.
 
Constructor Summary
AbstractXMLDefinitionWriter(ReportWriter reportWriter, int indentLevel)
          Creates a new writer.
 
Method Summary
protected  void decreaseIndent()
          Decreates the indention by one level.
protected  int getIndentLevel()
          Returns the current indent level.
static java.lang.String getLineSeparator()
          Returns the line separator.
protected  JFreeReport getReport()
          Returns the report.
protected  ReportWriter getReportWriter()
          Returns the report writer.
static SafeTagList getSafeTags()
          Returns the tags that can safely extend over several lines in the XML definition.
protected  void increaseIndent()
          Increases the indention by one level.
protected  void indent(java.io.Writer writer, int increase)
          Indent the line.
static java.lang.String normalize(java.lang.String s)
          Normalises a string, replacing certain characters with their escape sequences so that the XML text is not corrupted.
abstract  void write(java.io.Writer writer)
          Writes the report definition portion.
protected  void writeCloseTag(java.io.Writer w, java.lang.String tag)
          Writes a closing XML tag.
protected  void writeTag(java.io.Writer w, java.lang.String name)
          Writes an opening XML tag that has no attributes.
protected  void writeTag(java.io.Writer w, java.lang.String name, java.util.Properties attributes, boolean close)
          Writes an opening XML tag along with a list of attribute/value pairs.
protected  void writeTag(java.io.Writer w, java.lang.String name, java.lang.String attributeName, java.lang.String attributeValue, boolean close)
          Writes an opening XML tag with an attribute/value pair.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN_TAG_INCREASE

protected static final int OPEN_TAG_INCREASE
A int constant for controling the indent function.

See Also:
Constant Field Values

CLOSE_TAG_DECREASE

protected static final int CLOSE_TAG_DECREASE
A int constant for controling the indent function.

See Also:
Constant Field Values

INDENT_ONLY

protected static final int INDENT_ONLY
A int constant for controling the indent function.

See Also:
Constant Field Values

CLOSE

public static final boolean CLOSE
A constant for close.

See Also:
Constant Field Values

OPEN

public static final boolean OPEN
A constant for open.

See Also:
Constant Field Values
Constructor Detail

AbstractXMLDefinitionWriter

public AbstractXMLDefinitionWriter(ReportWriter reportWriter,
                                   int indentLevel)
Creates a new writer.

Parameters:
reportWriter - the report writer.
indentLevel - the current indention level.
Method Detail

getSafeTags

public static SafeTagList getSafeTags()
Returns the tags that can safely extend over several lines in the XML definition.

Returns:
The safe tags.

getLineSeparator

public static java.lang.String getLineSeparator()
Returns the line separator.

Returns:
The line separator.

getReportWriter

protected ReportWriter getReportWriter()
Returns the report writer.

Returns:
The report writer.

getReport

protected JFreeReport getReport()
Returns the report.

Returns:
The report.

writeTag

protected void writeTag(java.io.Writer w,
                        java.lang.String name)
                 throws java.io.IOException
Writes an opening XML tag that has no attributes.

Parameters:
w - the writer.
name - the tag name.
Throws:
java.io.IOException - if there is an I/O problem.

writeCloseTag

protected void writeCloseTag(java.io.Writer w,
                             java.lang.String tag)
                      throws java.io.IOException
Writes a closing XML tag.

Parameters:
w - the writer.
tag - the tag name.
Throws:
java.io.IOException - if there is an I/O problem.

writeTag

protected void writeTag(java.io.Writer w,
                        java.lang.String name,
                        java.lang.String attributeName,
                        java.lang.String attributeValue,
                        boolean close)
                 throws java.io.IOException
Writes an opening XML tag with an attribute/value pair.

Parameters:
w - the writer.
name - the tag name.
attributeName - the attribute name.
attributeValue - the attribute value.
close - controls whether the tag is closed.
Throws:
java.io.IOException - if there is an I/O problem.

writeTag

protected void writeTag(java.io.Writer w,
                        java.lang.String name,
                        java.util.Properties attributes,
                        boolean close)
                 throws java.io.IOException
Writes an opening XML tag along with a list of attribute/value pairs.

Parameters:
w - the writer.
name - the tag name.
attributes - the attributes.
close - controls whether the tag is closed.
Throws:
java.io.IOException - if there is an I/O problem.

normalize

public static java.lang.String normalize(java.lang.String s)
Normalises a string, replacing certain characters with their escape sequences so that the XML text is not corrupted.

Parameters:
s - the string.
Returns:
The normalised string.

indent

protected void indent(java.io.Writer writer,
                      int increase)
               throws java.io.IOException
Indent the line. Called for proper indenting in various places.

Parameters:
writer - the writer which should receive the indentention.
increase - the current indent level.
Throws:
java.io.IOException - if writing the stream failed.

getIndentLevel

protected int getIndentLevel()
Returns the current indent level.

Returns:
the current indent level.

increaseIndent

protected void increaseIndent()
Increases the indention by one level.


decreaseIndent

protected void decreaseIndent()
Decreates the indention by one level.


write

public abstract void write(java.io.Writer writer)
                    throws java.io.IOException,
                           ReportWriterException
Writes the report definition portion. Every DefinitionWriter handles one or more elements of the JFreeReport object tree, DefinitionWriter traverse the object tree and write the known objects or forward objects to other definition writers.

Parameters:
writer - the writer.
Throws:
java.io.IOException - if there is an I/O problem.
ReportWriterException - if the report serialisation failed.