org.codehaus.modello.generator.java.javasource

Class JNamedMap

public class JNamedMap extends Object

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

Author: Keith Visco

Constructor Summary
JNamedMap()
Creates a new JNamedMap
JNamedMap(int size)
Creates a new JNamedMap with the given size.
Method Summary
Objectget(String name)
Returns the Object associated with the given name.
Objectget(int index)
Returns the Object at the given index.
StringgetNameByObject(Object obj)
Returns the name associated with the given Object
VectorgetNames()
Return a Vector of names
VectorgetObjects()
Return a Vector of Objects
intindexOf(String name)
Returns the index of the Object which has been mapped (associated) with the given name
voidput(String name, Object obj)
Maps (associates) an Object with a name
Objectremove(int index)
Removes and returns the Object located at the given index
Objectremove(String name)
Removes and returns the Object associated with the given name
intsize()
Returns the number of Object associations currently in this named map

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 Object get(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 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 String getNameByObject(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 Vector getNames()
Return a Vector of names

Returns: a Vector of names

getObjects

public Vector getObjects()
Return a Vector of Objects

Returns: a Vector of Objects

indexOf

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

Returns: the index of the Object which has been mapped (associated) to the given name

put

public void put(String name, 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 Object remove(int index)
Removes and returns the Object located at the given index

Parameters: name the name of the Object to remove

Returns: the object removed from the map.

remove

public Object remove(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 © 2001-2008 Codehaus. All Rights Reserved.