|
Docmosis API 4.9.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.docmosis.template.analysis.structure.TemplateStructureExtractor
public class TemplateStructureExtractor
This class provides a simple interpretation of the structure of a template from the
given analysis. This structure can then be used with a TemplateStructureProcessor to
perform different analyses or renderings of the structure.
For example, a basic XML structure can be obtained with the following code which uses
SimpleXMLTemplateStructureProcessor:
final String context = "TemplateStructure";
final String template = "basicTests.doc";
// this code assumes you have a template in the local directory TemplateStructure called basicTests.doc
final String templatePath = context + "/" + template;
TemplateIdentifier tid = new TemplateIdentifier(template, context);
TemplateStore store = TemplateStoreFactory.getStore();
StoreHelper.storeTemplate(tid, new File(templatePath), store);
SimpleXMLTemplateStructureProcessor collector = new SimpleXMLTemplateStructureProcessor();
TemplateStructureExtractor.process(collector, tid);
System.out.println(collector.toString();
You can implement your own version of SimpleXMLTemplateStructureProcessor by implementing
the TemplateStructureProcessor interface and using it in the example code above.
SimpleXMLTemplateStructureProcessor,
TemplateStructureProcessor| Constructor Summary | |
|---|---|
TemplateStructureExtractor(TemplateAnalysis analysis)
|
|
| Method Summary | |
|---|---|
List |
getStructure()
Get the recursive structure which is a List of TemplateStructureElements. |
static List |
getStructureFromDefaultStore(TemplateIdentifier templateId)
This is a convenience method to extract the TemplateStructure for the given template from the default template store. |
void |
process(TemplateStructureProcessor processor)
Process the structure using the given processor. |
static void |
process(TemplateStructureProcessor processor,
TemplateIdentifier templateId)
This convenience method will get the template from the default TemplateStore and extract the structure before passing it to the given processor to process. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TemplateStructureExtractor(TemplateAnalysis analysis)
| Method Detail |
|---|
public static List getStructureFromDefaultStore(TemplateIdentifier templateId)
throws TemplateNotFoundException,
TemplateStoreException
templateId - the identifier for the template
TemplateStructureElement items.
TemplateNotFoundException - if the template could not be found
TemplateStoreException - if there an error from the template storeTemplateStructureElementpublic List getStructure()
public void process(TemplateStructureProcessor processor)
processor - the processor that will be used to process the structure.
public static void process(TemplateStructureProcessor processor,
TemplateIdentifier templateId)
throws TemplateNotFoundException,
TemplateStoreException
processor - the processor to usetemplateId - the template to get
TemplateStoreException - if a problem occurs getting the template from the store
TemplateNotFoundException - if the template does not exist
|
Docmosis API 4.9.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||