Package com.nomagic.magicreport.format
Class DefaultFormatter
java.lang.Object
com.nomagic.magicreport.format.DefaultFormatter
- All Implemented Interfaces:
IFormatter
- Direct Known Subclasses:
DocBookFormatter,DOCXFormatter,HTMLFormatter,LaTeXFormatter,PPTXFormatter,RTFFormatter,TextFormatter,XLSXFormatter,XMLFormatter
This class provides default implementation for any output format.
- Since:
- Jun 11, 2007 10:49:57 PM
- Version:
- 1.0 Jun 11, 2007
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PropertiesEngine properties.protected StyledDocumentStyled document.Fields inherited from interface com.nomagic.magicreport.format.IFormatter
DOT_PER_INCH -
Constructor Summary
ConstructorsConstructorDescriptionCreate a default formatter without properties.DefaultFormatter(Properties properties) Create a default formatter with specific properties. -
Method Summary
Modifier and TypeMethodDescriptionConvert an Object value into default format.static intgetImageFlag(String autoImageOption) Convert auto image option fromTemplateConstants.TEMPLATE_AUTO_IMAGEinto transformation flag.getObjectFormater(Class<?> targetType) Returns the formatter for the target type class or current formatter if target type class is not registered.Return a properties.voidregisterObjectFormatter(Class<?> targetType, IFormatter formatter) Register an object formatter to be used to format values of a given target class.voidsetProperties(Properties properties) Passes along the properties from the template engine indicating the properties to be used in formatter.voidsetStyledDocument(StyledDocument styledDocument) Set aStyledDocumentto be used with this formatter.protected voidwriteImage(Image image, String imageFormat, File outputFile, boolean forceWrite) Write an image into output file.protected voidwriteImage(Image image, String imageFormat, OutputStream outputStream, boolean forceWrite) Write an image into output stream.protected voidwriteImage(Image image, String imageFormat, OutputStream outputStream, boolean forceWrite, boolean skipDPI) Write an image into output stream.
-
Field Details
-
properties
Engine properties. -
styledDocument
Styled document.
-
-
Constructor Details
-
DefaultFormatter
public DefaultFormatter()Create a default formatter without properties. -
DefaultFormatter
Create a default formatter with specific properties.- Parameters:
properties- a template properties
-
-
Method Details
-
registerObjectFormatter
Register an object formatter to be used to format values of a given target class.- Specified by:
registerObjectFormatterin interfaceIFormatter- Parameters:
targetType- the Class object of the type to be formattedformatter- the instance of object of theIFormatterclass. If this is null, then any existing definition will be removed.
-
getObjectFormater
Returns the formatter for the target type class or current formatter if target type class is not registered.- Specified by:
getObjectFormaterin interfaceIFormatter- Parameters:
targetType- the Class object of the type to be formatted- Returns:
- the instance of object of the
IFormatterclass.
-
setProperties
Passes along the properties from the template engine indicating the properties to be used in formatter.- Parameters:
properties- Properties
-
getProperties
Return a properties.- Returns:
- the properties
-
setStyledDocument
Set aStyledDocumentto be used with this formatter.- Specified by:
setStyledDocumentin interfaceIFormatter- Parameters:
styledDocument- A {link StyledDocument}
-
writeImage
protected void writeImage(Image image, String imageFormat, OutputStream outputStream, boolean forceWrite) throws IOException Write an image into output stream.- Parameters:
image- ImageimageFormat- output image formatoutputStream- output streamforceWrite- force to write the image to output stream- Throws:
IOException- if an error occurs during writing.
-
writeImage
protected void writeImage(Image image, String imageFormat, OutputStream outputStream, boolean forceWrite, boolean skipDPI) throws IOException Write an image into output stream.- Parameters:
image- ImageimageFormat- output image formatoutputStream- output streamforceWrite- force to write the image to output streamskipDPI- skip change dpi metadata- Throws:
IOException- if an error occurs during writing.
-
writeImage
protected void writeImage(Image image, String imageFormat, File outputFile, boolean forceWrite) throws IOException Write an image into output file.- Parameters:
image- ImageimageFormat- output image formatoutputFile- output fileforceWrite- force to write the image to output stream- Throws:
IOException- if an error occurs during writing.
-
format
Convert an Object value into default format. This method always convert all value into String.- Specified by:
formatin interfaceIFormatter- Parameters:
value- converting value- Returns:
- object in default format.
-
getImageFlag
Convert auto image option fromTemplateConstants.TEMPLATE_AUTO_IMAGEinto transformation flag.- Parameters:
autoImageOption- auto image option; (value 0, 1, 2, 3)- Returns:
- transformation flag
-