ucar.netcdf
Class NamedDictionary

java.lang.Object
  extended byucar.netcdf.NamedDictionary
All Implemented Interfaces:
Serializable

class NamedDictionary
extends Object
implements Serializable

NamedDictionary is a collection of Named things. This is used in the implementation of the other netcdf collections. Note: no public methods, all are package scope or more private.

It turns out that people think that the order of these things is important. So, we implement as a Vector, with an aux Hashtable for lookup by name.

For serialization, we only put the Vector part over the wire. The Hashtable is reconstructed at the other end. In fact, we encode the vector as an array for transport, saving a few more bytes.


Constructor Summary
(package private) NamedDictionary(int size)
           
(package private) NamedDictionary(int size, Enumeration ee)
           
(package private) NamedDictionary(Named[] na)
           
 
Method Summary
(package private)  boolean contains(Object oo)
          Tests if the argument is in this set.
(package private)  boolean contains(String name)
          Tests if the Named identified by name is in this set.
(package private)  Enumeration elements()
          Returns an enumeration of the elements.
(package private)  Named get(String name)
          Gets the object associated with the specified name.
(package private)  int indexOf(Named elem)
          Searches for the specified object, starting from the first position and returns an index to it.
(package private)  Named put(Named value)
          Puts the specified element into the Dictionary, using the its name as key.
(package private)  Named remove(String name)
          Removes the element corresponding to the key.
(package private)  int size()
          Returns the number of elements contained within the Dictionary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedDictionary

NamedDictionary(Named[] na)

NamedDictionary

NamedDictionary(int size,
                Enumeration ee)

NamedDictionary

NamedDictionary(int size)
Method Detail

size

int size()
Returns the number of elements contained within the Dictionary.


elements

Enumeration elements()
Returns an enumeration of the elements. Use the Enumeration methods on the returned object to fetch the elements sequentially.

See Also:
Enumeration

get

Named get(String name)
Gets the object associated with the specified name.

Parameters:
name - the name of the dimension
Returns:
the dimension, or null if not found
See Also:
put(ucar.netcdf.Named)

put

Named put(Named value)
Puts the specified element into the Dictionary, using the its name as key. The element may be retrieved by doing a get() with the same name. The element cannot be null.

Parameters:
value - the specified element
Returns:
the old value of the key, or null if it did not have one.
Throws:
NullPointerException - If the value of the specified element is null.
See Also:
get(java.lang.String)

remove

Named remove(String name)
Removes the element corresponding to the key. Does nothing if the key is not present.

Parameters:
name - the name of the Named that needs to be removed
Returns:
the Named, or null if no match.

indexOf

int indexOf(Named elem)
Searches for the specified object, starting from the first position and returns an index to it. Only used by DimensionDictionary.

Parameters:
elem - the desired element
Returns:
the index of the element, or -1 if it was not found.

contains

boolean contains(String name)
Tests if the Named identified by name is in this set.

Parameters:
name - String which identifies the desired object
Returns:
true if and only if this set contains the Named

contains

boolean contains(Object oo)
Tests if the argument is in this set.

Parameters:
oo - some Object
Returns:
true if and only if this set contains oo TODO? typecheck?