org.encog.app.generate.generators
Class AbstractTemplateGenerator
- java.lang.Object
-
- org.encog.app.generate.generators.AbstractTemplateGenerator
-
- All Implemented Interfaces:
- LanguageSpecificGenerator, TemplateGenerator
- Direct Known Subclasses:
- GenerateMQL4, GenerateNinjaScript
public abstract class AbstractTemplateGenerator extends java.lang.Object implements TemplateGenerator
Provides a basic implementation of a template generator.
-
-
Constructor Summary
Constructors Constructor and Description AbstractTemplateGenerator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description voidaddLine(java.lang.String line)Add a line, with proper indention.voidaddNameValue(java.lang.String name, double[] data)Add a name value definition, as a double array.voidaddNameValue(java.lang.String name, int value)Add a name-value as an int.voidaddNameValue(java.lang.String name, int[] data)Add a name-value array where the value is an int array.voidaddNameValue(java.lang.String name, java.lang.String value)Add a name-value where a string is the value.int[]createActivations(FlatNetwork flat)Create an array of activations based on a flat network.double[]createParams(FlatNetwork flat)Create an array of doubles to hold the specified flat network.voidgenerate(EncogAnalyst theAnalyst)Generate based on the provided Encog Analyst.EncogAnalystgetAnalyst()java.lang.StringgetContents()intgetIndentLevel()abstract java.lang.StringgetNullArray()abstract java.lang.StringgetTemplatePath()voidindentIn()Indent to the right one.voidindentOut()Indent to the left one.abstract voidprocessToken(java.lang.String command)Process the specified token.voidsetIndentLevel(int indentLevel)voidtoBrokenList(java.lang.StringBuilder result, double[] data)Create an array list broken into 10 columns.voidtoBrokenList(java.lang.StringBuilder result, int[] data)Create an array list broken into 10 columns.voidwriteContents(java.io.File targetFile)Write the generated code to a file.
-
-
-
Method Detail
-
addLine
public void addLine(java.lang.String line)
Add a line, with proper indention.- Parameters:
line- The line to add.
-
addNameValue
public void addNameValue(java.lang.String name, double[] data)Add a name value definition, as a double array.- Parameters:
name- The name.data- THe data.
-
addNameValue
public void addNameValue(java.lang.String name, int value)Add a name-value as an int.- Parameters:
name- The name.value- THe value.
-
addNameValue
public void addNameValue(java.lang.String name, int[] data)Add a name-value array where the value is an int array.- Parameters:
name- The name.data- THe value.
-
addNameValue
public void addNameValue(java.lang.String name, java.lang.String value)Add a name-value where a string is the value.- Parameters:
name- The name.value- The value.
-
createActivations
public int[] createActivations(FlatNetwork flat)
Create an array of activations based on a flat network.- Parameters:
flat- The flat network.- Returns:
- The array of flat activations.
-
createParams
public double[] createParams(FlatNetwork flat)
Create an array of doubles to hold the specified flat network.- Parameters:
flat- The flat network to use as a model.- Returns:
- The new array.
-
generate
public void generate(EncogAnalyst theAnalyst)
Generate based on the provided Encog Analyst.- Specified by:
generatein interfaceTemplateGenerator- Parameters:
theAnalyst- The Encog analyst to base this on.
-
getAnalyst
public EncogAnalyst getAnalyst()
- Returns:
- The Encog analyst that we are using.
-
getContents
public java.lang.String getContents()
- Specified by:
getContentsin interfaceLanguageSpecificGenerator- Returns:
- The generated contents.
-
getIndentLevel
public int getIndentLevel()
- Returns:
- The current indent level.
-
getNullArray
public abstract java.lang.String getNullArray()
- Returns:
- A platform specific array set to null.
-
getTemplatePath
public abstract java.lang.String getTemplatePath()
- Returns:
- Get a resource path to the template that we are using.
-
indentIn
public void indentIn()
Indent to the right one.
-
indentOut
public void indentOut()
Indent to the left one.
-
processToken
public abstract void processToken(java.lang.String command)
Process the specified token.- Parameters:
command- The token to process.
-
setIndentLevel
public void setIndentLevel(int indentLevel)
-
toBrokenList
public void toBrokenList(java.lang.StringBuilder result, double[] data)Create an array list broken into 10 columns. This prevents a very large array from creating a very long single line.- Parameters:
result- The string builder to add to.data- The data to convert.
-
toBrokenList
public void toBrokenList(java.lang.StringBuilder result, int[] data)Create an array list broken into 10 columns. This prevents a very large array from creating a very long single line.- Parameters:
result- The string builder to add to.data- The data to convert.
-
writeContents
public void writeContents(java.io.File targetFile)
Write the generated code to a file.- Specified by:
writeContentsin interfaceLanguageSpecificGenerator- Parameters:
targetFile- the output file
-
-
DMelt 3.0 © DataMelt by jWork.ORG