cleoni.adv
Class Dict

java.lang.Object
  extended by cleoni.adv.ManageableObject
      extended by cleoni.adv.Dict
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
DictSorted

public class Dict
extends ManageableObject
implements java.lang.Cloneable, java.io.Serializable

Modified version of the Vector class, so that it works like an associative array. Dictionary object. SETS are Dictionary object. See VBScript documentation on Dictionary objects

See Also:
Serialized Form

Field Summary
protected  int elementCount
          The number of valid components in the vector.
protected  java.lang.Object[] elementData
          The array buffer into which the components of the vector are stored.
protected  java.lang.String[] keys
           
 
Fields inherited from class cleoni.adv.ManageableObject
methodArgs, methods
 
Constructor Summary
Dict()
          Constructs an empty vector.
Dict(int initialCapacity)
          Constructs an empty vector with the specified initial capacity.
Dict(int initialCapacity, int capacityIncrement, boolean areDupsAllowed)
          Constructs an empty vector with the specified initial capacity and capacity increment.
 
Method Summary
 int capacity()
          Returns the current capacity of this vector.
 void clear()
          Removes all components from this vector and sets its size to zero.
 java.lang.Object clone()
          Returns a clone of this vector.
 boolean containsKey(java.lang.String key)
          Tests if the specified object is a component in this vector.
 void copyInto(java.lang.Object[] anArray)
          Copies the components of this vector into the specified array.
 void copyKeysInto(java.util.Vector myvect)
          Copies the components of this vector into the specified array.
 java.lang.Object elementAt(int index)
          Returns the component at the specified index.
 java.util.Enumeration elements()
          Returns an enumeration of the components of this vector.
 void ensureCapacity(int minCapacity)
          Increases the capacity of this vector, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.
protected  void ensureCapacityHelper(int minCapacity)
          This implements the unsynchronized semantics of ensureCapacity.
 java.lang.Object firstElement()
          Returns the first component of this vector.
 java.lang.String firstKey()
          Returns the first component of this vector.
 java.lang.Object get(java.lang.String key)
          Gets an object
 java.lang.Object getIC(java.lang.String key)
           
 java.lang.String getS(java.lang.String key)
           
 int indexOf(java.lang.String key)
          Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.
 void insertElementAt(java.lang.Object obj, int index)
          Inserts the specified object as a component in this vector at the specified index.
 boolean isEmpty()
          Tests if this vector has no components.
 java.lang.String keyAt(int index)
          Returns the component at the specified index.
 java.lang.Object lastElement()
          Returns the last component of the vector.
 java.lang.Object lastKey()
          Returns the last component of the vector.
 void put(java.lang.String key, java.lang.Object obj)
          Adds the specified component to the end of this vector, increasing its size by one.
 boolean remove(java.lang.String id)
          Removes the first occurrence of the argument from this vector.
 void removeAt(int index)
          Deletes the component at the specified index.
 void setElementAt(java.lang.Object obj, int index)
          Sets the component at the specified index of this vector to be the specified object.
 void setSize(int newSize)
          Sets the size of this vector.
 int size()
          Returns the number of components in this vector.
 java.lang.String toSettingsPair(java.lang.String sep)
          Returns a string representation of this vector.
 java.lang.String toString()
          Returns a string representation of this vector.
 void trimToSize()
          Trims the capacity of this vector to be the vector's current size.
 
Methods inherited from class cleoni.adv.ManageableObject
execMethod, getId, getMethodArgs, getMethods, getName, hasMethod, varExists, varGet, varGet
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

keys

protected java.lang.String[] keys

elementData

protected java.lang.Object[] elementData
The array buffer into which the components of the vector are stored. The capacity of the vector is the length of this array buffer.

Since:
JDK1.0

elementCount

protected int elementCount
The number of valid components in the vector.

Since:
JDK1.0
Constructor Detail

Dict

public Dict()
Constructs an empty vector.

Since:
JDK1.0

Dict

public Dict(int initialCapacity)
Constructs an empty vector with the specified initial capacity.

Parameters:
initialCapacity - the initial capacity of the vector.
Since:
JDK1.0

Dict

public Dict(int initialCapacity,
            int capacityIncrement,
            boolean areDupsAllowed)
Constructs an empty vector with the specified initial capacity and capacity increment.

Parameters:
areDupsAllowed - must be True is duplicates are allowed
initialCapacity - the initial capacity of the vector.
capacityIncrement - the amount by which the capacity is increased when the vector overflows.
Since:
JDK1.0
Method Detail

capacity

public final int capacity()
Returns the current capacity of this vector.

Returns:
the current capacity of this vector.
Since:
JDK1.0

clear

public final void clear()
Removes all components from this vector and sets its size to zero.

Since:
JDK1.0

clone

public java.lang.Object clone()
Returns a clone of this vector.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this vector.
Since:
JDK1.0

containsKey

public final boolean containsKey(java.lang.String key)
Tests if the specified object is a component in this vector.

Parameters:
key -
Returns:
true if the specified object is a component in this vector; false otherwise.
Since:
JDK1.0

copyInto

public final void copyInto(java.lang.Object[] anArray)
Copies the components of this vector into the specified array. The array must be big enough to hold all the objects in this vector.

Parameters:
anArray - the array into which the components get copied.
Since:
JDK1.0

copyKeysInto

public final void copyKeysInto(java.util.Vector myvect)
Copies the components of this vector into the specified array. The array must be big enough to hold all the objects in this vector.

Parameters:
anArray - the array into which the components get copied.
Since:
JDK1.0

elementAt

public final java.lang.Object elementAt(int index)
Returns the component at the specified index.

Parameters:
index - an index into this vector.
Returns:
the component at the specified index.
Since:
JDK1.0

elements

public final java.util.Enumeration elements()
Returns an enumeration of the components of this vector.

Returns:
an enumeration of the components of this vector.
Since:
JDK1.0
See Also:
Enumeration

ensureCapacity

public final void ensureCapacity(int minCapacity)
Increases the capacity of this vector, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.

Parameters:
minCapacity - the desired minimum capacity.
Since:
JDK1.0

ensureCapacityHelper

protected void ensureCapacityHelper(int minCapacity)
This implements the unsynchronized semantics of ensureCapacity. Synchronized methods in this class can internally call this method for ensuring capacity without incurring the cost of an extra synchronization.

See Also:
Vector.ensureCapacity(int)

firstElement

public final java.lang.Object firstElement()
                                    throws java.lang.Exception
Returns the first component of this vector.

Returns:
the first component of this vector.
Throws:
NoSuchElementException - if this vector has no components.
java.lang.Exception
Since:
JDK1.0

firstKey

public final java.lang.String firstKey()
                                throws java.lang.Exception
Returns the first component of this vector.

Returns:
the first key of this vector.
Throws:
NoSuchElementException - if this vector has no components.
java.lang.Exception
Since:
JDK1.0

get

public java.lang.Object get(java.lang.String key)
Gets an object

Parameters:
key - key to be searched
Returns:
the searched object, null otherwise

getS

public final java.lang.String getS(java.lang.String key)

indexOf

public int indexOf(java.lang.String key)
Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.

Parameters:
elem - an object.
Returns:
the index of the first occurrence of the object argument in this vector at position index or later in the vector; returns -1 if the object is not found.
Since:
JDK1.0
See Also:
Object.equals(java.lang.Object)

insertElementAt

public final void insertElementAt(java.lang.Object obj,
                                  int index)
Inserts the specified object as a component in this vector at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously.

The index must be a value greater than or equal to 0 and less than or equal to the current size of the vector.

Parameters:
obj - the component to insert.
index - where to insert the new component.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.
Since:
JDK1.0
See Also:
Vector.size()

isEmpty

public final boolean isEmpty()
Tests if this vector has no components.

Returns:
true if this vector has no components; false otherwise.
Since:
JDK1.0

keyAt

public final java.lang.String keyAt(int index)
Returns the component at the specified index.

Parameters:
index - an index into this vector.
Returns:
the component at the specified index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if an invalid index was given.
Since:
JDK1.0

lastElement

public final java.lang.Object lastElement()
                                   throws java.lang.Exception
Returns the last component of the vector.

Returns:
the last component of the vector, i.e., the component at index size() - 1.
Throws:
NoSuchElementException - if this vector is empty.
java.lang.Exception
Since:
JDK1.0

lastKey

public final java.lang.Object lastKey()
                               throws java.lang.Exception
Returns the last component of the vector.

Returns:
the last component of the vector, i.e., the component at index size() - 1.
Throws:
NoSuchElementException - if this vector is empty.
java.lang.Exception
Since:
JDK1.0

put

public void put(java.lang.String key,
                java.lang.Object obj)
Adds the specified component to the end of this vector, increasing its size by one. The capacity of this vector is increased if its size becomes greater than its capacity.

Parameters:
obj - the component to be added.
Since:
JDK1.0

remove

public final boolean remove(java.lang.String id)
Removes the first occurrence of the argument from this vector. If the object is found in this vector, each component in the vector with an index greater or equal to the object's index is shifted downward to have an index one smaller than the value it had previously.

Parameters:
obj - the component to be removed.
Returns:
true if the argument was a component of this vector; false otherwise.
Since:
JDK1.0

removeAt

public final void removeAt(int index)
Deletes the component at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted downward to have an index one smaller than the value it had previously.

The index must be a value greater than or equal to 0 and less than the current size of the vector.

Parameters:
index - the index of the object to remove.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.
Since:
JDK1.0
See Also:
Vector.size()

setElementAt

public final void setElementAt(java.lang.Object obj,
                               int index)
Sets the component at the specified index of this vector to be the specified object. The previous component at that position is discarded.

The index must be a value greater than or equal to 0 and less than the current size of the vector.

Parameters:
obj - what the component is to be set to.
index - the specified index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.
Since:
JDK1.0
See Also:
Vector.size()

setSize

public final void setSize(int newSize)
Sets the size of this vector. If the new size is greater than the current size, new null items are added to the end of the vector. If the new size is less than the current size, all components at index newSize and greater are discarded.

Parameters:
newSize - the new size of this vector.
Since:
JDK1.0

size

public final int size()
Returns the number of components in this vector.

Returns:
the number of components in this vector.
Since:
JDK1.0

toString

public final java.lang.String toString()
Returns a string representation of this vector.

Overrides:
toString in class ManageableObject
Returns:
a string representation of this vector.
Since:
JDK1.0

toSettingsPair

public final java.lang.String toSettingsPair(java.lang.String sep)
Returns a string representation of this vector.

Returns:
a string representation of this vector.
Since:
JDK1.0

trimToSize

public final void trimToSize()
Trims the capacity of this vector to be the vector's current size. An application can use this operation to minimize the storage of a vector.

Since:
JDK1.0

getIC

public java.lang.Object getIC(java.lang.String key)