|
TrueZIP Kernel 7.0-rc2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.truezip.util.BitField<E>
E - The type of Enum objects contained in this set.@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) @Immutable public final class BitField<E extends Enum<E>>
A type-safe, immutable set of enums which emulates the concept of a bit field, i.e. a set of predefined bits. As an immutable class, it's inherently thread-safe. All modifying methods return a modified clone of this instance.
In general, passing null as a method parameter results in a
NullPointerException and methods return non-null.
TODO: Add more modifying methods.
| Field Summary | |
|---|---|
private EnumSet<E> |
bits
|
private static long |
serialVersionUID
|
| Constructor Summary | |
|---|---|
private |
BitField(Class<E> elementType,
boolean allOf)
Constructs a new bit field which contains all or none of the enums of the given element type. |
private |
BitField(E bit)
Constructs a new bit field which contains the given bit. |
private |
BitField(E bit,
E... bits)
Constructs a new bit field which contains the given bits. |
private |
BitField(EnumSet<E> bits)
Constructs a new bit field by sharing the given set of enums. |
| Method Summary | ||
|---|---|---|
static
|
allOf(Class<E> elementType)
Returns a bit field which contains all enums of the given element type. |
|
BitField<E> |
and(BitField<E> that)
|
|
int |
cardinality()
Returns the number of bits set in this field. |
|
BitField<E> |
clear(E bit)
Clears the given bit. |
|
boolean |
equals(Object that)
Returns true if and only if the given object is another
BitField and contains the same bits. |
|
boolean |
get(E bit)
Returns true if and only if the given bit is set. |
|
int |
hashCode()
Returns a hash code which is consistent with equals(java.lang.Object). |
|
boolean |
is(E bit)
Equivalent to get(bit). |
|
boolean |
isEmpty()
Returns true if and only if all bits are cleared in this bit
field. |
|
Iterator<E> |
iterator()
Returns a read-only iterator for the bits in this field. |
|
static
|
noneOf(Class<E> elementType)
Returns a bit field which can contain the given element type and is initially empty. |
|
BitField<E> |
not()
|
|
static
|
of(Class<E> elementType,
String list)
|
|
static
|
of(E bit)
Returns a bit field which contains the given bit. |
|
static
|
of(E bit,
E... bits)
Returns a bit field which contains the given bits. |
|
static
|
of(EnumSet<E> bits)
Returns a bit field which contains the same bits as the given set of enums. |
|
BitField<E> |
or(BitField<E> that)
|
|
BitField<E> |
set(E bit)
Sets the given bit. |
|
BitField<E> |
set(E bit,
boolean set)
Sets or clears the given bit. |
|
EnumSet<E> |
toEnumSet()
Returns a new set of enums containing the same bits as this instance. |
|
String |
toString()
Returns a concatenation of the names of the bits in this field, separated by "|". |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final long serialVersionUID
private final EnumSet<E extends Enum<E>> bits
| Constructor Detail |
|---|
private BitField(Class<E> elementType,
boolean allOf)
private BitField(E bit)
private BitField(E bit,
E... bits)
private BitField(EnumSet<E> bits)
bits - the set of enums to share with this instance.| Method Detail |
|---|
public static <E extends Enum<E>> BitField<E> noneOf(Class<E> elementType)
This could be used like this:
BitField<Option> field = BitField.noneOf(Option.class);
where Option is an arbitrary enum type.
public static <E extends Enum<E>> BitField<E> allOf(Class<E> elementType)
This could be used like this:
BitField<Option> field = BitField.allOf(Option.class);
where Option is an arbitrary enum type.
public static <E extends Enum<E>> BitField<E> of(E bit)
This could be used like this:
BitField<Option> field = BitField.of(Option.ONE);
where Option.ONE is an arbitrary enum.
public static <E extends Enum<E>> BitField<E> of(E bit,
E... bits)
This could be used like this:
BitField<Option> field = BitField.of(Option.ONE, Option.TWO);
where Option.ONE and Option.TWO are arbitrary enums.
public static <E extends Enum<E>> BitField<E> of(EnumSet<E> bits)
This could be used like this:
BitField<Option> field = BitField.of(bits);
where bits is an EnumSet<Option>.
public static <E extends Enum<E>> BitField<E> of(Class<E> elementType,
String list)
public boolean isEmpty()
true if and only if all bits are cleared in this bit
field.
public int cardinality()
public boolean get(E bit)
true if and only if the given bit is set.
bit - The bit to test.public boolean is(E bit)
get(bit).
public BitField<E> set(E bit,
boolean set)
Subclasses could override this method in order to cache frequently used results, such as a null bit field, a single bit field etc.
bit - The bit to set or clear.set - Whether the bit shall get set or cleared.public BitField<E> set(E bit)
public BitField<E> clear(E bit)
public BitField<E> not()
public BitField<E> and(BitField<E> that)
public BitField<E> or(BitField<E> that)
public Iterator<E> iterator()
iterator in interface Iterable<E extends Enum<E>>public EnumSet<E> toEnumSet()
null bit field bits:
bits.equals(BitField.of(bits.toEnumSet())).
public String toString()
"|".
toString in class Object
public boolean equals(@CheckForNull
Object that)
true if and only if the given object is another
BitField and contains the same bits.
equals in class Objectpublic int hashCode()
equals(java.lang.Object).
hashCode in class Object
|
TrueZIP Kernel 7.0-rc2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||