JMV 0.80 Programmer's Documentation

Class NameList

java.lang.Object
  |
  +--NameList

public class NameList
extends java.lang.Object

Storage class to store an Object and to be able to access it from its name or its index. Good for storeing many objects that may have the same name.


Constructor Summary
NameList()
          Constructor
 
Method Summary
 int addName(java.lang.String name, java.lang.Object value)
          Adds a new entry
 int getIndex(java.lang.String name)
          Gets the index of an entry based on its name
 java.lang.String getName(int index)
          Gets the name of an entry based on its index
 java.lang.Object getValue(int index)
          Gets the Object stored in an entry based on its index
 java.lang.Object getValue(java.lang.String name)
          Gets the Object stored in an entry based on its name
 void setName(int index, java.lang.String newname)
          Sets the name of an entry based on its index
 void setValue(int index, java.lang.Object value)
          Sets an Object in an entry based on its index
 int size()
          Gets the number of entries
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NameList

public NameList()
Constructor

Method Detail

size

public int size()
Gets the number of entries

Returns:
the number of entries in the NameList

addName

public int addName(java.lang.String name,
                   java.lang.Object value)
Adds a new entry

Parameters:
name - the name of the new entry
value - the Object to store
Returns:
the index of the newly created entry

getName

public java.lang.String getName(int index)
Gets the name of an entry based on its index

Parameters:
index - the index of the Object to get
Returns:
the name associated with the entry with the specified index

setName

public void setName(int index,
                    java.lang.String newname)
Sets the name of an entry based on its index

Parameters:
index - the index of the entry whose name is to be changed
newname - the new name

getIndex

public int getIndex(java.lang.String name)
Gets the index of an entry based on its name

Parameters:
name - the name of the entry
Returns:
the index of the entry

getValue

public java.lang.Object getValue(java.lang.String name)
Gets the Object stored in an entry based on its name

Parameters:
name - the name of the entry
Returns:
the stored Object

getValue

public java.lang.Object getValue(int index)
Gets the Object stored in an entry based on its index

Parameters:
index - the index of the entry
Returns:
the stored Object

setValue

public void setValue(int index,
                     java.lang.Object value)
Sets an Object in an entry based on its index

Parameters:
index - the index of the entry to modify
value - the new Object to store in this entry

Copyright (C) 2000-2002 The Board of Trustees of the University of Illinois