Package gov.nasa.pds.imaging.generate
Class Generator
- java.lang.Object
-
- gov.nasa.pds.imaging.generate.Generator
-
public class Generator extends Object
-
-
Constructor Summary
Constructors Constructor Description Generator()Generator(PDSObject pdsObject, File templateFile, File outputFile)Initialize Generator object with a PDSObject.Generator(PDSObject pdsObject, File templateFile, File outputFile, File inputFile)Initialize Generator object with a PDSObject.Generator(PDSObject pdsObject, File templateFile, File outputFile, File inputFile, Boolean isXML)Generator constructor class.Generator(PDSObject pdsObject, File templateFile, File outputFile, Boolean isXML)Initialize Generator object with a PDSObject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPdsObject(PDSObject pdsObject, String contextStr)addPdsObject add an additional PDSObject The contextStr is the variable prefix used in a velocity template * $extra.SOMETHING if contextStr is "extra" The pdsObject.getContext() value should be this same String * it is used by getPdsObjectvoidgenerate(boolean toStdOut)Functionality to generate the PDS4 Label from the Velocity Templatevoidgenerate(OutputStream os)Functionality to generate the PDS4 Label from the Velocity Templatevoidgenerate(ImageOutputStream ios)Functionality to generate the PDS4 Label from the Velocity Templateorg.apache.velocity.VelocityContextgetContext()ContextMappingsgetContextMappings()booleangetIsXML()FilegetOutputFile()PDSObjectgetPdsObject()PDSObjectgetPdsObject(String context_label)getPdsObjectorg.apache.velocity.TemplategetTemplate()FilegetTemplateFile()StringgetTemplatePath()voidinitTemplate()Initializes and reads in the Velocity Template into the Velocity Engine.voidsetContext()Sets the Velocity Template contexts specified by the PDSObject API and ContextMappings object.voidsetContext(org.apache.velocity.VelocityContext context)voidsetContextMappings(ContextMappings ctxMappings)voidsetInputFilePath(String inputFilePath)voidsetIsXML(boolean isXML)voidsetOutputFile(File outputFile)voidsetPDSObject(PDSObject pdsObject)voidsetTemplate(org.apache.velocity.Template template)voidsetTemplateFile(File templateFile)voidsetTemplatePath(String templatePath)
-
-
-
Constructor Detail
-
Generator
public Generator(PDSObject pdsObject, File templateFile, File outputFile) throws Exception
Initialize Generator object with a PDSObject. Defaults as XML output.- Parameters:
pdsObject-templateFile-outputFile-- Throws:
Exception
-
Generator
public Generator(PDSObject pdsObject, File templateFile, File outputFile, File inputFile) throws Exception
Initialize Generator object with a PDSObject. Defaults as XML output.- Parameters:
pdsObject-templateFile-outputFile-inputFile-- Throws:
Exception
-
Generator
public Generator(PDSObject pdsObject, File templateFile, File outputFile, Boolean isXML) throws Exception
Initialize Generator object with a PDSObject. Defaults as XML output.- Parameters:
pdsObject-templateFile-outputFile-isXML- flag to specify whether or not the output is expected to be XML- Throws:
Exception
-
Generator
public Generator(PDSObject pdsObject, File templateFile, File outputFile, File inputFile, Boolean isXML) throws Exception
Generator constructor class.- Parameters:
pdsObject- pds object, i.e. PDS3 labeltemplateFile- velocity template file pathoutputFile- path to output file. can be null in cases where we output to streamsinputFile- path to input file. can be null in cases where we don't careisXML- flag to specify whether or not the output is expected to be XML- Throws:
Exception
-
-
Method Detail
-
generate
public void generate(ImageOutputStream ios) throws Exception
Functionality to generate the PDS4 Label from the Velocity Template- Parameters:
ImageOutputStream- - ImageOutputStream write to ImageOutputStream and OutputStream are NOT related so we must use one or the other no casting allowed- Throws:
Exception- - when output file does not exist, or error close String writerTemplateException- - when output is null - reason needs to be found * may be able to merge the 2 generate()s together since we actually write to a PrintWriter which can wrap a File or OutputStream
-
generate
public void generate(OutputStream os) throws Exception
Functionality to generate the PDS4 Label from the Velocity Template- Parameters:
OutputStream- - OutputStream write to- Throws:
Exception- - when output file does not exist, or error close String writerTemplateException- - when output is null - reason needs to be found * may be able to merge the 2 generate()s together since we actually write to a PrintWriter which can wrap a File or OutputStream
-
generate
public void generate(boolean toStdOut) throws ExceptionFunctionality to generate the PDS4 Label from the Velocity Template- Parameters:
toStdOut- - Determines whether the output should be to a file or System.out- Throws:
Exception- - when output file does not exist, or error close String writerTemplateException- - when output is null - reason needs to be found
-
initTemplate
public void initTemplate() throws TemplateExceptionInitializes and reads in the Velocity Template into the Velocity Engine.- Throws:
TemplateExceptionIOException
-
addPdsObject
public void addPdsObject(PDSObject pdsObject, String contextStr) throws TemplateException, Exception
addPdsObject add an additional PDSObject The contextStr is the variable prefix used in a velocity template * $extra.SOMETHING if contextStr is "extra" The pdsObject.getContext() value should be this same String * it is used by getPdsObject- Parameters:
extraLabel-contextStr-- Throws:
TemplateExceptionException
-
setPDSObject
public void setPDSObject(PDSObject pdsObject)
-
getPdsObject
public PDSObject getPdsObject()
-
setContext
public void setContext() throws TemplateException, ExceptionSets the Velocity Template contexts specified by the PDSObject API and ContextMappings object.- Throws:
TemplateExceptionException
-
getContext
public org.apache.velocity.VelocityContext getContext()
-
getContextMappings
public ContextMappings getContextMappings()
-
getOutputFile
public File getOutputFile()
-
getTemplate
public org.apache.velocity.Template getTemplate()
-
getTemplateFile
public File getTemplateFile()
-
getTemplatePath
public String getTemplatePath()
-
getIsXML
public boolean getIsXML()
-
setContext
public void setContext(org.apache.velocity.VelocityContext context)
-
setContextMappings
public void setContextMappings(ContextMappings ctxMappings)
-
setOutputFile
public void setOutputFile(File outputFile)
-
setTemplate
public void setTemplate(org.apache.velocity.Template template)
-
setTemplateFile
public void setTemplateFile(File templateFile) throws TemplateException
- Throws:
TemplateException
-
setTemplatePath
public void setTemplatePath(String templatePath)
-
setInputFilePath
public void setInputFilePath(String inputFilePath)
-
setIsXML
public void setIsXML(boolean isXML)
-
-