|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfacets.util.StringFlags
public final class StringFlags
Container for flags defined using strings.
StringFlags
offers an alternative to int
constants to encode flags, being
int
s used as valuesint
s on externally
defined logical arcana.StringFlags
defines flags as set or reset by the presence or
absence in its (immutable) contained string of string constants which should be
created with newFlag(String)
. Collisions between partial or complete
flag strings are avoided by prefixing each with the PREFIX
constant
and by numbering flags sequentially.
Field Summary | |
---|---|
static StringFlags |
EMPTY
|
static java.lang.String |
FLAG_NONE
|
static java.lang.String |
PREFIX
|
Constructor Summary | |
---|---|
StringFlags(java.lang.String flags)
Unique constructor. |
Method Summary | |
---|---|
StringFlags |
addFlag(java.lang.String flag)
Add a flag. |
boolean |
includeFlag(java.lang.String flag)
Do the flags set include this flagged string? |
static java.lang.String |
newFlag(java.lang.String text)
Converts text into an appropriate flag. |
StringFlags |
removeFlag(java.lang.String flag)
Remove a flag. |
java.lang.String |
toString()
Lists the current set of flags. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PREFIX
public static final java.lang.String FLAG_NONE
public static final StringFlags EMPTY
Constructor Detail |
---|
public StringFlags(java.lang.String flags)
flags
- must a concatenation of strings created using newFlag(String)
.Method Detail |
---|
public static final java.lang.String newFlag(java.lang.String text)
The flag is guaranteed to be acceptable when passed to the constructor either on its own or concatenated with others created by this method. Such flags are therefore suitable as constants for use by application code.
text
- may be any string not including the PREFIX
constant
beyond its start and will define a single flagpublic boolean includeFlag(java.lang.String flag)
flag
- must have been created with newFlag(String)
.public StringFlags addFlag(java.lang.String flag)
flag
- must have been created with newFlag(String)
.
StringFlags
with flag
appended to the
flags if not already includedpublic StringFlags removeFlag(java.lang.String flag)
flag
- must have been created with newFlag(String)
.
StringFlags
with flag
absent from the
flagspublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |