terp - the ANT Tasks
v1.3.304

com.codemesh.terp.ant
Class FileToBytes

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.apache.tools.ant.taskdefs.MatchingTask
              extended by com.codemesh.terp.ant.FileToBytes
All Implemented Interfaces:
java.lang.Cloneable, org.apache.tools.ant.types.selectors.SelectorContainer

public class FileToBytes
extends org.apache.tools.ant.taskdefs.MatchingTask

An ANT task that takes an arbitrary file(set) as input and converts it to a byte array in one of several supported languages. This task usually expects to receive a .class or .jar file as input, but it could be used for a set of files or for totally different file types as well. The generated byte array will be in a form that is compilable in the target language and can thereby be embedded in an application.


Field Summary
static java.lang.String LANG_CPP
           
static java.lang.String LANG_CS
           
static java.lang.String LANG_JAVA
           
 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
FileToBytes()
           
 
Method Summary
 void addFileset(org.apache.tools.ant.types.FileSet set)
          Adds a fileset to the maintained vector of filesets.
 void execute()
           
 java.lang.String getEncoding()
          Returns the encoding that is to be used for the generated file.
 java.lang.String getLanguage()
          Returns the language for which the files are generated.
 java.lang.String getNamespace()
          Returns the namespace that is used for .NET files.
 java.lang.String getPackage()
          Returns the package name that is used for the bytes-holding type if the target language is "java".
 java.lang.String getPrefix()
          Returns the filename prefix.
 void setDestDir(java.io.File destDir)
          Sets the target directory into which the generated files are written.
 void setEncoding(java.lang.String encoding)
          Sets the encoding for the generated file.
 void setLanguage(java.lang.String language)
          Sets the language in which the generated files are to be compilable.
 void setNamespace(java.lang.String namespace)
          Sets the namespace that is used for .NET files.
 void setPackage(java.lang.String pack)
          Sets the package name that is used for Java files.
 void setPrefix(java.lang.String prefix)
          Sets an optional filename prefix for the generated file.
 void setTargetDir(java.io.File targetDir)
          Sets the target directory into which the generated files are written.
 void toCpp(java.io.File baseDir, java.lang.String file)
           
 void toCs(java.io.File baseDir, java.lang.String file)
           
 void toJava(java.io.File baseDir, java.lang.String file)
           
 
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LANG_CPP

public static final java.lang.String LANG_CPP
See Also:
Constant Field Values

LANG_CS

public static final java.lang.String LANG_CS
See Also:
Constant Field Values

LANG_JAVA

public static final java.lang.String LANG_JAVA
See Also:
Constant Field Values
Constructor Detail

FileToBytes

public FileToBytes()
Method Detail

addFileset

public void addFileset(org.apache.tools.ant.types.FileSet set)
Adds a fileset to the maintained vector of filesets.


setEncoding

public void setEncoding(java.lang.String encoding)
Sets the encoding for the generated file. When no encoding is specified, the JRE's default encoding is used.

Parameters:
encoding - the encoding to use.

getEncoding

public java.lang.String getEncoding()
Returns the encoding that is to be used for the generated file. This method may return null, which represents the JRE's default encoding.


setDestDir

public void setDestDir(java.io.File destDir)
Sets the target directory into which the generated files are written. This is an optional setting. If no target directory is specified, the files are generated into the directory in which the input file resides.

Parameters:
destDir -

setTargetDir

public void setTargetDir(java.io.File targetDir)
Sets the target directory into which the generated files are written. This is an optional setting. If no target directory is specified, the files are generated into the directory in which the input file resides.


setLanguage

public void setLanguage(java.lang.String language)
Sets the language in which the generated files are to be compilable. Currently, this task supports "java", "c++", or "c#". The default value is "c++".


getLanguage

public java.lang.String getLanguage()
Returns the language for which the files are generated.


setPackage

public void setPackage(java.lang.String pack)
Sets the package name that is used for Java files.

Parameters:
pack - the package in which the bytes-holding type is generated.

getPackage

public java.lang.String getPackage()
Returns the package name that is used for the bytes-holding type if the target language is "java".

Returns:

setNamespace

public void setNamespace(java.lang.String namespace)
Sets the namespace that is used for .NET files.

Parameters:
namespace -

getNamespace

public java.lang.String getNamespace()
Returns the namespace that is used for .NET files.

Returns:

setPrefix

public void setPrefix(java.lang.String prefix)
Sets an optional filename prefix for the generated file.


getPrefix

public java.lang.String getPrefix()
Returns the filename prefix.


execute

public void execute()
             throws org.apache.tools.ant.BuildException
Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException

toCpp

public void toCpp(java.io.File baseDir,
                  java.lang.String file)

toCs

public void toCs(java.io.File baseDir,
                 java.lang.String file)

toJava

public void toJava(java.io.File baseDir,
                   java.lang.String file)

terp - the ANT Tasks
v1.3.304

Copyright © 2008-2012 by Codemesh, Inc. All Rights Reserved.