com.plumtree.remote.util
Class NamedValueMap

java.lang.Object
  extended bycom.plumtree.remote.util.NamedValueMap
Direct Known Subclasses:
AuthInfo, CrawlerInfo, DataSourceInfo, ProfileInfo, SyncInfo, UserInfo, UserInfoMap, UserPrefs, UserPropertyInfo

public class NamedValueMap
extends java.lang.Object

Utility class that converts between an array of NamedValues and a HashMap. Useful when manipulating arrays of NamedValues.


Constructor Summary
NamedValueMap()
          Default constructor
NamedValueMap(NamedValue[] nvArray)
          Creates a new NamedValueMap instance and initializes it with values from the given array.
 
Method Summary
 void fromArray(NamedValue[] nvArray)
          Clears the current values and initializes with values from the given array.
 java.lang.String get(java.lang.String key)
          Returns the string value to which the specified name key is mapped or null if the key is not mapped to any values.
 java.lang.String put(java.lang.String key, java.lang.String value)
          Adds a name/value pair to the map, replacing any existing value.
 java.lang.String put(java.lang.String key, java.lang.String[] values)
          Adds multiple name/value pairs to the map, where the value is a String[], replacing any existing values.
 void remove(java.lang.String key)
          Removes the mapping for the key from the map if present.
 void remove(java.lang.String key, java.lang.String value)
          Removes the mapping for the key and value from the map if present.
 NamedValue[] toArray()
          Converts the contents of the NamedValueMap into a NamedValue array, and returns the array.
 java.lang.String toString()
          Returns a string for debugging.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NamedValueMap

public NamedValueMap()
Default constructor


NamedValueMap

public NamedValueMap(NamedValue[] nvArray)
Creates a new NamedValueMap instance and initializes it with values from the given array. Null NamedValues and NamedValues with null keys will not be added to the map. NamedValues with null values but valid keys will be imported

Parameters:
nvArray - the NamedValue array
Method Detail

get

public java.lang.String get(java.lang.String key)
Returns the string value to which the specified name key is mapped or null if the key is not mapped to any values. If the NamedValueMap has already been stored in the portal, then all names will be uppercased. If the key is mapped to a String[], then the first element of the String[] will be returned.

Parameters:
key - the key for which a string will be returned
Returns:
the mapped value or null if there is no mapping

put

public java.lang.String put(java.lang.String key,
                            java.lang.String value)
Adds a name/value pair to the map, replacing any existing value.

Parameters:
key - the key name; all names will be uppercased by the portal
value - the value to assign to the key; can be null
Returns:
the previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the NamedValueMap previously associated null with the specified key. If the previous element was a String[], this method returns the first element of the String[].

put

public java.lang.String put(java.lang.String key,
                            java.lang.String[] values)
Adds multiple name/value pairs to the map, where the value is a String[], replacing any existing values. Used when adding multi-value properties to the portal in Profile and Crawl. For example, if calling put("key1", {"value1", "value2", "value3"}); the following would be returned to the portal as the named value pairs:
key1 value1
key1 value2
key1 value3
This method is only supported for UserPropertyInfo in Profile.

Parameters:
key - the key name; all names will be uppercased by the portal
values - the value to assign to the key; can be null
Returns:
the previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the NamedValueMap previously associated null with the specified key. If the previous element was a String[], this will return the first element of the String[].

fromArray

public void fromArray(NamedValue[] nvArray)
Clears the current values and initializes with values from the given array. Null NamedValues and NamedValues with null names will not be added. NamedValues with null keys will be added. If multiple NamedValues have the same key and different values, then the values will be added to the map as a String[].

Parameters:
nvArray - the NamedValue array

toArray

public NamedValue[] toArray()
Converts the contents of the NamedValueMap into a NamedValue array, and returns the array. Keys with String[] mappings will be returned as multiple NamedValues.

Returns:
a NamedValue array

remove

public void remove(java.lang.String key)
Removes the mapping for the key from the map if present. Note: Since all names are uppercased by the portal, the key should also be uppercase. No exception is thrown if the key does not exist.

Parameters:
key - the key to match

remove

public void remove(java.lang.String key,
                   java.lang.String value)
Removes the mapping for the key and value from the map if present. If there is no matching key, the map is unchanged. If the matching object is a String, then the mapping is removed. If the matching object is a String[], then the matching value is removed from the String[]. If there are remaining elements in the String[], then the resulting String[] is put back into the map. If there are no remaining elements in the String[], then the mapping is removed. Note: Since all names are uppercased by the portal, the key should also be uppercase. No exception is thrown if the key does not exist.

Parameters:
key - the key to match

toString

public java.lang.String toString()
Returns a string for debugging.



For additional information on the Oracle® WebCenter Interaction Development Kit, including tutorials, blogs, code samples and more, see the Oracle Technology Network (http://www.oracle.com/technology/index.html).

Copyright ©2010 Oracle® Corporation. All Rights Reserved.