Platform SDK Java 8.5 API Reference

com.genesyslab.platform.commons.collections
Class KVList

java.lang.Object
  extended by com.genesyslab.platform.commons.collections.KVList
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection
Direct Known Subclasses:
KeyValueCollection

public abstract class KVList
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable, java.util.Collection

Key-value list. Ordered collection of key-value pairs. Nulls are not accepted neither as a key nor as a value.

Keys are not required to be unique and getters will return first encountered value for the key. Use getEnumeration(String) if you need all pairs with the given key.

KVList implements Collection interface. The elements of the Collection are Pairs.

See Also:
Serialized Form

Nested Class Summary
static interface KVList.PairList
          A list of key-value pairs.
 
Field Summary
protected  KVList.PairList storage
          Pairs storage.
 
Constructor Summary
KVList()
           
 
Method Summary
 boolean add(java.lang.Object o)
           
 boolean addAll(java.util.Collection c)
           
 void addBinary(java.lang.String key, byte[] data)
          Adds binary value to the list with specified key.
 void addInt(java.lang.String key, int value)
          Adds integer value to the list with specified key.
 void addInt(java.lang.String key, java.lang.Integer value)
          Adds integer value to the list with specified key.
 void addObject(java.lang.String key, java.lang.Object value)
          Adds supported value to this list with specified key.
 void addString(java.lang.String key, java.lang.String value)
          Adds string value to the list with specified key.
 void addUTFString(java.lang.String key, java.lang.String value)
          Adds string value to the list with specified key.
 void addUTFString(java.lang.String key, UTFValue value)
          Adds string value to the list with specified key.
 void clear()
          Clears the list.
 java.lang.Object clone()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection c)
           
 boolean containsKey(java.lang.Object key)
           
protected abstract  Pair createPair(java.lang.Object key)
          Creates list specific Pair implementation.
 boolean equals(java.lang.Object obj)
           
 byte[] getBinary(java.lang.String key)
          Returns binary data stored with specified key.
 java.util.Comparator getComparator()
           
 java.util.Enumeration getEnumeration()
          Returns an Enumeration through this list.
 java.util.Enumeration getEnumeration(java.lang.String key)
          Returns an Enumeration of pairs with specified key from this list.
 java.lang.Integer getInt(java.lang.String key)
          Returns integer value stored with specified key.
protected  java.util.Enumeration getPairEnumeration(java.lang.Object key)
          Returns an Enumeration of pairs with specified key from this list.
 java.lang.String getString(java.lang.String key)
          Returns string value stored with specified key.
 int hashCode()
           
 boolean isEmpty()
          Checks if the list is empty (doesn't contain any pair)s
 java.util.Iterator iterator()
           
 int length()
          Returns length of this list (number of pairs).
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection c)
           
protected  Pair removePair(java.lang.Object key)
          Removes the pair with the specified key in this list.
 boolean retainAll(java.util.Collection c)
           
 void setComparator(java.util.Comparator comparator)
          Sets Comparator used to check equality of Pairs' key in key-related searches.
 int size()
           
protected abstract  void throwNotPair(java.lang.Object o)
          Checks that Object inserted to this KVList through Collection interface is appropriate Pair implementation (e.g.
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

storage

protected transient KVList.PairList storage
Pairs storage.

Constructor Detail

KVList

public KVList()
Method Detail

addBinary

public void addBinary(java.lang.String key,
                      byte[] data)
Adds binary value to the list with specified key.

Parameters:
key - key of the added pair
data - binary data

addInt

public void addInt(java.lang.String key,
                   int value)
Adds integer value to the list with specified key.

Parameters:
key - key of the added pair
value - integer value

addInt

public void addInt(java.lang.String key,
                   java.lang.Integer value)
Adds integer value to the list with specified key.

Parameters:
key - key of the added pair
value - integer value

addString

public void addString(java.lang.String key,
                      java.lang.String value)
Adds string value to the list with specified key. During serialization process this string will be represented in single byte encoding (using platform default one). If you use national symbols in the value, please consider using addUTFString(String, String) method.

Parameters:
key - key of the added pair
value - String value

addUTFString

public void addUTFString(java.lang.String key,
                         java.lang.String value)
Adds string value to the list with specified key. During serialization process this string will be represented by two bytes encoding (UTF16-BE).

Note: only value will be packed as UTF, but not key.

Parameters:
key - key of the added pair
value - string value

addUTFString

public void addUTFString(java.lang.String key,
                         UTFValue value)
Adds string value to the list with specified key. During serialization process this string will be represented by two bytes encoding (UTF16-BE).

Note: only value will be packed as UTF, but not key.

Parameters:
key - key of the added pair
value - UTF-string value

addObject

public void addObject(java.lang.String key,
                      java.lang.Object value)
               throws java.lang.IllegalArgumentException
Adds supported value to this list with specified key. Please note, that list does not support arbitrary values, there is limited amount of supported types. This method will throw exception if value is of unsupported type. Also, string values will be added as ordinary (one byte per simbol) string. If you need to use national symbols use addUTFString(String, String).

Parameters:
key - key of the added pair
value - value
Throws:
java.lang.IllegalArgumentException - if value has unsupported type

getBinary

public byte[] getBinary(java.lang.String key)
Returns binary data stored with specified key. If no such key in list or data is not binary (has some other type) null is returned.

Parameters:
key - key of the binary value
Returns:
binary data or null if key not found or value has some other type

getInt

public java.lang.Integer getInt(java.lang.String key)
Returns integer value stored with specified key. If no such key in list or data is not integer (has some other type) 0 (zero) is returned.

Parameters:
key - key of the integer value
Returns:
integer value or null if key not found or value has some other type

getString

public java.lang.String getString(java.lang.String key)
Returns string value stored with specified key. If no such key in list or data is not string (has some other type) null is returned.

Parameters:
key - key of the value
Returns:
string value or null if key not found or value has some other type

clear

public void clear()
Clears the list. The list will be empty after this call returns.

Specified by:
clear in interface java.util.Collection

length

public int length()
Returns length of this list (number of pairs).

Returns:
number of pairs in this list

isEmpty

public boolean isEmpty()
Checks if the list is empty (doesn't contain any pair)s

Specified by:
isEmpty in interface java.util.Collection
Returns:
true - if list is empty and false otherwise

getEnumeration

public java.util.Enumeration getEnumeration()
Returns an Enumeration through this list. Type of elements in this Enumeration depends on list implementation (list specific pairs).

Returns:
Enumeration for the list

getEnumeration

public java.util.Enumeration getEnumeration(java.lang.String key)
Returns an Enumeration of pairs with specified key from this list. Type of elements in this Enumeration depends on list implementation (list specific pairs).

Returns:
Enumeration for the list

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

equals

public boolean equals(java.lang.Object obj)
Specified by:
equals in interface java.util.Collection
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

size

public int size()
Specified by:
size in interface java.util.Collection

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Specified by:
toArray in interface java.util.Collection

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.Collection

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection

containsKey

public boolean containsKey(java.lang.Object key)

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.Collection

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface java.util.Collection

removeAll

public boolean removeAll(java.util.Collection c)
Specified by:
removeAll in interface java.util.Collection

retainAll

public boolean retainAll(java.util.Collection c)
Specified by:
retainAll in interface java.util.Collection

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection

setComparator

public void setComparator(java.util.Comparator comparator)
Sets Comparator used to check equality of Pairs' key in key-related searches.

Parameters:
comparator - the comparator to set

getComparator

public java.util.Comparator getComparator()
Returns:
the comparator

getPairEnumeration

protected java.util.Enumeration getPairEnumeration(java.lang.Object key)
Returns an Enumeration of pairs with specified key from this list. Type of elements in this Enumeration depends on list implementation (list specific pairs).

Returns:
Enumeration for the list

removePair

protected Pair removePair(java.lang.Object key)
Removes the pair with the specified key in this list. Returns the pair that was removed from the list.

Parameters:
key - the key of the pair to be removed
Returns:
the element that was removed

createPair

protected abstract Pair createPair(java.lang.Object key)
Creates list specific Pair implementation.

Parameters:
key - key of the pair to create
Returns:
list specific Pair implementation

throwNotPair

protected abstract void throwNotPair(java.lang.Object o)
Checks that Object inserted to this KVList through Collection interface is appropriate Pair implementation (e.g. KeyValuePair for TKVList)s

Parameters:
o - Object to insert

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.