Package org.globus.rsl

# Class RslAttributes

java.lang.Object
org.globus.rsl.RslAttributes

Direct Known Subclasses:
  `GramAttributes`

public class RslAttributes extends 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

Fields
Modifier and Type
Field
Description
`protected RslNode`
`rslTree`

## Constructor Summary

Constructors
Constructor
Description
`RslAttributes()`
Creates an empty RslAttributes object.
`RslAttributes(String rsl)`
Creates a new RslAttributes object from specified RSL string.
`RslAttributes(RslNode rslTree)`
Creates a new RslAttributes object with specified rsl parse tree.

## Method Summary

Modifier and Type
Method
Description
`void`
`add(String attribute, String value)`
Adds a simple value to the list of values of a given attribute.
`void`
`addMulti(String attribute, String[] values)`
Adds a list of values as a single value to the specified attribute.
`void`
`addVariable(String attribute, String varName, String value)`
Adds a new variable definition to the specified variable definitions attribute.
`List`
`get(String attribute)`
Deprecated.
use getMulti() instead.
`String`
`getFirstValue(String attribute)`
Deprecated.
use getSingle() instead.
`Map`
`getMap(String attribute)`
Returns a key/value pair map for a specified attribute.
`List`
`getMulti(String attribute)`
Returns a list of strings for a specified attribute.
`protected NameOpValue`
`getRelation(String attribute)`
`RslNode`
`getRslNode()`
Returns the rsl parse tree.
`String`
`getSingle(String attribute)`
Returns a string value of the specified attribute.
`Map`
`getVariables(String attribute)`
Returns a variable name/value pair map of variable definitions.
`void`
`remove(String attribute)`
Removes a specific attribute from attribute/value relations.
`boolean`
`remove(String attribute, String value)`
Removes a specific value from a list of values of the specified attribute.
`boolean`
`removeMap(String attribute, String key)`
Removes a specific key from a list of values of the specified attribute.
`boolean`
`removeVariable(String attribute, String varName)`
Removes a specific variable definition given a variable name.
`void`
`set(String attribute, String value)`
Sets the attribute value to the given value.
`void`
`setMulti(String attribute, String[] values)`
Sets the attribute value to the given list of values.
`String`
`toRSL()`
Returns the rsl.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### rslTree

protected RslNode rslTree

## Constructor Details

### 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(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 Details

### getRslNode

public RslNode getRslNode()
Returns the rsl parse tree.

Returns:
  the rsl parse tree.

### getSingle

public String getSingle(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 List getMulti(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 Map getMap(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 Map getVariables(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(String attribute, String varName, 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(String attribute, 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(String attribute)
Removes a specific attribute from attribute/value relations.

Parameters:
  `attribute` - the attribute name to remove.

### remove

public boolean remove(String attribute, 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(String attribute, 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(String attribute)

### set

public void set(String attribute, 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(String attribute, 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(String attribute, 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(String attribute, 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 String getFirstValue(String attribute)
Deprecated.
use getSingle() instead.
Returns the first value of a specified attribute.

Returns:
  the first value of the attribute.

### get

public List get(String attribute)
Deprecated.
use getMulti() instead.
Returns the values for a specified attribute.

Returns:
  the list of values.

### toRSL

public String toRSL()
Returns the rsl.

Returns:
  the rsl.