Package org.jfree.xml
Class ParserFrontend
java.lang.Object
org.jfree.xml.ParserFrontend
The reportgenerator initializes the parser and provides an interface
the the default parser.
To create a report from an URL, use
ReportGenerator.getInstance().parseReport (URL myURl, URL contentBase);
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate FrontendDefaultHandler
The report handler.private EntityResolver
The DTD.private SAXParserFactory
The parser factory.private boolean
A flag indicating whether to use a DTD to validate the xml input. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ParserFrontend
(FrontendDefaultHandler parser) Creates a new report generator. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureReader
(XMLReader reader, FrontendDefaultHandler handler) Configures the xml reader.protected FrontendDefaultHandler
createDefaultHandler
(URL contentBase) Creates a new instance of the currently set default handler and sets the contentbase for the handler tocontentBase
.Returns the ElementDefinitionHandler used for parsing reports.Returns the entity resolver.protected SAXParser
Returns a SAX parser.boolean
Returnstrue
if the report definition should be validated against the DTD, andfalse
otherwise.Parses an XML file which is loaded using the given URL.protected Object
parse
(InputSource input, URL contentBase) Parses an XML report template file.void
setDefaultHandler
(FrontendDefaultHandler handler) Sets the default handler used for parsing reports.void
setEntityResolver
(EntityResolver entityResolver) Sets the entity resolver.void
setValidateDTD
(boolean validateDTD) Sets a flag that controls whether or not the report definition is validated against the DTD.
-
Field Details
-
defaulthandler
The report handler. -
factory
The parser factory. -
entityResolver
The DTD. -
validateDTD
private boolean validateDTDA flag indicating whether to use a DTD to validate the xml input.
-
-
Constructor Details
-
ParserFrontend
Creates a new report generator. The generator uses the singleton pattern by default, so use generator.getInstance() to get the generator.- Parameters:
parser
- the parser that is used to coordinate the parsing process.
-
-
Method Details
-
isValidateDTD
public boolean isValidateDTD()Returnstrue
if the report definition should be validated against the DTD, andfalse
otherwise.- Returns:
- A boolean.
-
setValidateDTD
public void setValidateDTD(boolean validateDTD) Sets a flag that controls whether or not the report definition is validated against the DTD.- Parameters:
validateDTD
- the flag.
-
getEntityResolver
Returns the entity resolver.- Returns:
- The entity resolver.
-
setEntityResolver
Sets the entity resolver.- Parameters:
entityResolver
- the entity resolver.
-
getParser
Returns a SAX parser.- Returns:
- a SAXParser.
- Throws:
ParserConfigurationException
- if there is a problem configuring the parser.SAXException
- if there is a problem with the parser initialisation
-
setDefaultHandler
Sets the default handler used for parsing reports. This handler is used to initiate parsing.- Parameters:
handler
- the handler.
-
getDefaultHandler
Returns the ElementDefinitionHandler used for parsing reports.- Returns:
- the report handler.
-
createDefaultHandler
Creates a new instance of the currently set default handler and sets the contentbase for the handler tocontentBase
.- Parameters:
contentBase
- the content base.- Returns:
- the report handler.
-
parse
Parses an XML report template file.- Parameters:
input
- the input source.contentBase
- the content base.- Returns:
- the report.
- Throws:
ElementDefinitionException
- if an error occurred.
-
configureReader
Configures the xml reader. Use this to set features or properties before the documents get parsed.- Parameters:
handler
- the parser implementation that will handle the SAX-Callbacks.reader
- the xml reader that should be configured.
-
parse
Parses an XML file which is loaded using the given URL. All needed relative file- and resourcespecification are loaded using the URLcontentBase
as base.After the report is generated, the ReportDefinition-source and the contentbase are stored as string in the reportproperties.
- Parameters:
file
- the URL for the report template file.contentBase
- the URL for the report template content base.- Returns:
- the parsed report.
- Throws:
IOException
- if an I/O error occurs.ElementDefinitionException
- if there is a problem parsing the report template.
-