org.jcoderz.phoenix.chart2d
Class Chart2DHandlerImpl

java.lang.Object
  extended by org.jcoderz.phoenix.chart2d.Chart2DHandlerImpl
All Implemented Interfaces:
Chart2DHandler

public class Chart2DHandlerImpl
extends Object
implements Chart2DHandler

Generated implementation for documents valid against the chart2d dtd. Also give the ability to collect input data from a certain set of xml files. The format is currently quite tailored to the needs of a cruise control log file analysis. This might be opened up if further requirements come up. The format is given by the chart2d api. Look there http://chart2d.sourceforge.net/ for details. The special data collection is always started with a ! do mark the special format. For the AxisLabelText there are 2 additional attributes: count: The number of labels on the x-Axis. If the dataset contains count * 2 or more entries, n (= number of datasets / count) are put together in one label. max: The maximum number of datasets that are allowed to be put together under one label. If the number of available datasets is more than count * max the elder datasets are discarded. The element of AxisLabelText can contain a regular expression, that is used to search for the logfiles used as input datasets. The search is started recursive from the given context path. Path separators must be given as '/' characters if needed. The first group on the regular expression is used as label for the dataset. An example could be !.*log.*BUILD_([0-9]*)\.xml with would use the number after the BUILD_ as labeltext. The element of LegendLabelsTexts is the z-Axis. If the element starts with a ! character the rest must be a xpath expression returning a node set. Each node of the nodeset will build a element (and label) on the z-Axis. A valid expression could be: !/cruisecontrol/findingsummary/servicelevelxml/service/@name. The element of Data could also be an xpath expression. The handler then iterates over this for each file (dataset) and each value available for the z-Axis. The string $z is replaced by the current z-Axis value before the xpath expression is evaluated against the current file (dataset). The handler takes care for the Set, Category, Data element nesting. A valid expression could be: !/cruisecontrol/findingsummary/servicelevelxml/service[@name = '$z']/@quality. The expression should evaluate to a node that can be parsed as a float using Float.parseFloat or to a ant timestring matching the regular pattern "(([0-9]+) minutes? )?([0-9]+) seconds?" the timestring will be converted into the number of seconds. Other formats might be added.

Author:
Andreas Mandel, Netbeans Code generator.

Constructor Summary
Chart2DHandlerImpl(File dataRepository)
          A new handler for cart2d files.
 
Method Summary
 void endCategory()
          Handles the closing of Category.
 void endChart2D()
          A container element end event handling method.
 void endDataset()
          Called at the end of a dataset.
 void endGraphChart2DProperties()
          A container element end event handling method.
 void endGraphProperties()
          A container element end event handling method.
 void endLBChart2D()
          A container element end event handling method.
 void endLegendProperties()
          A container element end event handling method.
 void endLLChart2D()
          A container element end event handling method.
 void endMultiColorsProperties()
          Handles the end of the MultiColorsProperties element.
 void endPieChart2D()
          A container element end event handling method.
 void endSet()
          A container element end event handling method.
 void handleAxisLabelText(String data, Attributes meta)
          A data element event handling method.
 void handleChart2DProperties(Attributes meta)
          An empty element event handling method.
 void handleColorsCustom(String data, Attributes meta)
          A data element event handling method.
 void handleData(String data, Attributes meta)
          A data element event handling method.
 void handleGraphLabelsLinesStyle(Attributes meta)
          An empty element event handling method.
 void handleGraphNumbersLinesStyle(Attributes meta)
          An empty element event handling method.
 void handleLegendLabelsTexts(String data, Attributes meta)
          Handles the content of the LegentLablesTexts element.
 void handleObject2DProperties(Attributes meta)
          An empty element event handling method.
 void handlePieChart2DProperties(Attributes meta)
          A container element start event handling method.
 void handleWarningRegionProperties(Attributes meta)
          An empty element event handling method.
static void main(String[] args)
          Commandline interface to this handler.
 void startCategory(Attributes meta)
          Handles opening of Category a new ArrayList is created to collect inner Data elements.
 void startChart2D(Attributes meta)
          A container element start event handling method.
 void startDataset(Attributes meta)
          A container element start event handling method.
 void startGraphChart2DProperties(Attributes meta)
          A container element start event handling method.
 void startGraphProperties(Attributes meta)
          A container element start event handling method.
 void startLBChart2D(Attributes meta)
          Handles opening of LBChart2D and registeres the chart type accordingly.
 void startLegendProperties(Attributes meta)
          A container element start event handling method.
 void startLLChart2D(Attributes meta)
          A container element start event handling method.
 void startMultiColorsProperties(Attributes meta)
          Handles opening of MultiColorsProperties.
 void startPieChart2D(Attributes meta)
          A container element start event handling method.
 void startSet(Attributes meta)
          A container element start event handling method.
 void writeCache()
          Writes the xpath query cache if possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Chart2DHandlerImpl

public Chart2DHandlerImpl(File dataRepository)
A new handler for cart2d files. The repository directory is used to read input xml files and to read and store a cache file.

Parameters:
dataRepository - the directory to the logfiles, can be null.
Method Detail

main

public static void main(String[] args)
                 throws IOException
Commandline interface to this handler. Parameters should be <input file or dir> [context path] [debug]

Parameters:
args - args the commandline aruments.
Throws:
IOException - if a io problem occures.

handleGraphLabelsLinesStyle

public void handleGraphLabelsLinesStyle(Attributes meta)
                                 throws SAXException
An empty element event handling method.

Specified by:
handleGraphLabelsLinesStyle in interface Chart2DHandler
Parameters:
meta - value or null
Throws:
SAXException - in case of a parsing error.

startCategory

public void startCategory(Attributes meta)
                   throws SAXException
Handles opening of Category a new ArrayList is created to collect inner Data elements.

Specified by:
startCategory in interface Chart2DHandler
Parameters:
meta - the attributes that come with the element.
Throws:
SAXException - never.

endCategory

public void endCategory()
                 throws SAXException
Handles the closing of Category. The Category data, containing the collected Data elements is added to the corrent Set.

Specified by:
endCategory in interface Chart2DHandler
Throws:
SAXException - never.

startMultiColorsProperties

public void startMultiColorsProperties(Attributes meta)
                                throws SAXException
Handles opening of MultiColorsProperties.

Specified by:
startMultiColorsProperties in interface Chart2DHandler
Parameters:
meta - the attributes that come with the element.
Throws:
SAXException - never.

endMultiColorsProperties

public void endMultiColorsProperties()
                              throws SAXException
Handles the end of the MultiColorsProperties element. Adds the collected MultiColors to the properties.

Specified by:
endMultiColorsProperties in interface Chart2DHandler
Throws:
SAXException - never.

startLBChart2D

public void startLBChart2D(Attributes meta)
                    throws SAXException
Handles opening of LBChart2D and registeres the chart type accordingly.

Specified by:
startLBChart2D in interface Chart2DHandler
Parameters:
meta - the attributes that come with the element.
Throws:
SAXException - never.

endLBChart2D

public void endLBChart2D()
                  throws SAXException
A container element end event handling method.

Specified by:
endLBChart2D in interface Chart2DHandler
Throws:
SAXException - in case of a parsing error.

handleLegendLabelsTexts

public void handleLegendLabelsTexts(String data,
                                    Attributes meta)
                             throws SAXException
Handles the content of the LegentLablesTexts element. Special handling for xpath expressions is done here. See Chart2DHandlerImpl for details.

Specified by:
handleLegendLabelsTexts in interface Chart2DHandler
Parameters:
data - the element content.
meta - attributes set with the element.
Throws:
SAXException - if an error occurs.

startDataset

public void startDataset(Attributes meta)
                  throws SAXException
A container element start event handling method.

Specified by:
startDataset in interface Chart2DHandler
Parameters:
meta - attributes
Throws:
SAXException - in case of a parsing error.

endDataset

public void endDataset()
                throws SAXException
Called at the end of a dataset. The collected data is passed to chart2d.

Specified by:
endDataset in interface Chart2DHandler
Throws:
SAXException - if an error occures.

handlePieChart2DProperties

public void handlePieChart2DProperties(Attributes meta)
                                throws SAXException
A container element start event handling method.

Specified by:
handlePieChart2DProperties in interface Chart2DHandler
Parameters:
meta - attributes
Throws:
SAXException - in case of a parsing error.

startGraphChart2DProperties

public void startGraphChart2DProperties(Attributes meta)
                                 throws SAXException
A container element start event handling method.

Specified by:
startGraphChart2DProperties in interface Chart2DHandler
Parameters:
meta - attributes
Throws:
SAXException - in case of a parsing error.

endGraphChart2DProperties

public void endGraphChart2DProperties()
                               throws SAXException
A container element end event handling method.

Specified by:
endGraphChart2DProperties in interface Chart2DHandler
Throws:
SAXException - in case of a parsing error.

handleAxisLabelText

public void handleAxisLabelText(String data,
                                Attributes meta)
                         throws SAXException
A data element event handling method.

Specified by:
handleAxisLabelText in interface Chart2DHandler
Parameters:
data - value or null
meta - attributes
Throws:
SAXException - in case of a parsing error.

startChart2D

public void startChart2D(Attributes meta)
                  throws SAXException
A container element start event handling method.

Specified by:
startChart2D in interface Chart2DHandler
Parameters:
meta - attributes
Throws:
SAXException - in case of a parsing error.

endChart2D

public void endChart2D()
                throws SAXException
A container element end event handling method.

Specified by:
endChart2D in interface Chart2DHandler
Throws:
SAXException - in case of a parsing error.

startLLChart2D

public void startLLChart2D(Attributes meta)
                    throws SAXException
A container element start event handling method.

Specified by:
startLLChart2D in interface Chart2DHandler
Parameters:
meta - attributes
Throws:
SAXException - in case of a parsing error.

endLLChart2D

public void endLLChart2D()
                  throws SAXException
A container element end event handling method.

Specified by:
endLLChart2D in interface Chart2DHandler
Throws:
SAXException - in case of a parsing error.

handleGraphNumbersLinesStyle

public void handleGraphNumbersLinesStyle(Attributes meta)
                                  throws SAXException
An empty element event handling method.

Specified by:
handleGraphNumbersLinesStyle in interface Chart2DHandler
Parameters:
meta - value or null
Throws:
SAXException - in case of a parsing error.

handleData

public void handleData(String data,
                       Attributes meta)
                throws SAXException
A data element event handling method.

Specified by:
handleData in interface Chart2DHandler
Parameters:
data - value or null
meta - attributes
Throws:
SAXException - in case of a parsing error.

startPieChart2D

public void startPieChart2D(Attributes meta)
                     throws SAXException
A container element start event handling method.

Specified by:
startPieChart2D in interface Chart2DHandler
Parameters:
meta - attributes
Throws:
SAXException - in case of a parsing error.

endPieChart2D

public void endPieChart2D()
                   throws SAXException
A container element end event handling method.

Specified by:
endPieChart2D in interface Chart2DHandler
Throws:
SAXException - in case of a parsing error.

handleObject2DProperties

public void handleObject2DProperties(Attributes meta)
                              throws SAXException
An empty element event handling method.

Specified by:
handleObject2DProperties in interface Chart2DHandler
Parameters:
meta - value or null
Throws:
SAXException - in case of a parsing error.

handleWarningRegionProperties

public void handleWarningRegionProperties(Attributes meta)
                                   throws SAXException
An empty element event handling method.

Specified by:
handleWarningRegionProperties in interface Chart2DHandler
Parameters:
meta - value or null
Throws:
SAXException - in case of a parsing error.

handleChart2DProperties

public void handleChart2DProperties(Attributes meta)
                             throws SAXException
An empty element event handling method.

Specified by:
handleChart2DProperties in interface Chart2DHandler
Parameters:
meta - value or null
Throws:
SAXException - in case of a parsing error.

startSet

public void startSet(Attributes meta)
              throws SAXException
A container element start event handling method.

Specified by:
startSet in interface Chart2DHandler
Parameters:
meta - attributes
Throws:
SAXException - in case of a parsing error.

endSet

public void endSet()
            throws SAXException
A container element end event handling method.

Specified by:
endSet in interface Chart2DHandler
Throws:
SAXException - in case of a parsing error.

startGraphProperties

public void startGraphProperties(Attributes meta)
                          throws SAXException
A container element start event handling method.

Specified by:
startGraphProperties in interface Chart2DHandler
Parameters:
meta - attributes
Throws:
SAXException - in case of a parsing error.

endGraphProperties

public void endGraphProperties()
                        throws SAXException
A container element end event handling method.

Specified by:
endGraphProperties in interface Chart2DHandler
Throws:
SAXException - in case of a parsing error.

handleColorsCustom

public void handleColorsCustom(String data,
                               Attributes meta)
                        throws SAXException
A data element event handling method.

Specified by:
handleColorsCustom in interface Chart2DHandler
Parameters:
data - value or null
meta - attributes
Throws:
SAXException - in case of a parsing error.

startLegendProperties

public void startLegendProperties(Attributes meta)
                           throws SAXException
A container element start event handling method.

Specified by:
startLegendProperties in interface Chart2DHandler
Parameters:
meta - attributes
Throws:
SAXException - in case of a parsing error.

endLegendProperties

public void endLegendProperties()
                         throws SAXException
A container element end event handling method.

Specified by:
endLegendProperties in interface Chart2DHandler
Throws:
SAXException - in case of a parsing error.

writeCache

public void writeCache()
Writes the xpath query cache if possible.



Copyright 2007 The jCoderZ Project.