jfun.jaskell.ast
Class InterpolatedString

java.lang.Object
  extended byjfun.jaskell.ast.InterpolatedString
All Implemented Interfaces:
java.io.Serializable

public final class InterpolatedString
extends java.lang.Object
implements java.io.Serializable

Represents a string literal with interpolation.

Zephyr Business Solutions Corp.

Author:
Ben Yu
See Also:
Serialized Form

Constructor Summary
InterpolatedString(int[] indices, int[] lengths, Expr[] exprs, java.lang.String str)
           
 
Method Summary
 Expr getExpr(int i)
          Get the i'th sub-expression.
 Expr[] getExprs()
          Get the sub-expressions.
 int getIndice(int i)
          Get the indice in the raw string for the i'th sub-expression.
 int getInterpolationCount()
          Get the number of sub-expressions to interpolate.
 int getLength(int i)
          Get the length of the i'th sub-expression.
 java.lang.String getRaw()
          Get the raw string that contains all the '$' and '{', '}' characters.
 InterpolatedString setExprs(Expr[] exprs)
          replace the sub-expressions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterpolatedString

public InterpolatedString(int[] indices,
                          int[] lengths,
                          Expr[] exprs,
                          java.lang.String str)
Parameters:
indices -
lengths -
exprs -
str -
Method Detail

setExprs

public final InterpolatedString setExprs(Expr[] exprs)
replace the sub-expressions. This is functional update, the original InterpolatedString object is not changed.

Parameters:
exprs - the new sub-expressions.
Returns:
the new InterpolatedString object.

getExprs

public final Expr[] getExprs()
Get the sub-expressions.


getInterpolationCount

public final int getInterpolationCount()
Get the number of sub-expressions to interpolate.


getIndice

public final int getIndice(int i)
Get the indice in the raw string for the i'th sub-expression. It points to the '$' character.

Parameters:
i - the subscript.
Returns:
the indice.

getLength

public final int getLength(int i)
Get the length of the i'th sub-expression. It includes the '$' character and the '{' and '}' if any.

Parameters:
i - the subscript.
Returns:
the length.

getExpr

public final Expr getExpr(int i)
Get the i'th sub-expression. If the actual sub-expression is $$, it returns an expression for the character '$'

Parameters:
i - the subscript.
Returns:
the expression.

getRaw

public final java.lang.String getRaw()
Get the raw string that contains all the '$' and '{', '}' characters.

Returns:
the raw string.