org.globus.rsl
Class AbstractRslNode

java.lang.Object
  extended by org.globus.rsl.AbstractRslNode
Direct Known Subclasses:
ListRslNode, RslNode

public abstract class AbstractRslNode
extends Object

This class represents an abstract RSL parse tree. It is composed of variable definitions (bindings), relations, and sub-specifications (sub nodes).


Field Summary
protected  int _operator
           
protected  List _specifications
           
static int AND
           
static int MULTI
           
static int OR
           
 
Constructor Summary
AbstractRslNode()
           
AbstractRslNode(int operator)
           
 
Method Summary
 boolean add(AbstractRslNode node)
          Adds a rsl parse tree to this node.
abstract  boolean add(Bindings bindings)
           
abstract  boolean add(NameOpValue relations)
           
static String canonicalize(String str)
          Canonicalizes a string by removing any underscores and moving all characters to lowercase.
 AbstractRslNode evaluate()
          Evalutes the rsl tree.
abstract  AbstractRslNode evaluate(Map symbolTable)
          Evalutes the rsl tree against the specified symbol table.
abstract  Bindings getBindings(String attribute)
          Returns the variable definitions associated wit the given attribute.
 int getOperator()
          Returns the node operator.
 String getOperatorAsString()
          Returns the operator as a string.
static String getOperatorAsString(int op)
          Returns a string represention of a given operator.
abstract  NameOpValue getParam(String attribute)
          Returns the relation associated with the given attribute.
 List getSpecifications()
          Returns the list of sub-specifications.
 void merge(AbstractRslNode inNode)
          Merges the specified node with the current node.
 void mergeTo(AbstractRslNode dstNode)
           
abstract  Bindings removeBindings(String attribute)
          Removes a bindings list for the specified attribute.
abstract  NameOpValue removeParam(String attribute)
          Removes a relation for the specified attribute.
 boolean removeSpecification(AbstractRslNode node)
          Removes a specific sub-specification tree from the sub-specification list.
 void setOperator(int oper)
          Sets the operator.
 String toRSL(boolean explicitConcat)
          Returns a RSL representation of this relation.
abstract  void toRSL(StringBuffer buf, boolean explicitConcat)
          Produces a RSL representation of node.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AND

public static final int AND
See Also:
Constant Field Values

OR

public static final int OR
See Also:
Constant Field Values

MULTI

public static final int MULTI
See Also:
Constant Field Values

_operator

protected int _operator

_specifications

protected List _specifications
Constructor Detail

AbstractRslNode

public AbstractRslNode()

AbstractRslNode

public AbstractRslNode(int operator)
Method Detail

add

public abstract boolean add(Bindings bindings)

add

public abstract boolean add(NameOpValue relations)

add

public boolean add(AbstractRslNode node)
Adds a rsl parse tree to this node.

Parameters:
node - the rsl parse tree to add.

getParam

public abstract NameOpValue getParam(String attribute)
Returns the relation associated with the given attribute.

Parameters:
attribute - the attribute of the relation.
Returns:
the relation for the attribute. Null, if not found.

getBindings

public abstract Bindings getBindings(String attribute)
Returns the variable definitions associated wit the given attribute.

Parameters:
attribute - the attribute of the variable deinitions.
Returns:
the variable deinitions for the attribute. Null, if not found.

removeSpecification

public boolean removeSpecification(AbstractRslNode node)
Removes a specific sub-specification tree from the sub-specification list.

Parameters:
node - node to remove.
Returns:
true if the tree was removed successfuly. False, otherwise.

removeBindings

public abstract Bindings removeBindings(String attribute)
Removes a bindings list for the specified attribute.

Parameters:
attribute - the attribute name for the bindings.
Returns:
the bindings that were removed.

removeParam

public abstract NameOpValue removeParam(String attribute)
Removes a relation for the specified attribute.

Parameters:
attribute - the attribute name for the relation to remove.
Returns:
the relation that was removed.

merge

public void merge(AbstractRslNode inNode)
Merges the specified node with the current node. All sub-specifications from the given node will be copied to the current node. All relations and variable definitions will be added together in the current node.

Parameters:
inNode - the source parse tree.

mergeTo

public void mergeTo(AbstractRslNode dstNode)

getSpecifications

public List getSpecifications()
Returns the list of sub-specifications.

Returns:
the list of other sub-specifications.

getOperator

public int getOperator()
Returns the node operator.

Returns:
the operator.

setOperator

public void setOperator(int oper)
Sets the operator.

Parameters:
oper - the operator.

getOperatorAsString

public String getOperatorAsString()
Returns the operator as a string.

Returns:
operator in a string representation.

getOperatorAsString

public static String getOperatorAsString(int op)
Returns a string represention of a given operator.

Parameters:
op - the operator.
Returns:
the string representation of the operator.

evaluate

public AbstractRslNode evaluate()
                         throws RslEvaluationException
Evalutes the rsl tree. All the variable definitions are first evaluated because they might update the symbol table. Then all the relations followed by the sub-specifications are evaluated.

Returns:
the evaluated rsl tree.
Throws:
RslEvaluationException - If an error occured during rsl evaluation.

evaluate

public abstract AbstractRslNode evaluate(Map symbolTable)
                                  throws RslEvaluationException
Evalutes the rsl tree against the specified symbol table. All the variable definitions are first evaluated because they might update the symbol table. Then all the relations followed by the sub-specifications are evaluated.

Parameters:
symbolTable - the symbol table to evalute variables against.
Returns:
the evaluated rsl tree.
Throws:
RslEvaluationException - If an error occured during rsl evaluation.

toRSL

public String toRSL(boolean explicitConcat)
Returns a RSL representation of this relation.
Note: Enable explicitConcat to generate more 'valid' RSL

Parameters:
explicitConcat - if true explicit concatination will be used in RSL strings.
Returns:
RSL representation of this relation.

toRSL

public abstract void toRSL(StringBuffer buf,
                           boolean explicitConcat)
Produces a RSL representation of node.

Parameters:
buf - buffer to add the RSL representation to.
explicitConcat - if true explicit concatination will be used in RSL strings.

toString

public String toString()
Overrides:
toString in class Object

canonicalize

public static String canonicalize(String str)
Canonicalizes a string by removing any underscores and moving all characters to lowercase.

Parameters:
str - string to canonicalize
Returns:
canonicalized string