org.exolab.javasource
Class JNamedMap

java.lang.Object
  extended by org.exolab.javasource.JNamedMap

public final class JNamedMap
extends java.lang.Object

A simple String to Object mapping which preserves order.
Note: This class is not synchronized. So be careful. :-)

Version:
$Revision: 7943 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
Author:
Keith Visco

Constructor Summary
JNamedMap()
          Creates a new JNamedMap.
JNamedMap(int size)
          Creates a new JNamedMap with the given size.
 
Method Summary
 java.lang.Object get(int index)
          Returns the Object at the given index.
 java.lang.Object get(java.lang.String name)
          Returns the Object associated with the given name.
 java.lang.String getNameByObject(java.lang.Object obj)
          Returns the name associated with the given Object.
 java.util.Vector<java.lang.String> getNames()
          Returns a Vector of names.
 java.util.Vector<java.lang.Object> getObjects()
          Returns a Vector of Objects.
 int indexOf(java.lang.String name)
          Returns the index of the Object which has been mapped (associated) with the given name.
 void put(java.lang.String name, java.lang.Object obj)
          Maps (associates) an Object with a name.
 java.lang.Object remove(int index)
          Removes and returns the Object located at the given index.
 java.lang.Object remove(java.lang.String name)
          Removes and returns the Object associated with the given name.
 int size()
          Returns the number of Object associations currently in this named map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JNamedMap

public JNamedMap()
Creates a new JNamedMap.


JNamedMap

public JNamedMap(int size)
Creates a new JNamedMap with the given size.

Parameters:
size - The initial size for this NamedMap.
Method Detail

get

public java.lang.Object get(java.lang.String name)
Returns the Object associated with the given name.

Parameters:
name - The name to search for.
Returns:
The Object associated with the given name.

get

public java.lang.Object get(int index)
Returns the Object at the given index.

Parameters:
index - The index of the Object to return.
Returns:
The Object at the given index.

getNameByObject

public java.lang.String getNameByObject(java.lang.Object obj)
Returns the name associated with the given Object.

Parameters:
obj - The Object to search for.
Returns:
The name of the given Object.

getNames

public java.util.Vector<java.lang.String> getNames()
Returns a Vector of names.

Returns:
A Vector of names.

getObjects

public java.util.Vector<java.lang.Object> getObjects()
Returns a Vector of Objects.

Returns:
A Vector of Objects.

indexOf

public int indexOf(java.lang.String name)
Returns the index of the Object which has been mapped (associated) with the given name.

Parameters:
name - The name to get the index of.
Returns:
The index of the Object which has been mapped (associated) to the given name.

put

public void put(java.lang.String name,
                java.lang.Object obj)
Maps (associates) an Object with a name.

Parameters:
name - The name to associate with the given Object.
obj - The Object to be mapped.

remove

public java.lang.Object remove(int index)
Removes and returns the Object located at the given index.

Parameters:
index - The index of the Object to remove.
Returns:
The object removed from the map.

remove

public java.lang.Object remove(java.lang.String name)
Removes and returns the Object associated with the given name.

Parameters:
name - The name of the Object to remove.
Returns:
The object removed from the map.

size

public int size()
Returns the number of Object associations currently in this named map.

Returns:
The number of Object associations currently in this named map.


Copyright © 2011. All Rights Reserved.