***  This class provides Binary Compatibility only, not Source Compatibility  ***

com.sas.services.util
Class AttributeMap

com.sas.services.util.AttributeMap
All Implemented Interfaces:
AttributeMapInterface, java.io.Serializable, java.rmi.Remote

public class AttributeMap
implements AttributeMapInterface

Represents the name/value pairs. A name/value can be specified as a name, a name and a value, or a name and multiple values.

Name/value pairs are used by the Publish services to provide user or application control information describing the result package or entry. Name/values can be associated with a result package, or with individual entries within the result package.

Since:
1.0
See Also:
Serialized Form

Constructor Summary
AttributeMap()
          Constructor.
 
Method Summary
 void addAttribute(java.lang.String name, java.lang.String value)
          Add a value to existing name/value pair.
static boolean applyFilter(java.lang.String filter, AttributeMapInterface attr)
          Apply a filter string to the specified name/value pairs to determine if there is a match.
static java.lang.String buildValue(java.lang.String[] values)
          Takes the values of a name/value pair, and builds the appropriate value String.
 java.lang.String getAttribute(java.lang.String name)
          Get the value for the specified name.
 java.lang.String[] getAttributes(java.lang.String name)
          Get all the values for the specified name.
 java.lang.String[] listAttributeNames()
          Returns an array of all the names.
static AttributeMapInterface parseNameValuePairs(AttributeMapInterface attrMap, java.lang.String nameValuePairs)
          Parses a name/value pairs string.
static AttributeMapInterface parseValues(AttributeMapInterface attrMap, java.lang.String name, java.lang.String values)
          Parses a name/value pairs string.
 void setAttribute(java.lang.String name, java.lang.String value)
          Set the name/value pair.
 

Constructor Detail

AttributeMap

public AttributeMap()
             throws java.rmi.RemoteException
Constructor.

Throws:
java.rmi.RemoteException - if unable to export a remote object to the RMI system.
Method Detail

getAttribute

public java.lang.String getAttribute(java.lang.String name)
                              throws java.rmi.RemoteException
Get the value for the specified name. If there are multiple values for this name, it returns the first name that was added.

Specified by:
getAttribute in interface AttributeMapInterface
Parameters:
name - The name portion of the name/value pair.
Returns:
String The value.
Throws:
java.rmi.RemoteException - If a network anomaly is encountered.

getAttributes

public java.lang.String[] getAttributes(java.lang.String name)
                                 throws java.rmi.RemoteException
Get all the values for the specified name. If no values exist for this name, an empty array is returned.

Specified by:
getAttributes in interface AttributeMapInterface
Parameters:
name - The name portion of the name/value pair.
Returns:
String[] An array of all values for the specified name.
Throws:
java.rmi.RemoteException - If a network anomaly is encountered.

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
                  throws java.rmi.RemoteException,
                         java.lang.IllegalArgumentException
Set the name/value pair. Any existing value(s) will be cleared in favor of the new value.

Specified by:
setAttribute in interface AttributeMapInterface
Parameters:
name - The name portion of the name/value pair.
value - The value portion of the name/value pair. If this value is null, any existing value(s) are removed for the name/value pair.
Throws:
java.lang.IllegalArgumentException - If a null or blank name is specified.
java.rmi.RemoteException - If a network anomaly is encountered.

addAttribute

public void addAttribute(java.lang.String name,
                         java.lang.String value)
                  throws java.rmi.RemoteException,
                         java.lang.IllegalArgumentException
Add a value to existing name/value pair. This value is appended to the set of any existing values for the specified name. If this name does not already exist, the behavior is the same as setAttribute(String, String). The order is preserved between addAttribute and getAttributes(String).

Specified by:
addAttribute in interface AttributeMapInterface
Parameters:
name - The name portion of the name/value pair.
value - The value portion of the name/value pair.
Throws:
java.lang.IllegalArgumentException - If a null or blank name is specified.
java.rmi.RemoteException - If a network anomaly is encountered.

listAttributeNames

public java.lang.String[] listAttributeNames()
                                      throws java.rmi.RemoteException
Returns an array of all the names.

Specified by:
listAttributeNames in interface AttributeMapInterface
Returns:
Set An array of all the names.
Throws:
java.rmi.RemoteException - If a network anomaly is encountered.

parseNameValuePairs

public static AttributeMapInterface parseNameValuePairs(AttributeMapInterface attrMap,
                                                        java.lang.String nameValuePairs)
                                                 throws ParseException
Parses a name/value pairs string. The parsed name/values are returned in a AttributeMapInterface object.

Parameters:
attrMap - The AttributeMapInterface to continue to build with the parsed name/value pairs. This may be null. If null, a new attribute map will be created and returned. If not null, the existing map will be updated and returned.
nameValuePairs - The name/value string to parse.
Returns:
AttributeMapInterface The name/value pairs attribute map.
Throws:
ParseException - If an error occurs during parsing.

parseValues

public static AttributeMapInterface parseValues(AttributeMapInterface attrMap,
                                                java.lang.String name,
                                                java.lang.String values)
                                         throws ParseException
Parses a name/value pairs string. The parsed name/values are returned in a AttributeMapInterface object.

Parameters:
attrMap - The AttributeMapInterface to continue to build with the parsed name/value pairs. This may be null. If null, a new attribute map will be created and returned. If not null, the existing map will be updated and returned.
name - The name to parse.
values - Values to be parsed.
Returns:
Map of attributes.
Throws:
ParseException - If an error occurs during parsing.

buildValue

public static java.lang.String buildValue(java.lang.String[] values)
                                   throws ParseException
Takes the values of a name/value pair, and builds the appropriate value String. Single values that contain spaces will quoted. For example, "single value with spaces". The constructed String will contain the quotes. Multi-valued name/value specifications will be surrounded in parenthesis, and values will be comma-separated. For example, (value1, "value 2", value3, ...valueN).

Parameters:
values - The array of values for this name/value specification
Returns:
String The constructed values string. This may be null.
Throws:
ParseException - If an error is encountered building the value string.

applyFilter

public static boolean applyFilter(java.lang.String filter,
                                  AttributeMapInterface attr)
                           throws ParseException
Apply a filter string to the specified name/value pairs to determine if there is a match.

Parameters:
filter - Filter to be applied.
attr - Map of attributes.
Returns:
boolean Returns true if the name/value filter matches the name/value pair specification; otherwise if there is not match, false is returned.
Throws:
ParseException - If an error occurs parsing the name/value filter.

***  This class provides Binary Compatibility only, not Source Compatibility  ***




Copyright © 2009 SAS Institute Inc. All Rights Reserved.