org.encog.app.generate.generators
Class AbstractTemplateGenerator

java.lang.Object
  extended by org.encog.app.generate.generators.AbstractTemplateGenerator
All Implemented Interfaces:
LanguageSpecificGenerator, TemplateGenerator
Direct Known Subclasses:
GenerateMQL4, GenerateNinjaScript

public abstract class AbstractTemplateGenerator
extends Object
implements TemplateGenerator

Provides a basic implementation of a template generator.


Constructor Summary
AbstractTemplateGenerator()
           
 
Method Summary
 void addLine(String line)
          Add a line, with proper indention.
 void addNameValue(String name, double[] data)
          Add a name value definition, as a double array.
 void addNameValue(String name, int value)
          Add a name-value as an int.
 void addNameValue(String name, int[] data)
          Add a name-value array where the value is an int array.
 void addNameValue(String name, 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.
 void generate(EncogAnalyst theAnalyst)
          Generate based on the provided Encog Analyst.
 EncogAnalyst getAnalyst()
           
 String getContents()
           
 int getIndentLevel()
           
abstract  String getNullArray()
           
abstract  String getTemplatePath()
           
 void indentIn()
          Indent to the right one.
 void indentOut()
          Indent to the left one.
abstract  void processToken(String command)
          Process the specified token.
 void setIndentLevel(int indentLevel)
           
 void toBrokenList(StringBuilder result, double[] data)
          Create an array list broken into 10 columns.
 void toBrokenList(StringBuilder result, int[] data)
          Create an array list broken into 10 columns.
 void writeContents(File targetFile)
          Write the generated code to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTemplateGenerator

public AbstractTemplateGenerator()
Method Detail

addLine

public void addLine(String line)
Add a line, with proper indention.

Parameters:
line - The line to add.

addNameValue

public void addNameValue(String name,
                         double[] data)
Add a name value definition, as a double array.

Parameters:
name - The name.
data - THe data.

addNameValue

public void addNameValue(String name,
                         int value)
Add a name-value as an int.

Parameters:
name - The name.
value - THe value.

addNameValue

public void addNameValue(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(String name,
                         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:
generate in interface TemplateGenerator
Parameters:
theAnalyst - The Encog analyst to base this on.

getAnalyst

public EncogAnalyst getAnalyst()
Returns:
The Encog analyst that we are using.

getContents

public String getContents()
Specified by:
getContents in interface LanguageSpecificGenerator
Returns:
The generated contents.

getIndentLevel

public int getIndentLevel()
Returns:
The current indent level.

getNullArray

public abstract String getNullArray()
Returns:
A platform specific array set to null.

getTemplatePath

public abstract 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(String command)
Process the specified token.

Parameters:
command - The token to process.

setIndentLevel

public void setIndentLevel(int indentLevel)

toBrokenList

public void toBrokenList(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(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(File targetFile)
Write the generated code to a file.

Specified by:
writeContents in interface LanguageSpecificGenerator


Copyright © 2014. All Rights Reserved.