|
Web Site | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.janino.util.enumerator.EnumeratorSet
A class that represents a set of enumerated values.
Its main features are its constructor, which initializes the object from a clear-text string,
and its toString()
method, which reconstructs the clear text values. Both is done
through reflection.
Use this class as follows:
public class Food extends EnumeratorSet { public static final Food BEEF = new Food(1); public static final Food LETTUCE = new Food(2); public static final Food BREAD = new Food(4); public static final Food NONE = new Food(0); public static final Food ALL = new Food(7); public Food(String s) throws EnumeratorFormatException { super(s); } public Food add(Food that) { return new Food(super.add(that)); } public Food remove(Food that) { return new Food(super.remove(that)); } private Food(int values) { super(values); } }
Constructor Summary | |
protected |
EnumeratorSet(int values)
Initialize the enumerator to the given OR'ed set of values. |
protected |
EnumeratorSet(String s)
Initialize an EnumeratorSet from a string. |
protected |
EnumeratorSet(String s,
String delimiter)
Initialize an EnumeratorSet from a string. |
Method Summary | |
protected int |
add(EnumeratorSet that)
Add to the object's values the given OR'ed set of values. |
boolean |
contains(EnumeratorSet that)
Check if the object contains any of the given values. |
boolean |
containsAllOf(EnumeratorSet that)
Check if the object contain all of the given values. |
boolean |
containsAnyOf(EnumeratorSet that)
Check if the object contain any of the given values. |
boolean |
equals(Object that)
Check the values' identity. |
int |
hashCode()
|
protected int |
remove(EnumeratorSet that)
Remove an OR'ed set of values from the object's values. |
String |
toString()
Convert an EnumeratorSet to a clear-text string. |
String |
toString(String delimiter)
Convert an EnumeratorSet into a clear-text string. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected EnumeratorSet(int values)
protected EnumeratorSet(String s) throws EnumeratorFormatException
EnumeratorSet
from a string.
Equivalent to EnumeratorSet(s, ",")
.
protected EnumeratorSet(String s, String delimiter) throws EnumeratorFormatException
EnumeratorSet
from a string.
The given string is parsed into tokens; each token is converted into a value by looking
at the class's public static final
fields which have the same type as
the class itself. The values are OR'ed together.
EnumeratorFormatException
- if a token cannot be identifiedMethod Detail |
protected int add(EnumeratorSet that)
protected int remove(EnumeratorSet that)
public boolean contains(EnumeratorSet that)
public boolean containsAnyOf(EnumeratorSet that)
public boolean containsAllOf(EnumeratorSet that)
public boolean equals(Object that)
public int hashCode()
public String toString()
EnumeratorSet
to a clear-text string.
Identical with toString(",")
.
public String toString(String delimiter)
EnumeratorSet
into a clear-text string.
Examine the object through reflection for public static final
fields that have the same type as this object, and collect the names of all fields who's
values are contained in the object's values. Return the names of these fields, concatenated
with the given delimiter
.
|
Web Site | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |