Package org.wildfly.security.util
Class StringEnumeration
- java.lang.Object
-
- org.wildfly.security.util.StringEnumeration
-
public final class StringEnumeration extends Object
An indexed enumeration of strings. The enumeration can look up string indexes by number, numeric indexes by string, or retrieve the interned string value by name.- Author:
- David M. Lloyd
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
StringEnumeration.Data
-
Field Summary
Fields Modifier and Type Field Description private StringEnumeration.Data[]
byId
private HashMap<String,StringEnumeration.Data>
index
-
Constructor Summary
Constructors Modifier Constructor Description private
StringEnumeration(HashMap<String,StringEnumeration.Data> index, StringEnumeration.Data[] byId)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
canonicalName(String str)
Get the canonical name for a string.int
indexOf(String str)
Get the numeric index for a string.String
nameOf(int index)
Get the canonical name for an index.static StringEnumeration
of(String... values)
Construct a new instance.int
size()
Get the size of this enumeration.
-
-
-
Field Detail
-
index
private final HashMap<String,StringEnumeration.Data> index
-
byId
private final StringEnumeration.Data[] byId
-
-
Constructor Detail
-
StringEnumeration
private StringEnumeration(HashMap<String,StringEnumeration.Data> index, StringEnumeration.Data[] byId)
-
-
Method Detail
-
of
public static StringEnumeration of(String... values)
Construct a new instance. The given values are used as the string members in the order they are given.- Parameters:
values
- the values- Returns:
- the string enumeration
-
canonicalName
public String canonicalName(String str)
Get the canonical name for a string. If the string is not found, an exception is thrown.- Parameters:
str
- the string to look up (must not benull
)- Returns:
- the canonical name (not
null
)
-
indexOf
public int indexOf(String str)
Get the numeric index for a string. If the string is not found, an exception is thrown.- Parameters:
str
- the string to look up (must not benull
)- Returns:
- the numeric index
-
nameOf
public String nameOf(int index)
Get the canonical name for an index. If the index is out of range, an exception is thrown.- Parameters:
index
- the index to seek- Returns:
- the canonical name (not
null
)
-
size
public int size()
Get the size of this enumeration.- Returns:
- the size of this enumeration
-
-