eu.scape_project.xa.tw.gen
Class Substitutor

java.lang.Object
  extended by eu.scape_project.xa.tw.gen.Substitutor
Direct Known Subclasses:
PropertiesSubstitutor

public abstract class Substitutor
extends Object

GenericSubstitutor

Version:
0.3
Author:
shsdev https://github.com/shsdev

Field Summary
protected  org.apache.velocity.app.VelocityEngine ve
           
 
Constructor Summary
Substitutor()
          Constructor of the generic substitutor which initialises the velocity engine and the context containing the key value pairs.
 
Method Summary
 String applySubstitution(String content)
          Apply substitution
 void applySubstitution(String srcFileAbsPath, String trgtFileAbsPath)
          Apply substitution
 org.apache.velocity.VelocityContext getContext()
           
 void processDirectory(File path)
          Process directory recursively, only if a file is found, the subsitution is applied.
protected abstract  void processFile(File path)
           
 void putKeyValuePair(String key, String val)
          Add a new key-value pair to the velocity context, note that the dot (.) in the variable is replaced by underscore (_) because this character is used for accessing sub-properties in the Velocity VTL.
protected  String replaceVars(String inputText)
          Replace variables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ve

protected org.apache.velocity.app.VelocityEngine ve
Constructor Detail

Substitutor

public Substitutor()
Constructor of the generic substitutor which initialises the velocity engine and the context containing the key value pairs.

Method Detail

putKeyValuePair

public void putKeyValuePair(String key,
                            String val)
Add a new key-value pair to the velocity context, note that the dot (.) in the variable is replaced by underscore (_) because this character is used for accessing sub-properties in the Velocity VTL.

Parameters:
key - Key
val - Value

applySubstitution

public void applySubstitution(String srcFileAbsPath,
                              String trgtFileAbsPath)
                       throws GeneratorException
Apply substitution

Parameters:
srcFileAbsPath - Source file
trgtFileAbsPath - Target file
Throws:
GeneratorException

applySubstitution

public String applySubstitution(String content)
Apply substitution

Parameters:
content - Content string
Returns:
Result

processDirectory

public void processDirectory(File path)
                      throws IOException,
                             GeneratorException
Process directory recursively, only if a file is found, the subsitution is applied.

Parameters:
path - Path to start with
Throws:
IOException
GeneratorException

replaceVars

protected String replaceVars(String inputText)
Replace variables

Parameters:
inputText - Text where substitution will be applied
Returns:
Result text

processFile

protected abstract void processFile(File path)
                             throws GeneratorException
Throws:
GeneratorException

getContext

public org.apache.velocity.VelocityContext getContext()
Returns:
the context


Copyright © 2013. All Rights Reserved.