org.globus.rsl
Class RslAttributes

java.lang.Object
  extended by org.globus.rsl.RslAttributes
Direct Known Subclasses:
GramAttributes

public class RslAttributes
extends java.lang.Object

This class provides convieniene methods for accessing and manipulatig simple rsl expressions. The class provides methods for retreiving and setting values of specified attributes.


Field Summary
protected  RslNode rslTree
           
 
Constructor Summary
RslAttributes()
          Creates an empty RslAttributes object.
RslAttributes(RslNode rslTree)
          Creates a new RslAttributes object with specified rsl parse tree.
RslAttributes(java.lang.String rsl)
          Creates a new RslAttributes object from specified RSL string.
 
Method Summary
 void add(java.lang.String attribute, java.lang.String value)
          Adds a simple value to the list of values of a given attribute.
 void addMulti(java.lang.String attribute, java.lang.String[] values)
          Adds a list of values as a single value to the specified attribute.
 void addVariable(java.lang.String attribute, java.lang.String varName, java.lang.String value)
          Adds a new variable definition to the specified variable definitions attribute.
 java.util.List get(java.lang.String attribute)
          Deprecated. use getMulti() instead.
 java.lang.String getFirstValue(java.lang.String attribute)
          Deprecated. use getSingle() instead.
 java.util.Map getMap(java.lang.String attribute)
          Returns a key/value pair map for a specified attribute.
 java.util.List getMulti(java.lang.String attribute)
          Returns a list of strings for a specified attribute.
protected  NameOpValue getRelation(java.lang.String attribute)
           
 RslNode getRslNode()
          Returns the rsl parse tree.
 java.lang.String getSingle(java.lang.String attribute)
          Returns a string value of the specified attribute.
 java.util.Map getVariables(java.lang.String attribute)
          Returns a variable name/value pair map of variable definitions.
 void remove(java.lang.String attribute)
          Removes a specific attribute from attribute/value relations.
 boolean remove(java.lang.String attribute, java.lang.String value)
          Removes a specific value from a list of values of the specified attribute.
 boolean removeMap(java.lang.String attribute, java.lang.String key)
          Removes a specific key from a list of values of the specified attribute.
 boolean removeVariable(java.lang.String attribute, java.lang.String varName)
          Removes a specific variable definition given a variable name.
 void set(java.lang.String attribute, java.lang.String value)
          Sets the attribute value to the given value.
 void setMulti(java.lang.String attribute, java.lang.String[] values)
          Sets the attribute value to the given list of values.
 java.lang.String toRSL()
          Returns the rsl.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rslTree

protected RslNode rslTree
Constructor Detail

RslAttributes

public RslAttributes()
Creates an empty RslAttributes object.


RslAttributes

public RslAttributes(RslNode rslTree)
Creates a new RslAttributes object with specified rsl parse tree.

Parameters:
rslTree - the rsl parse tree.

RslAttributes

public RslAttributes(java.lang.String rsl)
              throws ParseException
Creates a new RslAttributes object from specified RSL string.

Parameters:
rsl - the rsl string.
Throws:
ParseException - if the rsl cannot be parsed.
Method Detail

getRslNode

public RslNode getRslNode()
Returns the rsl parse tree.

Returns:
the rsl parse tree.

getSingle

public java.lang.String getSingle(java.lang.String attribute)
Returns a string value of the specified attribute. If the attribute contains multiple values the first one is returned.

Parameters:
attribute - the rsl attribute to return the value of.
Returns:
value of the relation. Null is returned if there is no such attribute of the attribute/value relation is not an equality relation.

getMulti

public java.util.List getMulti(java.lang.String attribute)
Returns a list of strings for a specified attribute. For example for 'arguments' attribute.

Parameters:
attribute - the rsl attribute to return the values of.
Returns:
the list of values of the relation. Each value is a string. Null is returned if there is no such attribute or the attribute/values relation is not an equality relation.

getMap

public java.util.Map getMap(java.lang.String attribute)
Returns a key/value pair map for a specified attribute. For example for 'environment' attribute. Note: Use getVariables() for rsl_substitution attribute.

Parameters:
attribute - the rsl attribute to return the key/value pair map of.
Returns:
a key/value pair map. Null is returned if there is no such attribute defined or if the attribute/value relation is not an equality relation.

getVariables

public java.util.Map getVariables(java.lang.String attribute)
Returns a variable name/value pair map of variable definitions. Currently specified by the 'rsl_substitution' attribute.

Parameters:
attribute - the attribute that defines variables. Currently, only 'rsl_substitution' is supported.
Returns:
a variable name/value pair map. Null, if there is no definitions for a specified attribute.

addVariable

public void addVariable(java.lang.String attribute,
                        java.lang.String varName,
                        java.lang.String value)
Adds a new variable definition to the specified variable definitions attribute.

Parameters:
attribute - the variable definitions attribute - rsl_subsititution.
varName - the variable name to add.
value - the value of the variable to add.

removeVariable

public boolean removeVariable(java.lang.String attribute,
                              java.lang.String varName)
Removes a specific variable definition given a variable name.

Parameters:
attribute - the attribute that defines variable definitions.
varName - the name of the variable to remove.
Returns:
true if the variable was successfully removed. Otherwise, returns false,

remove

public void remove(java.lang.String attribute)
Removes a specific attribute from attribute/value relations.

Parameters:
attribute - the attribute name to remove.

remove

public boolean remove(java.lang.String attribute,
                      java.lang.String value)
Removes a specific value from a list of values of the specified attribute.

Parameters:
attribute - the attribute from which to remote the value from.
value - the specific value to remove.
Returns:
true if the value was successfully removed. Otherwise, returns false,

removeMap

public boolean removeMap(java.lang.String attribute,
                         java.lang.String key)
Removes a specific key from a list of values of the specified attribute. The attribute values must be in the right form. See the 'environment' rsl attribute.

Parameters:
attribute - the attribute to remove the key from.
key - the key to remove.
Returns:
true if the key was successfully removed. Otherwise, returns false.

getRelation

protected NameOpValue getRelation(java.lang.String attribute)

set

public void set(java.lang.String attribute,
                java.lang.String value)
Sets the attribute value to the given value. All previous values are removed first.

Parameters:
attribute - the attribute to set the value of.
value - the value to add.

add

public void add(java.lang.String attribute,
                java.lang.String value)
Adds a simple value to the list of values of a given attribute.

Parameters:
attribute - the attribute to add the value to.
value - the value to add.

setMulti

public void setMulti(java.lang.String attribute,
                     java.lang.String[] values)
Sets the attribute value to the given list of values. The list of values is added as a single value.

Parameters:
attribute - the attribute to set the value of.
values - the list of values to add.

addMulti

public void addMulti(java.lang.String attribute,
                     java.lang.String[] values)
Adds a list of values as a single value to the specified attribute.

Parameters:
attribute - the attribute to add the list of values to.
values - the values to add.

getFirstValue

public java.lang.String getFirstValue(java.lang.String attribute)
Deprecated. use getSingle() instead.

Returns the first value of a specified attribute.

Returns:
the first value of the attribute.

get

public java.util.List get(java.lang.String attribute)
Deprecated. use getMulti() instead.

Returns the values for a specified attribute.

Returns:
the list of values.

toRSL

public java.lang.String toRSL()
Returns the rsl.

Returns:
the rsl.