Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.plumtree.remote.util
Class NamedValueMap

    java.lang.Object
      com.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 `NamedValue`s and a `HashMap`. Useful when manipulating arrays of `NamedValue`s.

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 `NamedValue`s and `NamedValue`s with null keys will not be added to the map. `NamedValue`s 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 `NamedValue`s and `NamedValue`s with null names will not be added. `NamedValue`s with null keys will be added. If multiple `NamedValue`s 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 `NamedValue`s.

  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.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

For additional information on the IDK, including tutorials, blogs, code samples and more, see the AquaLogic User Interaction Developer Center on BEA dev2dev.

Copyright ©2007 BEA Systems, Inc. All Rights Reserved.