Docmosis API 4.5.0

com.docmosis.template.store
Class TemplateStoreFactory.PresetTemplateStore

java.lang.Object
  extended bycom.docmosis.template.store.TemplateStoreFactory.PresetTemplateStore
All Implemented Interfaces:
TemplateStore
Enclosing class:
TemplateStoreFactory

public static class TemplateStoreFactory.PresetTemplateStore
extends Object
implements TemplateStore

This class facades a real TemplateStore providing values for typical settings that one might use across lots of store requests.


Method Summary
 void deleteAll()
          Delete all templates in the store.
 void deleteTemplate(TemplateIdentifier templateId)
          Delete the given template from the store.
 void deleteTemplates(TemplateContext context, boolean includeSubContexts)
          Delete all templates in the given context.
 boolean equals(Object obj)
           
 TemplateDetails[] findByContext(TemplateContext templateContext, boolean includeSubContexts)
          Get the list of templates for the given context.
 InputStream getOriginalTemplate(TemplateIdentifier templateId)
          Get the original template provided in storeTemplate().
 Template getTemplate(TemplateIdentifier templateId)
          Get the (working) template identified by the given templateId.
 TemplateAnalysis getTemplateAnalysis(TemplateIdentifier templateId)
          Get the template analysis for the template identified by the given template info.
 long getTemplateStoredTime(TemplateIdentifier templateId)
          Return the time that the template was stored in this template store.
 int hashCode()
           
 TemplateDetails storeTemplate(TemplateIdentifier templateId, InputStream origTemplateSource, InputStream workingTemplateSource, TemplateAnalysis analysis, InputStream thumbnail, boolean overwrite, boolean templateErrorsFatal, String plainTextFieldPrefix, String plainTextFieldSuffix, boolean allowPaddedFields)
          Store the given InputStream as a template using the given templateId.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hashCode

public int hashCode()

equals

public boolean equals(Object obj)

deleteAll

public void deleteAll()
               throws TemplateStoreException
Description copied from interface: TemplateStore
Delete all templates in the store. If no templates exist, then no action is taken.

Specified by:
deleteAll in interface TemplateStore
Throws:
TemplateStoreException - if any of the templates could not be deleted

deleteTemplate

public void deleteTemplate(TemplateIdentifier templateId)
                    throws TemplateStoreException
Description copied from interface: TemplateStore
Delete the given template from the store. If the template does not exist, then no action is taken.

Specified by:
deleteTemplate in interface TemplateStore
Parameters:
templateId - the identifier for the template
Throws:
TemplateStoreException - if the template could not be deleted.

deleteTemplates

public void deleteTemplates(TemplateContext context,
                            boolean includeSubContexts)
                     throws TemplateStoreException
Description copied from interface: TemplateStore
Delete all templates in the given context. If the context does not exist then no action is taken.

Specified by:
deleteTemplates in interface TemplateStore
Parameters:
context - the template context in which all templates are to be deleted
includeSubContexts - if true all templates in contexts under the given context will also be deleted.
Throws:
TemplateStoreException - if any of the templates could not be deleted

findByContext

public TemplateDetails[] findByContext(TemplateContext templateContext,
                                       boolean includeSubContexts)
                                throws IOException,
                                       TemplateStoreException
Description copied from interface: TemplateStore
Get the list of templates for the given context. The context may specify just the name or may further constrain the returned result by specifying more information.

Specified by:
findByContext in interface TemplateStore
Parameters:
templateContext - the context under which to find templates
includeSubContexts - if true, templates under subcontexts will be returned.
Returns:
an array of TemplateDetails objects or null if no templates are found
Throws:
TemplateStoreException - if a problem occurs specific to the store
IOException - if an error occurs obtaining the template

getOriginalTemplate

public InputStream getOriginalTemplate(TemplateIdentifier templateId)
                                throws IOException,
                                       TemplateNotFoundException
Description copied from interface: TemplateStore
Get the original template provided in storeTemplate().

Specified by:
getOriginalTemplate in interface TemplateStore
Parameters:
templateId - details of the template to retrieve.
Returns:
the original template provided by storeTemplate() or null if there is no template found.
Throws:
IOException - if an IO problem occurs.
TemplateNotFoundException - if the specified template is not found

getTemplate

public Template getTemplate(TemplateIdentifier templateId)
                     throws IOException,
                            TemplateNotFoundException,
                            TemplateStoreException
Description copied from interface: TemplateStore
Get the (working) template identified by the given templateId. This method is intended to be used for obtaining the template for further processing/populating. NOTE: the template should be cleaned up (template.cleanup()) when finished so that InputStreams and other resources may be released.

Specified by:
getTemplate in interface TemplateStore
Parameters:
templateId - the identifier for the template
Returns:
the template.
Throws:
IOException - if an error occurs obtaining the template
TemplateNotFoundException - if the specified template cannot be found
TemplateStoreException

getTemplateAnalysis

public TemplateAnalysis getTemplateAnalysis(TemplateIdentifier templateId)
                                     throws IOException,
                                            TemplateNotFoundException,
                                            TemplateStoreException
Description copied from interface: TemplateStore
Get the template analysis for the template identified by the given template info.

Specified by:
getTemplateAnalysis in interface TemplateStore
Parameters:
templateId -
Returns:
null if the template is not found
Throws:
TemplateStoreException - if an error occurs retrieving the analysis
IOException - if an error occurs obtaining the analysis
TemplateNotFoundException - if the template cannot be located

getTemplateStoredTime

public long getTemplateStoredTime(TemplateIdentifier templateId)
                           throws TemplateStoreException
Description copied from interface: TemplateStore
Return the time that the template was stored in this template store. The time is returned as a long (millis since the epoch) as standard.

Specified by:
getTemplateStoredTime in interface TemplateStore
Returns:
-1 if the template is not known.
Throws:
TemplateStoreException - if an error occurred while retrieving this information.

storeTemplate

public TemplateDetails storeTemplate(TemplateIdentifier templateId,
                                     InputStream origTemplateSource,
                                     InputStream workingTemplateSource,
                                     TemplateAnalysis analysis,
                                     InputStream thumbnail,
                                     boolean overwrite,
                                     boolean templateErrorsFatal,
                                     String plainTextFieldPrefix,
                                     String plainTextFieldSuffix,
                                     boolean allowPaddedFields)
                              throws IOException,
                                     TemplateAlreadyExistsException,
                                     TemplateStoreException
Description copied from interface: TemplateStore
Store the given InputStream as a template using the given templateId.

Specified by:
storeTemplate in interface TemplateStore
Parameters:
templateId - the unique identification for this template.
origTemplateSource - an InputStream over the "original" template. This is the raw template as provided by whatever source (eg a user).
workingTemplateSource - an InputStream over a working template source. This is expected to be a converted form of the original template that is suitable for populating by a TemplatePopulator. Specify null if the origTemplateSource should be used as the working template. The working template is returned by getTemplate().
analysis - the analysis for the template. This may be null and is expected to be constructed dynamically by some TemplateStore implementations, so most implementations should simply store what is given.
thumbnail - an image thumbnail for the template. This may be null and is expected to be constructed dynamically by some TemplateStore implementations, so most implementations of this interface should simply store what is given.
overwrite - if true, any existing template will be overwritten.
templateErrorsFatal - if true, errors detected in the template will result in a TemplateStoreException. If false, errors will be highlighted in the template (where possible) and thus be visible when the document is rendered. Most implementations of this interface can ignore this parameter because it is used by the TemplateStore implementation that will provide the TemplateAnalysis.
plainTextFieldPrefix - if not null, specifies a prefix to use when analysing templates to identify Docmosis fields in plain text. Most implementations of this interface can ignore this parameter because it is used by the TemplateStore implementation that will provide the TemplateAnalysis.
plainTextFieldSuffix - this is the partner to plainTextFieldPrefix and identifies the end of the field. Most implementations of this interface can ignore this parameter because it is used by the TemplateStore implementation that will provide the TemplateAnalysis.
allowPaddedFields - when processing the template allow fields padded with spaces to be included as fields. Most implementations of this interface can ignore this parameter because it is used by the TemplateStore implementation that will provide the TemplateAnalysis.
Returns:
a new TemplateDetails object with information about the template
Throws:
TemplateAlreadyExistsException - if the template is already present and overwrite is not true
TemplateStoreException - if any other unexpected error occurs.
IOException - if an error occurs storing the template

Docmosis API 4.5.0

Copyright © 2014 Docmosis Pty Ltd. All Rights Reserved.