org.ujac.print
Class DocumentPrinter

java.lang.Object
  extended by org.ujac.print.DocumentPrinter
Direct Known Subclasses:
DocumentTransformHelper

public class DocumentPrinter
extends Object

Name: DocumentPrinter
Description: A class printing xml based documents.

Author:
lauerc

Constructor Summary
DocumentPrinter()
          Constructs a DocumentPrinter instance with specific attributes.
DocumentPrinter(DocumentTagFactory tagFactory)
          Constructs a DocumentPrinter instance with specific attributes.
DocumentPrinter(InputStream templateStream, Map properties)
          Constructs a DocumentPrinter instance with specific arguments.
DocumentPrinter(InputStream templateStream, Map properties, DocumentTagFactory tagFactory)
          Constructs a DocumentPrinter instance with specific arguments.
DocumentPrinter(Reader templateReader, Map properties)
          Constructs a DocumentPrinter instance with specific arguments.
DocumentPrinter(Reader templateReader, Map properties, DocumentTagFactory tagFactory)
          Constructs a DocumentPrinter instance with specific arguments.
 
Method Summary
protected  void addDefaultProperties()
          Adds default properties.
 void clearProperties()
          Clears the document property map.
protected  DocumentHandler createDocumentHandler(OutputStream outputStream)
          Creates a DocumentHandler instance for the given output stream.
protected  XMLReader createXmlReader()
          Creates a XMLReader instance.
 ContentFilter getContentFilter()
          Getter method for the the property contentFilter.
 int getExpectedNumberOfPages()
          Getter method for the the property expectedNumberOfPages.
 FormatHelper getFormatHelper()
          Gets the format helper.
 DocumentMetaData getMetaData()
          Gets the document meta data.
protected  List getModules()
          Getter method for the the property modules.
 Map getProperties()
          Gets the document properties.
 ResourceLoader getResourceLoader()
          Gets the resource loader.
 DocumentTagFactory getTagFactory()
          Getter method for the the property tagFactory.
 DocumentTagInterceptor getTagInterceptor()
          Getter method for the the property tagInterceptor.
 TemplateInterpreter getTemplateInterpreter()
          Getter method for the the property templateInterpeter.
 String getXmlReaderClass()
          Gets the XML reader implementation.
 boolean isCacheImages()
          Getter method for the the property cacheImages.
 boolean isEvaluateExpressions()
          Getter method for the the property evaluateExpressions.
 boolean isPageNumberingStartsAfterHead()
          Getter method for the the property pageNumberingStartsAfterHead.
 boolean isParseDynamicContent()
          Getter method for the the property parseDynamicContent.
 boolean isStrictlyCheckDocumentStructure()
          Getter method for the the property strictlyCheckDocumentStructure.
 boolean isTranslateEscapeSequences()
          Getter method for the the property translateEscapeSequences.
 void loadModule(String modulePath)
          Loads a module from a resource loader.
static Map loadProperties(String location)
          Loads document properties from the given location.
static void main(String[] args)
          The main method for command line access.
protected  DocumentHandler printDocument(DocumentHandler documentHandler, InputSource templateSource, List modules)
          Prints the document to the given output stream.
 DocumentHandler printDocument(OutputStream outputStream)
          Prints the document to the given output stream.
 DocumentHandler printDocument(OutputStream outputStream, boolean supportToc)
          Prints the document to the given output stream.
protected  void removeInternalDocumentProperties()
          Removes document properties, which are internally used by the DocumentHandler.
 void setCacheImages(boolean cacheImages)
          Setter method for the the property cacheImages.
 void setContentFilter(ContentFilter contentFilter)
          Setter method for the the property contentFilter.
 void setDataAccessor(DocumentDataAccessor dataAccessor)
          Sets the data accessor component.
 void setEvaluateExpressions(boolean evaluateExpressions)
          Setter method for the the property evaluateExpressions.
 void setExpectedNumberOfPages(int expectedNumberOfPages)
          Setter method for the the property expectedNumberOfPages.
 void setFormatHelper(FormatHelper formatHelper)
          Sets the format helper.
 void setMetaData(DocumentMetaData metaData)
          Sets the document meta data.
 void setPageNumberingStartsAfterHead(boolean pageNumberingStartsAfterHead)
          Setter method for the the property pageNumberingStartsAfterHead.
 void setParseDynamicContent(boolean parseDynamicContent)
          Setter method for the the property parseDynamicContent.
 void setProperties(Map properties)
          Sets the document properties.
 void setResourceLoader(ResourceLoader resourceLoader)
          Sets the resource loader.
 void setStrictlyCheckDocumentStructure(boolean strictlyCheckDocumentStructure)
          Setter method for the the property strictlyCheckDocumentStructure.
 void setTagFactory(DocumentTagFactory tagFactory)
          Setter method for the the property tagFactory.
 void setTagInterceptor(DocumentTagInterceptor tagInterceptor)
          Setter method for the the property tagInterceptor.
 void setTemplateInterpreter(TemplateInterpreter templateInterpeter)
          Setter method for the the property templateInterpeter.
 void setTemplateSource(InputStream templateStream)
          Sets the template source.
 void setTemplateSource(Reader templateReader)
          Sets the template source.
 void setTranslateEscapeSequences(boolean translateEscapeSequences)
          Setter method for the the property translateEscapeSequences.
 void setXmlReaderClass(String xmlReaderClass)
          Sets the XML reader implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentPrinter

public DocumentPrinter()
Constructs a DocumentPrinter instance with specific attributes. In case the system propery 'org.xml.sax.driver' is defined, overwrites the attribute xmlReaderClassName with that value.


DocumentPrinter

public DocumentPrinter(DocumentTagFactory tagFactory)
Constructs a DocumentPrinter instance with specific attributes. In case the system propery 'org.xml.sax.driver' is defined, overwrites the attribute xmlReaderClassName with that value.

Parameters:
tagFactory - The document tag factory.

DocumentPrinter

public DocumentPrinter(InputStream templateStream,
                       Map properties)
Constructs a DocumentPrinter instance with specific arguments.

Parameters:
templateStream - The template input stream.
properties - The document's properties.

DocumentPrinter

public DocumentPrinter(InputStream templateStream,
                       Map properties,
                       DocumentTagFactory tagFactory)
Constructs a DocumentPrinter instance with specific arguments.

Parameters:
templateStream - The template input stream.
properties - The document's properties.
tagFactory - The document tag factory.

DocumentPrinter

public DocumentPrinter(Reader templateReader,
                       Map properties)
Constructs a DocumentPrinter instance with specific arguments.

Parameters:
templateReader - The template reader.
properties - The document's properties.

DocumentPrinter

public DocumentPrinter(Reader templateReader,
                       Map properties,
                       DocumentTagFactory tagFactory)
Constructs a DocumentPrinter instance with specific arguments.

Parameters:
templateReader - The template reader.
properties - The document's properties.
tagFactory - The document tag factory.
Method Detail

getTemplateInterpreter

public TemplateInterpreter getTemplateInterpreter()
Getter method for the the property templateInterpeter.

Returns:
The current value of property templateInterpeter.

setTemplateInterpreter

public void setTemplateInterpreter(TemplateInterpreter templateInterpeter)
Setter method for the the property templateInterpeter.

Parameters:
templateInterpeter - The value to set for the property templateInterpeter.

getFormatHelper

public FormatHelper getFormatHelper()
Gets the format helper.

Returns:
The format helper.

setFormatHelper

public void setFormatHelper(FormatHelper formatHelper)
Sets the format helper.

Parameters:
formatHelper - The format helper to set.

setTemplateSource

public void setTemplateSource(InputStream templateStream)
Sets the template source.

Parameters:
templateStream - The input stream to read from.

setTemplateSource

public void setTemplateSource(Reader templateReader)
Sets the template source.

Parameters:
templateReader - The reader to read from.

getProperties

public Map getProperties()
Gets the document properties.

Returns:
The document properties.

setProperties

public void setProperties(Map properties)
Sets the document properties.

Parameters:
properties - The document's properties.

getXmlReaderClass

public String getXmlReaderClass()
Gets the XML reader implementation.

Returns:
The class name of the current XML reader implementation.

setXmlReaderClass

public void setXmlReaderClass(String xmlReaderClass)
Sets the XML reader implementation.

Parameters:
xmlReaderClass - The class name of the XML reader implementation to set, only non null values are accepted, null values are ignored.

createXmlReader

protected XMLReader createXmlReader()
                             throws SAXException
Creates a XMLReader instance.

Returns:
The created XMLReader instance.
Throws:
SAXException - If no default XMLReader class can be identified and instantiated or the class cannot be loaded, instantiated, and cast to XMLReader.

getResourceLoader

public ResourceLoader getResourceLoader()
Gets the resource loader.

Returns:
The current resource loader.

setResourceLoader

public void setResourceLoader(ResourceLoader resourceLoader)
Sets the resource loader.

Parameters:
resourceLoader - The resource loader to set.

setDataAccessor

public void setDataAccessor(DocumentDataAccessor dataAccessor)
Sets the data accessor component.

Parameters:
dataAccessor - The data accessor to set.

getTagInterceptor

public DocumentTagInterceptor getTagInterceptor()
Getter method for the the property tagInterceptor.

Returns:
The current value of property tagInterceptor.

setTagInterceptor

public void setTagInterceptor(DocumentTagInterceptor tagInterceptor)
Setter method for the the property tagInterceptor.

Parameters:
tagInterceptor - The value to set for the property tagInterceptor.

getContentFilter

public ContentFilter getContentFilter()
Getter method for the the property contentFilter.

Returns:
The current value of property contentFilter.

setContentFilter

public void setContentFilter(ContentFilter contentFilter)
Setter method for the the property contentFilter.

Parameters:
contentFilter - The value to set for the property contentFilter.

isTranslateEscapeSequences

public boolean isTranslateEscapeSequences()
Getter method for the the property translateEscapeSequences.

Returns:
The current value of property translateEscapeSequences.

setTranslateEscapeSequences

public void setTranslateEscapeSequences(boolean translateEscapeSequences)
Setter method for the the property translateEscapeSequences.

Parameters:
translateEscapeSequences - The value to set for the property translateEscapeSequences.

isParseDynamicContent

public boolean isParseDynamicContent()
Getter method for the the property parseDynamicContent.

Returns:
The current value of property parseDynamicContent.

setParseDynamicContent

public void setParseDynamicContent(boolean parseDynamicContent)
Setter method for the the property parseDynamicContent.

Parameters:
parseDynamicContent - The value to set for the property parseDynamicContent.

isEvaluateExpressions

public boolean isEvaluateExpressions()
Getter method for the the property evaluateExpressions.

Returns:
The current value of property evaluateExpressions.

setEvaluateExpressions

public void setEvaluateExpressions(boolean evaluateExpressions)
Setter method for the the property evaluateExpressions.

Parameters:
evaluateExpressions - The value to set for the property evaluateExpressions.

isCacheImages

public boolean isCacheImages()
Getter method for the the property cacheImages.

Returns:
The current value of property cacheImages.

setCacheImages

public void setCacheImages(boolean cacheImages)
Setter method for the the property cacheImages.

Parameters:
cacheImages - The value to set for the property cacheImages.

isStrictlyCheckDocumentStructure

public boolean isStrictlyCheckDocumentStructure()
Getter method for the the property strictlyCheckDocumentStructure.

Returns:
The current value of property strictlyCheckDocumentStructure.

setStrictlyCheckDocumentStructure

public void setStrictlyCheckDocumentStructure(boolean strictlyCheckDocumentStructure)
Setter method for the the property strictlyCheckDocumentStructure.

Parameters:
strictlyCheckDocumentStructure - The value to set for the property strictlyCheckDocumentStructure.

getExpectedNumberOfPages

public int getExpectedNumberOfPages()
Getter method for the the property expectedNumberOfPages.

Returns:
The current value of property expectedNumberOfPages.

setExpectedNumberOfPages

public void setExpectedNumberOfPages(int expectedNumberOfPages)
Setter method for the the property expectedNumberOfPages.

Parameters:
expectedNumberOfPages - The value to set for the property expectedNumberOfPages.

isPageNumberingStartsAfterHead

public boolean isPageNumberingStartsAfterHead()
Getter method for the the property pageNumberingStartsAfterHead.

Returns:
The current value of property pageNumberingStartsAfterHead.

setPageNumberingStartsAfterHead

public void setPageNumberingStartsAfterHead(boolean pageNumberingStartsAfterHead)
Setter method for the the property pageNumberingStartsAfterHead.

Parameters:
pageNumberingStartsAfterHead - The value to set for the property pageNumberingStartsAfterHead.

loadModule

public void loadModule(String modulePath)
                throws IOException
Loads a module from a resource loader.

Parameters:
modulePath - The path that leads to the module.
Throws:
IOException - In case the given directory couldn't be accessed.

printDocument

public DocumentHandler printDocument(OutputStream outputStream)
                              throws DocumentHandlerException,
                                     IOException
Prints the document to the given output stream.

Parameters:
outputStream - The output stream to which to write the document.
Returns:
Reference of the document handler, used for the document processing.
Throws:
DocumentHandlerException - If something went wrong at document handling.
IOException - In case something went wrong during output.

printDocument

public DocumentHandler printDocument(OutputStream outputStream,
                                     boolean supportToc)
                              throws DocumentHandlerException,
                                     IOException
Prints the document to the given output stream.

Parameters:
outputStream - The output stream to which to write the document.
supportToc - Tells whether or not to support the output of a leading table of contents. Notice: if you use this option, the document will be generated in up to three document processing steps which has negative performance impacts.
Returns:
Reference of the document handler, used for the document processing.
Throws:
DocumentHandlerException - If something went wrong at document handling.
IOException - In case something went wrong during output.

removeInternalDocumentProperties

protected void removeInternalDocumentProperties()
Removes document properties, which are internally used by the DocumentHandler.


printDocument

protected DocumentHandler printDocument(DocumentHandler documentHandler,
                                        InputSource templateSource,
                                        List modules)
                                 throws DocumentHandlerException,
                                        IOException
Prints the document to the given output stream.

Parameters:
documentHandler - The document handler to use for XML processing.
templateSource - The template to process.
modules - The modules to use.
Returns:
Reference of the document handler, used for the document processing.
Throws:
DocumentHandlerException - If something went wrong at document handling.
IOException - In case something went wrong during output.

createDocumentHandler

protected DocumentHandler createDocumentHandler(OutputStream outputStream)
Creates a DocumentHandler instance for the given output stream.

Parameters:
outputStream - The output stream to use.
Returns:
The created DocumentHandler instance.

loadProperties

public static Map loadProperties(String location)
                          throws IOException
Loads document properties from the given location.

Parameters:
location - The file system location to load the properties from.
Returns:
The map holding the parsed properties.
Throws:
IOException - In case a problem occurred while reading the properties.

clearProperties

public void clearProperties()
Clears the document property map.


addDefaultProperties

protected void addDefaultProperties()
Adds default properties.


getModules

protected List getModules()
Getter method for the the property modules.

Returns:
The current value of property modules.

main

public static void main(String[] args)
The main method for command line access.

Parameters:
args - The command line arguments.

getTagFactory

public DocumentTagFactory getTagFactory()
Getter method for the the property tagFactory.

Returns:
The current value of property tagFactory.

setTagFactory

public void setTagFactory(DocumentTagFactory tagFactory)
Setter method for the the property tagFactory.

Parameters:
tagFactory - The value to set for the property tagFactory.

getMetaData

public DocumentMetaData getMetaData()
Gets the document meta data.

Returns:
The document meta data.

setMetaData

public void setMetaData(DocumentMetaData metaData)
Sets the document meta data.

Parameters:
metaData - The XMP meta data to set.


Copyright © 2003-2004 UJAC.org. All Rights Reserved.