com.jrefinery.report.io.simple
Class FunctionFactory

java.lang.Object
  extended bycom.jrefinery.report.io.simple.AbstractReportDefinitionHandler
      extended bycom.jrefinery.report.io.simple.FunctionFactory
All Implemented Interfaces:
org.jfree.xml.ElementDefinitionHandler, ReportDefinitionTags

public class FunctionFactory
extends AbstractReportDefinitionHandler
implements ReportDefinitionTags

The functionFactory creates functions and adds these functions to the FunctionCollection of the current report.

Author:
Thomas Morgner

Field Summary
 
Fields inherited from interface com.jrefinery.report.io.simple.ReportDefinitionTags
ALIGNMENT_ATT, BOTTOMMARGIN_ATT, COLOR_ATT, CONFIGURATION_TAG, DATAREF_TAG, DATE_FIELD_TAG, DATE_FUNCTION_TAG, DEPENCY_LEVEL_ATT, DRAWABLE_FIELD_TAG, EXPRESSION_TAG, FIELD_TAG, FIELDNAME_ATT, FIELDS_TAG, FONT_NAME_ATT, FONT_SIZE_ATT, FONT_STYLE_ATT, FORMAT_ATT, FS_BOLD, FS_EMBEDDED, FS_ENCODING, FS_ITALIC, FS_STRIKETHR, FS_UNDERLINE, FUNCTION_TAG, FUNCTIONNAME_ATT, FUNCTIONS_TAG, GENERAL_FIELD_TAG, GENERAL_FUNCTION_TAG, GROUP_FOOTER_TAG, GROUP_HEADER_TAG, GROUP_TAG, GROUPS_TAG, HEIGHT_ATT, IMAGEFIELD_TAG, IMAGEFUNCTION_TAG, IMAGEREF_TAG, IMAGEURLFIELD_TAG, IMAGEURLFUNCTION_TAG, ITEMS_TAG, LABEL_TAG, LEFTMARGIN_ATT, LINE_TAG, LINEHEIGHT, MULTILINE_FIELD_TAG, MULTILINE_FUNCTION_TAG, NAME_ATT, NULLSTRING_ATT, NUMBER_FIELD_TAG, NUMBER_FUNCTION_TAG, ORIENTATION_ATT, ORIENTATION_LANDSCAPE_VAL, ORIENTATION_PORTRAIT_VAL, ORIENTATION_REVERSE_LANDSCAPE_VAL, PAGE_FOOTER_TAG, PAGE_HEADER_TAG, PAGEFORMAT_ATT, PROPERTIES_TAG, PROPERTY_ENCODING_ATT, PROPERTY_ENCODING_TEXT, PROPERTY_REFERENCE_TAG, PROPERTY_TAG, RECTANGLE_TAG, REPEAT_HEADER, REPORT_FOOTER_TAG, REPORT_HEADER_TAG, REPORT_TAG, RESOURCEBASE_ATTR, RESOURCEFIELD_TAG, RESOURCELABEL_TAG, RIGHTMARGIN_ATT, SHAPE_FIELD_TAG, STRING_FIELD_TAG, STRING_FUNCTION_TAG, TOPMARGIN_ATT, VALIGNMENT_ATT, WIDTH_ATT
 
Constructor Summary
FunctionFactory(org.jfree.xml.Parser parser, java.lang.String finishTag)
          Creates a new function handler.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receives some (or all) of the text in the current element.
 void endElement(java.lang.String qName)
          Ends the current element.
protected  void endExpression()
          Ends the expression.
protected  void endFunction()
          Ends the function.
protected  void endFunctions()
          Ends the parsing of functions.
protected  void endProperties()
          Ends the properties parsing for the current function.
protected  void endProperty()
          Ends the definition of a single property entry.
protected  void endPropertyRef()
          Ends the definition of a single property entry.
protected  Expression getCurrentExpression()
          Returns the current expression.
protected  Function getCurrentFunction()
          Returns the function under construction.
protected  java.util.Properties getProperties()
          Returns the current properties bundle for the function that is currently created.
protected  void setCurrentExpression(Expression function)
          Sets the current expression.
protected  void setCurrentFunction(Function function)
          Defines the current function.
protected  void setProperties(java.util.Properties p)
          Sets the properties for the current function.
 void startElement(java.lang.String qName, org.xml.sax.Attributes atts)
          SAX-Handler function that is forwarded from the ReportDefinitionContentHandler.
protected  void startExpression(org.xml.sax.Attributes attr)
          Starts processing an expression element.
protected  void startFunction(org.xml.sax.Attributes attr)
          starts and loads a function by instantating the functions class.
protected  void startFunctions(org.xml.sax.Attributes atts)
          Starts a new function collection.
protected  void startProperties(org.xml.sax.Attributes atts)
          Starts the Properties tag to create a new property bundle for a function.
protected  void startProperty(org.xml.sax.Attributes atts)
          Starts a new property entry for the current function.
protected  void startPropertyRef(org.xml.sax.Attributes attr)
          Starts processing an expression element.
 
Methods inherited from class com.jrefinery.report.io.simple.AbstractReportDefinitionHandler
getContentBase, getFinishTag, getLocator, getNameGenerator, getParser, getReport
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionFactory

public FunctionFactory(org.jfree.xml.Parser parser,
                       java.lang.String finishTag)
Creates a new function handler.

Parameters:
parser - the used parser to coordinate the parsing process.
finishTag - the finish tag, that should trigger the deactivation of this parser.
Throws:
java.lang.NullPointerException - if the finishTag or the parser are null.
Method Detail

startElement

public void startElement(java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
SAX-Handler function that is forwarded from the ReportDefinitionContentHandler. StartTag-occurences of function definitions get handled by this factory. If an unknown tag is encountered, a SAXException is thrown.

Specified by:
startElement in interface org.jfree.xml.ElementDefinitionHandler
Parameters:
qName - the element name.
atts - the attributes.
Throws:
org.xml.sax.SAXException - if an unknown tag is encountered.

getProperties

protected java.util.Properties getProperties()
Returns the current properties bundle for the function that is currently created.

Returns:
the function/expression properties.

setProperties

protected void setProperties(java.util.Properties p)
Sets the properties for the current function.

Parameters:
p - the properties.

getCurrentFunction

protected Function getCurrentFunction()
Returns the function under construction.

Returns:
the function just built (or under construction).

setCurrentFunction

protected void setCurrentFunction(Function function)
Defines the current function. This function gets properties set and is then added to the report's function collection.

Parameters:
function - the function.

getCurrentExpression

protected Expression getCurrentExpression()
Returns the current expression.

Returns:
the expression just built (or under construction).

setCurrentExpression

protected void setCurrentExpression(Expression function)
Sets the current expression. This expression gets properties set and is then added to the reports expression collection.

Parameters:
function - the expression.

startProperties

protected void startProperties(org.xml.sax.Attributes atts)
                        throws org.xml.sax.SAXException
Starts the Properties tag to create a new property bundle for a function.

Parameters:
atts - the element attributes.
Throws:
org.xml.sax.SAXException - if there is an error parsing the XML.

startProperty

protected void startProperty(org.xml.sax.Attributes atts)
                      throws org.xml.sax.SAXException
Starts a new property entry for the current function.

Parameters:
atts - the element attributes.
Throws:
org.xml.sax.SAXException - if there is an error parsing the XML.

startFunctions

protected void startFunctions(org.xml.sax.Attributes atts)
                       throws org.xml.sax.SAXException
Starts a new function collection. Function collections are already contained in the report, so this function does nothing.

Parameters:
atts - the element attributes.
Throws:
org.xml.sax.SAXException - if there is an error parsing the XML.

startExpression

protected void startExpression(org.xml.sax.Attributes attr)
                        throws org.xml.sax.SAXException
Starts processing an expression element.

Parameters:
attr - the element attributes.
Throws:
org.xml.sax.SAXException - if there is an error parsing the XML.

startPropertyRef

protected void startPropertyRef(org.xml.sax.Attributes attr)
                         throws org.xml.sax.SAXException
Starts processing an expression element.

Parameters:
attr - the element attributes.
Throws:
org.xml.sax.SAXException - if there is an error parsing the XML.

startFunction

protected void startFunction(org.xml.sax.Attributes attr)
                      throws org.xml.sax.SAXException
starts and loads a function by instantating the functions class. The function must have a default constructor defined.

Parameters:
attr - the element attributes.
Throws:
org.xml.sax.SAXException - if there is an error parsing the XML.

characters

public void characters(char[] ch,
                       int start,
                       int length)
Receives some (or all) of the text in the current element.

Specified by:
characters in interface org.jfree.xml.ElementDefinitionHandler
Overrides:
characters in class AbstractReportDefinitionHandler
Parameters:
ch - the character array.
start - the first character index.
length - the length (number of valid characters).

endElement

public void endElement(java.lang.String qName)
                throws org.xml.sax.SAXException
Ends the current element.

Specified by:
endElement in interface org.jfree.xml.ElementDefinitionHandler
Parameters:
qName - the element name.
Throws:
org.xml.sax.SAXException - if there is a problem parsing the element.

endFunction

protected void endFunction()
                    throws org.xml.sax.SAXException
Ends the function. The current function is added to the report and initialized during this process.

Throws:
org.xml.sax.SAXException - if there is a problem parsing the element.

endExpression

protected void endExpression()
                      throws org.xml.sax.SAXException
Ends the expression. The current expression is added to the report and initialized during this process.

Throws:
org.xml.sax.SAXException - if there is a problem parsing the element.

endFunctions

protected void endFunctions()
                     throws org.xml.sax.SAXException
Ends the parsing of functions.

Throws:
org.xml.sax.SAXException - if there is a problem parsing the element.

endProperties

protected void endProperties()
                      throws org.xml.sax.SAXException
Ends the properties parsing for the current function. The properties are added to the current function.

Throws:
org.xml.sax.SAXException - if there is a problem parsing the element.

endProperty

protected void endProperty()
                    throws org.xml.sax.SAXException
Ends the definition of a single property entry.

Throws:
org.xml.sax.SAXException - if there is a problem parsing the element.

endPropertyRef

protected void endPropertyRef()
                       throws org.xml.sax.SAXException
Ends the definition of a single property entry.

Throws:
org.xml.sax.SAXException - if there is a problem parsing the element.