@OpenApiAll public class FileTool extends ConcurrentTool
ConcurrentTool.ConsumeObject
ITool.HTMLString, ITool.RetainedString, ITool.Void
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONTEXT_NAME
Contains a context name.
|
context, properties
Constructor and Description |
---|
FileTool(ITemplateEngine engine)
Create a file tool with default global engine.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
computeName(java.lang.String directory,
java.lang.String name)
Create pathname string from given directory, name.
|
java.lang.String |
computeName(java.lang.String directory,
java.lang.String name,
java.lang.String fileType)
Create pathname string from given directory, name, and file type.
|
void |
consume(ConcurrentTool.ConsumeObject consumeObject)
Consumes this object so that it will be processed in the default manner.
|
java.lang.String |
copy(java.io.File inputFile)
Copy an input file to output file with the same name in binary format.
|
protected java.lang.String |
copy(java.io.File inputFile,
java.io.File outputFile)
Copy an input file to output file in binary format.
|
java.lang.String |
copy(java.io.File inputFile,
java.lang.String outputFileName)
Copy an input file to output file in binary format.
|
java.lang.String |
copy(java.lang.String inputFileName)
Copy an input file to output file with the same name in binary format.
|
java.lang.String |
copy(java.lang.String inputFileName,
java.lang.String outputFileName)
Copy an input file to output file in binary format.
|
java.lang.String |
create(java.io.File templateFile)
A shortcut to create file which output filename is same as a name of template file and no import context object.
|
protected java.lang.String |
create(java.io.File templateFile,
java.io.File outputFile,
java.lang.Object importedObject)
Generate the report output by using the template file.
|
java.lang.String |
create(java.io.File templateFile,
java.lang.Object importObject)
A shortcut to create file which output filename is same as a name of template file.
|
java.lang.String |
create(java.io.File templateFile,
java.lang.String outputFileName,
java.lang.Object importObject)
Generate the report output from given template file.
|
protected java.lang.String |
create(java.io.File templateFile,
java.lang.String outputDir,
java.lang.String outputFileName,
java.lang.Object importedObject)
Generate the report output by using the template file.
|
java.lang.String |
create(java.lang.String template)
A shortcut to create file which output filename is template name and no import context object.
|
java.lang.String |
create(java.lang.String template,
java.lang.Object importObject)
A shortcut to create file which output filename is template name.
|
java.lang.String |
create(java.lang.String templateFileName,
java.lang.String outputFileName,
java.lang.Object importObject)
Generate the report output from given template name.
|
java.lang.String |
create(java.lang.String templateType,
java.lang.String template,
java.lang.String outputname,
java.lang.Object importObject)
Deprecated.
|
protected java.lang.String |
create(java.lang.String templateDir,
java.lang.String templateFileName,
java.lang.String outputDir,
java.lang.String outputFileName,
java.lang.Object importedObject)
Generate the report output by using the template file.
|
java.lang.String |
createAndWait(java.io.File templateFile)
Invoke a new template engine to generate a report and return the path to output file.
|
protected java.lang.String |
createAndWait(java.io.File templateFile,
java.io.File outputFile,
java.util.Map<java.lang.String,java.lang.Object> context)
Invoke a new template engine to generate a report and return the path to output file.
|
java.lang.String |
createAndWait(java.io.File templateFile,
java.util.Map<java.lang.String,java.lang.Object> context)
Invoke a new template engine to generate a report and return the path to output file.
|
java.lang.String |
createAndWait(java.io.File templateFile,
java.lang.Object contextValue)
Invoke a new template engine to generate a report and return the path to output file.
|
java.lang.String |
createAndWait(java.io.File templateFile,
java.lang.String outputFileName,
java.util.Map<java.lang.String,java.lang.Object> context)
Invoke a new template engine to generate a report and return the path to output file.
|
java.lang.String |
createAndWait(java.io.File templateFile,
java.lang.String outputFileName,
java.lang.Object contextValue)
Invoke a new template engine to generate a report and return the path to output file.
|
java.lang.String |
createAndWait(java.io.File templateFile,
java.lang.String outputFileName,
java.lang.String contextName,
java.lang.Object contextValue)
Invoke a new template engine to generate a report and return the path to output file.
|
java.lang.String |
createAndWait(java.lang.String templateFileName)
Invoke a new template engine to generate a report and return the path to output file.
|
java.lang.String |
createAndWait(java.lang.String templateFileName,
java.util.Map<java.lang.String,java.lang.Object> context)
Invoke a new template engine to generate a report and return the path to output file.
|
java.lang.String |
createAndWait(java.lang.String templateFileName,
java.lang.Object contextValue)
Invoke a new template engine to generate a report and return the path to output file.
|
java.lang.String |
createAndWait(java.lang.String templateFileName,
java.lang.String outputFileName,
java.util.Map<java.lang.String,java.lang.Object> context)
Invoke a new template engine to generate a report and return the path to output file.
|
java.lang.String |
createAndWait(java.lang.String templateFileName,
java.lang.String outputFileName,
java.lang.Object contextValue)
Invoke a new template engine to generate a report and return the path to output file.
|
java.lang.String |
createAndWait(java.lang.String templateFileName,
java.lang.String outputFileName,
java.lang.String contextName,
java.lang.Object contextValue)
Invoke a new template engine to generate a report and return the path to output file.
|
protected void |
createDir(java.io.File outputDirectory)
Create directory
|
boolean |
exists(java.lang.String pathname)
Tests whether the file denoted by
pathname exists. |
protected java.lang.String |
getResultPath(java.lang.String resultFromProcess,
java.lang.String originalPath)
Get result path.
|
protected boolean |
isEmpty(java.lang.Object obj)
Check null object or empty string.
|
protected java.lang.String |
resolveOutputFileName(java.lang.String templateFileName,
java.lang.String outputFileName,
java.io.File templateFile)
Sometime the name of real template file is not match to original template file name.
In case user does not specify output file name, we cannot assign the templateFileName to be outputFileName without checking. e.g., templateFileName = "mdp://attachedFile#_1234" templateFile = C://tmp//test.docx So, outputFileName should be 'test.docx' not 'mdp://attachedFile#_1234' |
ITool.Void |
silentCreate(java.io.File templateFile)
A shortcut to create file which output filename is same as a name of input template file and no import context object.
|
ITool.Void |
silentCreate(java.io.File templateFile,
java.lang.Object importObject)
A shortcut to create file which output filename is same as a name of input template file.
|
ITool.Void |
silentCreate(java.io.File templateFile,
java.lang.String outputFileName,
java.lang.Object importObject)
Generate the report output from given template file.
|
ITool.Void |
silentCreate(java.lang.String template)
A shortcut to create file which output filename is template name and no import context object.
|
ITool.Void |
silentCreate(java.lang.String template,
java.lang.Object importObject)
A shortcut to create file which output filename is template name.
|
ITool.Void |
silentCreate(java.lang.String template,
java.lang.String outputFileName,
java.lang.Object importObject)
Generate the report output from given template name.
|
ITool.Void |
silentCreate(java.lang.String templateType,
java.lang.String template,
java.lang.String outputname,
java.lang.Object importObject)
Deprecated.
|
destroy, isNoSpaceException, isRunning, offer
clone, getContext, getProperties, getProperty, getProperty, notifyObservers, setContext, setProperties
public static final java.lang.String CONTEXT_NAME
public FileTool(ITemplateEngine engine)
engine
- default global enginepublic ITool.Void silentCreate(java.lang.String template) throws ParseErrorException
For example:
$file.silentCreate('overview.html')
template
- the input template nameParseErrorException
- when template has a syntax or other error which prevents it from being parsed.public ITool.Void silentCreate(java.io.File templateFile) throws ParseErrorException
$file.silentCreate($iFile)
templateFile
- the input template fileParseErrorException
- when template has a syntax or other error which prevents it from being parsed.public ITool.Void silentCreate(java.lang.String template, java.lang.Object importObject) throws ParseErrorException
$file.silentCreate('overview.html','')
importObject
is an instance of java.util.Map
, key-value of Map will be used as
name-value of context.template
- the input template nameimportObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.public ITool.Void silentCreate(java.io.File templateFile, java.lang.Object importObject) throws ParseErrorException
$file.silentCreate($iFile,'')
importObject
is an instance of java.util.Map
, key-value of Map will be used as
name-value of context.templateFile
- the input template fileimportObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.public ITool.Void silentCreate(java.lang.String template, java.lang.String outputFileName, java.lang.Object importObject) throws ParseErrorException
$file.silentCreate('overview.html','overview.html','')
importObject
is an instance of java.util.Map
, key-value of Map will be used as
name-value of context.template
- the input template nameoutputFileName
- the output file nameimportObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.public ITool.Void silentCreate(java.io.File templateFile, java.lang.String outputFileName, java.lang.Object importObject) throws ParseErrorException
$file.silentCreate($iFile,'overview.html','')
importObject
is an instance of java.util.Map
, key-value of Map will be used as
name-value of context.templateFile
- the input template fileoutputFileName
- the output file nameimportObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.@Deprecated public ITool.Void silentCreate(java.lang.String templateType, java.lang.String template, java.lang.String outputname, java.lang.Object importObject) throws ParseErrorException
silentCreate(String, String, Object)
$file.silentCreate('html','overview','overview','')
importObject
is an instance of java.util.Map
, key-value of Map will be used as
name-value of context.template
- the input pathname string without extensionoutputname
- the output file name, not include any extension.templateType
- the template type such rtf, html, htm.importObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.public java.lang.String create(java.lang.String template) throws ParseErrorException
<a href="$file.create('overview.html')">overview.html</a>
template
- the input template nameParseErrorException
- when template has a syntax or other error which prevents it from being parsed.public java.lang.String create(java.io.File templateFile) throws ParseErrorException
<a href="$file.create($aFile)">overview.html</a>
templateFile
- the input template fileParseErrorException
- when template has a syntax or other error which prevents it from being parsed.public java.lang.String create(java.lang.String template, java.lang.Object importObject) throws ParseErrorException
<a href="$file.create('overview.html','')">overview.html</a>
importObject
is an instance of java.util.Map
, key-value of Map will be used as
name-value of context.template
- the input template nameimportObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.public java.lang.String create(java.io.File templateFile, java.lang.Object importObject) throws ParseErrorException
<a href="$file.create($iFile,'')">overview.html</a>
importObject
is an instance of java.util.Map
, key-value of Map will be used as
name-value of context.templateFile
- the input template fileimportObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.public java.lang.String create(java.lang.String templateFileName, java.lang.String outputFileName, java.lang.Object importObject) throws ParseErrorException
<a href="$file.create('overview.html','overview.html','')">overview.html</a>
importObject
is an instance of java.util.Map
, key-value of Map will be used as
name-value of context.templateFileName
- the input template file nameoutputFileName
- the output file nameimportObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.public java.lang.String create(java.io.File templateFile, java.lang.String outputFileName, java.lang.Object importObject) throws ParseErrorException
<a href="$file.create($iFile,'overview.html','')">overview.html</a>
importObject
is an instance of java.util.Map
, key-value of Map will be used as
name-value of context.templateFile
- the input template fileoutputFileName
- the output file nameimportObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.@Deprecated public java.lang.String create(java.lang.String templateType, java.lang.String template, java.lang.String outputname, java.lang.Object importObject) throws ParseErrorException
create(String, String, Object)
<a href="$file.create('html','overview','overview','')">overview.html</a>
template
- the input pathname string without extensionoutputname
- the output file name, not include any extension.templateType
- the template type such rtf, html, htm.importObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.protected java.lang.String create(java.lang.String templateDir, java.lang.String templateFileName, java.lang.String outputDir, java.lang.String outputFileName, java.lang.Object importedObject) throws ParseErrorException
templateDir
- the directory of the template.templateFileName
- the template file name.outputDir
- the directory of the output report.outputFileName
- the output file name, not include any extension.importedObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.protected java.lang.String create(java.io.File templateFile, java.lang.String outputDir, java.lang.String outputFileName, java.lang.Object importedObject) throws ParseErrorException
templateFile
- the template file.outputDir
- the directory of the output report.outputFileName
- the output file name, not include any extension.importedObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.protected java.lang.String create(java.io.File templateFile, java.io.File outputFile, java.lang.Object importedObject) throws ParseErrorException
templateFile
- the template file.outputFile
- the output file.importedObject
- the object reference, which will be DefaultElement in the template file. You can use
DefaultElement variable in the template file for getting the data.ParseErrorException
- when template has a syntax or other error which prevents it from being parsed.public void consume(ConcurrentTool.ConsumeObject consumeObject)
consume
in class ConcurrentTool
consumeObject
- consume objectConcurrentTool.consume(com.nomagic.magicreport.engine.ConcurrentTool.ConsumeObject)
public java.lang.String copy(java.lang.String inputFileName)
<img src="$file.copy('icon.gif')">
inputFileName
- the input filenamepublic java.lang.String copy(java.io.File inputFile)
<img src="$file.copy($iFile)">
inputFile
- the input filepublic java.lang.String copy(java.lang.String inputFileName, java.lang.String outputFileName)
<img src="$file.copy('icon.gif','icon.gif')">
inputFileName
- the input filenameoutputFileName
- the output filenamepublic java.lang.String copy(java.io.File inputFile, java.lang.String outputFileName)
<img src="$file.copy($iconFile,'icon.gif')">
inputFile
- the input fileoutputFileName
- the output filenameprotected java.lang.String copy(java.io.File inputFile, java.io.File outputFile)
<img src="$file.copy($iIcon, $oIcon)">
inputFile
- the input fileoutputFile
- the output filepublic boolean exists(java.lang.String pathname)
pathname
exists. By default, current directory will be
referred to template location.
$file.exists("$template.resourcesLocation/myimage.png")
$file.exists("C:/myfolder/myimage.png")
$file.exists("mytemplate.txt")
pathname
- A pathname stringtrue
if and only if the file or directory denoted by this name exists;
false
otherwisepublic java.lang.String computeName(java.lang.String directory, java.lang.String name)
directory
- a parent directory of filename
- a name of file (exclude extension)public java.lang.String computeName(java.lang.String directory, java.lang.String name, java.lang.String fileType)
directory
- a parent directory of filename
- a name of file (exclude extension)fileType
- type of file. e.g. rtf, txt, htmlpublic java.lang.String createAndWait(java.lang.String templateFileName)
templateFileName
- an input template file name.public java.lang.String createAndWait(java.io.File templateFile)
templateFile
- an input template file.public java.lang.String createAndWait(java.lang.String templateFileName, java.lang.Object contextValue)
templateFileName
- an input template file name.contextValue
- additional object adding to new template context with default $importer name.public java.lang.String createAndWait(java.io.File templateFile, java.lang.Object contextValue)
templateFile
- an input template file name.contextValue
- additional object adding to new template context with default $importer name.public java.lang.String createAndWait(java.lang.String templateFileName, java.lang.String outputFileName, java.lang.Object contextValue)
"importer" will be used as a name of context value.
templateFileName
- an input template file name.outputFileName
- an output report file name.contextValue
- additional object adding to new template context with default $importer name.public java.lang.String createAndWait(java.io.File templateFile, java.lang.String outputFileName, java.lang.Object contextValue)
"importer" will be used as a name of context value.
templateFile
- an input template file.outputFileName
- an output report file name.contextValue
- additional object adding to new template context with default $importer name.public java.lang.String createAndWait(java.lang.String templateFileName, java.lang.String outputFileName, java.lang.String contextName, java.lang.Object contextValue)
templateFileName
- an input template file name.outputFileName
- an output report file name.contextName
- adding object context's name.contextValue
- additional object adding to new template context.public java.lang.String createAndWait(java.io.File templateFile, java.lang.String outputFileName, java.lang.String contextName, java.lang.Object contextValue)
templateFile
- an input template file.outputFileName
- an output report file name.contextName
- adding object context's name.contextValue
- additional object adding to new template context.public java.lang.String createAndWait(java.lang.String templateFileName, java.util.Map<java.lang.String,java.lang.Object> context)
templateFileName
- an input template file name.context
- additional context adding to new template.public java.lang.String createAndWait(java.io.File templateFile, java.util.Map<java.lang.String,java.lang.Object> context)
templateFile
- an input template file.context
- additional context adding to new template.public java.lang.String createAndWait(java.lang.String templateFileName, java.lang.String outputFileName, java.util.Map<java.lang.String,java.lang.Object> context)
templateFileName
- an input template file name.outputFileName
- an output report file name.context
- additional context adding to new template.public java.lang.String createAndWait(java.io.File templateFile, java.lang.String outputFileName, java.util.Map<java.lang.String,java.lang.Object> context)
templateFile
- an input template file.outputFileName
- an output report file name.context
- additional context adding to new template.protected java.lang.String createAndWait(java.io.File templateFile, java.io.File outputFile, java.util.Map<java.lang.String,java.lang.Object> context)
templateFile
- an input template file.outputFile
- an output report file.context
- additional context adding to new template.protected boolean isEmpty(java.lang.Object obj)
obj
- object to checkprotected java.lang.String getResultPath(java.lang.String resultFromProcess, java.lang.String originalPath)
resultFromProcess
- path from processoriginalPath
- specific output file nameprotected void createDir(java.io.File outputDirectory)
outputDirectory
- directory pathprotected java.lang.String resolveOutputFileName(java.lang.String templateFileName, java.lang.String outputFileName, java.io.File templateFile)
templateFileName
- original template file nameoutputFileName
- original output file nametemplateFile
- real template fileCopyright © 2010 - No Magic Asia