org.allcolor.yahp.converter
Class CYaHPConverter

java.lang.Object
  extended by org.allcolor.yahp.converter.CYaHPConverter

public final class CYaHPConverter
extends java.lang.Object

This class convert an HTML input to a PDF.

Version:
0.94
Author:
Quentin Anciaux

Field Summary
private static int countInstance
          Number of active instance
private static CMutex countMutex
          an handle to a mutex object for thread safety
private static java.util.List fileToDeleteOnDestroy
           
private  CMutex mutex
          an handle to a mutex object for thread safety
private  java.util.Map transformers
          an handle to the known transformers
 
Constructor Summary
CYaHPConverter()
          Creates a new CYaHPConverter object.
 
Method Summary
 void convertToPdf(java.lang.String content, IHtmlToPdfTransformer.PageSize size, java.util.List hf, java.lang.String furlForBase, java.io.OutputStream out, java.util.Map fproperties)
          Convert the document in content in a PDF file.
 void convertToPdf(java.net.URL url, IHtmlToPdfTransformer.PageSize size, java.util.List hf, java.io.OutputStream out, java.util.Map fproperties)
          Convert the document pointed by url in a PDF file.
static void destroy()
          Delete the jar file from the temp directory Destroy the classloader
protected  void finalize()
          If instance count fall to 0, Delete the jar file from the temp directory, Destroy the classloader by calling the destroy method
private  IHtmlToPdfTransformer getTransformer(java.util.Map properties)
          Get a transformer.
private  void init()
          initialize the classloader, and the transformer
static void registerFileToDeleteOnDestroy(java.io.File f)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

countMutex

private static final CMutex countMutex
an handle to a mutex object for thread safety


countInstance

private static int countInstance
Number of active instance


mutex

private final CMutex mutex
an handle to a mutex object for thread safety


transformers

private java.util.Map transformers
an handle to the known transformers


fileToDeleteOnDestroy

private static java.util.List fileToDeleteOnDestroy
Constructor Detail

CYaHPConverter

public CYaHPConverter()
Creates a new CYaHPConverter object.

Method Detail

destroy

public static void destroy()
Delete the jar file from the temp directory Destroy the classloader


registerFileToDeleteOnDestroy

public static void registerFileToDeleteOnDestroy(java.io.File f)

convertToPdf

public final void convertToPdf(java.net.URL url,
                               IHtmlToPdfTransformer.PageSize size,
                               java.util.List hf,
                               java.io.OutputStream out,
                               java.util.Map fproperties)
                        throws IHtmlToPdfTransformer.CConvertException
Convert the document pointed by url in a PDF file. This method is thread safe.

Parameters:
url - Url to the document
size - PDF Page size
hf - header-footer list
out - outputstream to render into
fproperties - properties map
Throws:
IHtmlToPdfTransformer.CConvertException - if an unexpected error occurs.

convertToPdf

public final void convertToPdf(java.lang.String content,
                               IHtmlToPdfTransformer.PageSize size,
                               java.util.List hf,
                               java.lang.String furlForBase,
                               java.io.OutputStream out,
                               java.util.Map fproperties)
                        throws IHtmlToPdfTransformer.CConvertException
Convert the document in content in a PDF file. This method is thread safe.

Parameters:
content - the html document as a string
size - PDF Page size
hf - header-footer list
furlForBase - base url of the document, mandatory, must end with a '/'
out - outputstream to render into
fproperties - properties map
Throws:
IHtmlToPdfTransformer.CConvertException - if an unexpected error occurs

finalize

protected final void finalize()
                       throws java.lang.Throwable
If instance count fall to 0, Delete the jar file from the temp directory, Destroy the classloader by calling the destroy method

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - if an unexpected error occurs

init

private final void init()
initialize the classloader, and the transformer


getTransformer

private IHtmlToPdfTransformer getTransformer(java.util.Map properties)
Get a transformer.

Parameters:
properties - The properties map.
Returns:
a transformer corresponding to the criterias found in the properties map.