com.partnersoft.data
Class Naming

java.lang.Object
  extended by com.partnersoft.data.Naming
All Implemented Interfaces:
java.io.Serializable, java.util.Map

public class Naming
extends java.lang.Object
implements java.util.Map, java.io.Serializable

This is really a special case of Map, which consists of a sorted list of values keyed by a String name. This is such a common case, however, that it is worth special casing and optimizing. Naming is case insensitive.

Author:
Paul Reavis Copyright 2003 Partner Software, Inc.
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(boolean orderPreserving)
           
Naming(java.util.HashMap map)
           
Naming(java.util.List names, java.util.List values)
           
Naming(java.util.List names, java.util.List values, boolean orderPreserving)
           
Naming(java.util.Map map)
           
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 Naming copy()
           
 java.lang.String createUniqueNameWithPrefix(java.lang.String prefix)
          Used to support GUIs better, this provides you with a new unique name within this naming such that it has the given prefix and, if necessary, a sequence number.
 java.util.Set<java.util.Map.Entry> entrySet()
           
 int find(java.lang.String name)
           
 int findClosest(java.lang.String name)
           
 java.lang.Object get(java.lang.Object key)
           
 java.lang.String getNameAt(int i)
           
 int getSize()
           
 java.lang.Object getValue(java.lang.String name)
           
 java.lang.Object getValueAt(int i)
           
 boolean isEmpty()
           
 boolean isOrderPreserving()
           
 java.util.Set keySet()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void putAll(java.util.Map map)
           
 java.lang.Object remove(java.lang.Object key)
           
 java.lang.Object removeValue(java.lang.String name)
           
 void setAll(Naming nother)
           
 void setOrderPreserving(boolean tizit)
          Set to true if you want the naming to keep the order of entries without sorting them.
 java.lang.Object setValue(java.lang.String name, java.lang.Object value)
           
 int size()
           
 java.lang.String toString()
           
 java.util.Collection values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

Naming

public Naming()

Naming

public Naming(boolean orderPreserving)

Naming

public Naming(java.util.List names,
              java.util.List values)

Naming

public Naming(java.util.List names,
              java.util.List values,
              boolean orderPreserving)

Naming

public Naming(java.util.Map map)

Naming

public Naming(java.util.HashMap map)
Method Detail

toString

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

isOrderPreserving

public boolean isOrderPreserving()

setOrderPreserving

public void setOrderPreserving(boolean tizit)
Set to true if you want the naming to keep the order of entries without sorting them. This will cause performance problems for large lists, so beware.


setValue

public java.lang.Object setValue(java.lang.String name,
                                 java.lang.Object value)

getValue

public java.lang.Object getValue(java.lang.String name)

removeValue

public java.lang.Object removeValue(java.lang.String name)

getSize

public int getSize()

getNameAt

public java.lang.String getNameAt(int i)

getValueAt

public java.lang.Object getValueAt(int i)

find

public int find(java.lang.String name)

findClosest

public int findClosest(java.lang.String name)

setAll

public void setAll(Naming nother)

createUniqueNameWithPrefix

public java.lang.String createUniqueNameWithPrefix(java.lang.String prefix)
Used to support GUIs better, this provides you with a new unique name within this naming such that it has the given prefix and, if necessary, a sequence number. This allows you to create e.g. "new item", "new item 1", "new item 2", etc.


size

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

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map

putAll

public void putAll(java.util.Map map)
Specified by:
putAll in interface java.util.Map

clear

public void clear()
Specified by:
clear in interface java.util.Map

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map

entrySet

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

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map

copy

public Naming copy()