public class ClassConstants extends Hashtable implements Enumeration
It is a combination Enumeration and Hashtable.
It takes a list of constant names (Strings) and Hashes a unique int with them. This allows the user to access the Constants via an Enum mechanism or a Hash mechanism.
Modifier and Type | Field and Description |
---|---|
private int |
currentIndex_
The current index into the Enumeration of Constants.
|
private Enumeration |
enum_
The enumeration of constant names.
|
private int |
numConstants_
The number of Constants defined/assigned.
|
private Collection |
values_
The collection of int valkues assigned to the instantiated class
constants.
|
Constructor and Description |
---|
ClassConstants(int startVal,
int stepVal,
String[] constantNames)
Constructor that takes a list of names and assigns constant numbers starting
from the passed in 'startVal' and incrementing by the passed in stepVal.
|
ClassConstants(int startVal,
String[] constantNames)
Constructor that takes a list of names and assigns constant numbers starting
from the passed in 'startVal' and incrementing by 1.
|
ClassConstants(String[] constantNames)
Default constructor that takes a list of names and assigns constant numbers
starting from 0 and incrementing by 1.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(String constName)
Description of the Method
|
boolean |
equals(String constName,
int val)
Compares the passed in Constant name with
|
int |
getValueOf(String constName)
Gets the Constant valueof the ClassConstants object
|
boolean |
hasMoreElements()
Does this classes enumeration of constants have any more elements.
|
String |
nextConstantName()
Gets the next Enumerated Clas Constant Name.
|
Object |
nextElement()
Returns the next enumerated Constant as an Object.
|
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, values
private int currentIndex_
private int numConstants_
private Enumeration enum_
private Collection values_
public ClassConstants(String[] constantNames)
constantNames
- the list of names to give the constantspublic ClassConstants(int startVal, String[] constantNames)
startVal
- the int to start the enumeration atconstantNames
- the list of names to give the constantspublic ClassConstants(int startVal, int stepVal, String[] constantNames)
startVal
- the int to start the enumeration atstepVal
- the int to step the enumeration byconstantNames
- the list of names to give the constantspublic int getValueOf(String constName)
constName
- the constant to getpublic boolean hasMoreElements()
hasMoreElements
in interface Enumeration
public Object nextElement() throws NoSuchElementException
nextElement
in interface Enumeration
NoSuchElementException
- Description of Exceptionpublic String nextConstantName() throws NoSuchElementException
NoSuchElementException
public boolean equals(String constName, int val)
constName
- Constant name to compareval
- the int value to compare to the passed in Constant.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses