com.partnersoft.data
Class Naming<V>

java.lang.Object
  extended by com.partnersoft.data.Naming<V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,V>
Direct Known Subclasses:
NamedLists, NamedNameSets

public class Naming<V>
extends java.lang.Object
implements java.util.Map<java.lang.String,V>, java.lang.Cloneable, java.io.Serializable

An auto-sorted, string-indexed association.

A "naming" is an association between unique names and (possibly non-unique) values. In Java terms, it is a special case of String-indexed Map, where the keys are compared and looked up case-insensitively. Thus, it implements Map<String, V>.

This use of the term "naming" has nothing whatsoever to do with java.rmi.Naming.

This implementation does not automatically sort the entries by name; instead order is based on the order of the original data (if copied from lists or a Map) or based on insertion order. Removing a value, then putting it in again, will place it at the end of the list. We may add additional re-ordering methods later to help with e.g. GUI interfaces.

Copyright 2003-2006 Partner Software, Inc.

Version:
$Id: Naming.java 2474 2010-03-13 14:28:43Z paul $
Author:
Paul Reavis
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
Naming()
           
Naming(java.util.List<java.lang.String> names, java.util.List<V> values)
           
Naming(java.util.List<java.lang.String> names, java.util.List<V> values, boolean orderPreserving)
           
Naming(java.util.Map<? extends java.lang.String,? extends V> map)
           
Naming(java.lang.Object... contents)
          This constructor uses varargs to build the naming.
Naming(java.lang.String[] names, V[] values)
           
 
Method Summary
 void clear()
           
 java.lang.Object clone()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 Naming<V> copy()
          Returns a shallow copy of the Naming.
 java.lang.String createUniqueNameWithPrefix(java.lang.String prefix)
           
 java.util.Set<java.util.Map.Entry<java.lang.String,V>> entrySet()
           
 boolean equals(java.lang.Object nother)
           
 V get(java.lang.Object key)
           
 java.lang.String getNameAt(int i)
           
 int getSize()
           
 V getValue(java.lang.String key)
           
 V getValueAt(int index)
           
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Set<java.lang.String> keySet()
           
 V put(java.lang.String key, V value)
           
 void putAll(java.util.Map<? extends java.lang.String,? extends V> t)
           
 V remove(java.lang.Object key)
           
 V removeValue(java.lang.String key)
           
 void setOrderPreserving(boolean orderPreserving)
          Not sure what to do here, so it just logs a warning.
 void setValue(java.lang.String key, V value)
           
 int size()
           
 void sort()
          Sorts the keys in this naming, case-insensitively.
 java.lang.String toString()
           
 java.util.Collection<V> values()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Naming

public Naming()

Naming

public Naming(java.util.List<java.lang.String> names,
              java.util.List<V> values)

Naming

public Naming(java.util.List<java.lang.String> names,
              java.util.List<V> values,
              boolean orderPreserving)
Parameters:
names -
values -
orderPreserving -

Naming

public Naming(java.util.Map<? extends java.lang.String,? extends V> map)

Naming

public Naming(java.lang.String[] names,
              V[] values)

Naming

public Naming(java.lang.Object... contents)
This constructor uses varargs to build the naming. You simply supply the data in name, value, name, value order. Note that while this takes an array of objects, there must be an even number of values, and they must alternate String, V, String, V, etc. Break the rules and you'll get an IllegalArgumentException.

Method Detail

copy

public Naming<V> copy()
Returns a shallow copy of the Naming.


sort

public void sort()
Sorts the keys in this naming, case-insensitively.


clear

public void clear()
Specified by:
clear in interface java.util.Map<java.lang.String,V>

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map<java.lang.String,V>

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map<java.lang.String,V>

entrySet

public java.util.Set<java.util.Map.Entry<java.lang.String,V>> entrySet()
Specified by:
entrySet in interface java.util.Map<java.lang.String,V>

equals

public boolean equals(java.lang.Object nother)
Specified by:
equals in interface java.util.Map<java.lang.String,V>
Overrides:
equals in class java.lang.Object

get

public V get(java.lang.Object key)
Specified by:
get in interface java.util.Map<java.lang.String,V>

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map<java.lang.String,V>
Overrides:
hashCode in class java.lang.Object

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<java.lang.String,V>

keySet

public java.util.Set<java.lang.String> keySet()
Specified by:
keySet in interface java.util.Map<java.lang.String,V>

put

public V put(java.lang.String key,
             V value)
Specified by:
put in interface java.util.Map<java.lang.String,V>

putAll

public void putAll(java.util.Map<? extends java.lang.String,? extends V> t)
Specified by:
putAll in interface java.util.Map<java.lang.String,V>

remove

public V remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<java.lang.String,V>

size

public int size()
Specified by:
size in interface java.util.Map<java.lang.String,V>

values

public java.util.Collection<V> values()
Specified by:
values in interface java.util.Map<java.lang.String,V>

setValue

public void setValue(java.lang.String key,
                     V value)

getValue

public V getValue(java.lang.String key)

removeValue

public V removeValue(java.lang.String key)

getSize

public int getSize()

getNameAt

public java.lang.String getNameAt(int i)

getValueAt

public V getValueAt(int index)

setOrderPreserving

public void setOrderPreserving(boolean orderPreserving)
Not sure what to do here, so it just logs a warning.

Parameters:
orderPreserving -

createUniqueNameWithPrefix

public java.lang.String createUniqueNameWithPrefix(java.lang.String prefix)
Parameters:
prefix -
Returns:
Throws:
java.lang.UnsupportedOperationException - because it's not implemented.

toString

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

clone

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