com.waveset.util
Class VariableExpander

java.lang.Object
  extended bycom.waveset.util.VariableExpander

public class VariableExpander
extends java.lang.Object

Utilities for parsing a string containing variable references of the form "$(name)" and building a string containing the expanded values of those variables.


Nested Class Summary
static class VariableExpander.MapResolver
          A class that implements the VariableResolver interface, and looks up variables in a Map.
 
Field Summary
static java.lang.String code_id
           
 
Constructor Summary
VariableExpander()
           
 
Method Summary
static java.lang.String expand(java.lang.String src, java.util.Map variables)
          Process a string which may contain references to variables and substitute the values of those variables.
static java.lang.String expand(java.lang.String src, VariableResolver resolver)
           
static java.lang.String getVariableAt(java.lang.String src, int startPoint, int endPoint)
           
static java.lang.String getVariableName(java.lang.String ref)
          Given a string containing a variable reference, return the name of the variable (or null if there is no reference).
static java.lang.String replaceString(java.lang.String src, int startPoint, int endPoint, java.lang.String replaceString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

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

VariableExpander

public VariableExpander()
Method Detail

getVariableAt

public static java.lang.String getVariableAt(java.lang.String src,
                                             int startPoint,
                                             int endPoint)

replaceString

public static java.lang.String replaceString(java.lang.String src,
                                             int startPoint,
                                             int endPoint,
                                             java.lang.String replaceString)

expand

public static java.lang.String expand(java.lang.String src,
                                      VariableResolver resolver)
                               throws WavesetException
Throws:
WavesetException

expand

public static java.lang.String expand(java.lang.String src,
                                      java.util.Map variables)
Process a string which may contain references to variables and substitute the values of those variables. Variable values are supplied in a Map.


getVariableName

public static java.lang.String getVariableName(java.lang.String ref)
Given a string containing a variable reference, return the name of the variable (or null if there is no reference).

This isn't very complicated but I wanted to keep here next to expand() so we can keep them in sync if we ever change variable referencing conventions.