public class AttributeBitmask
extends java.lang.Object
Constructor and Description |
---|
AttributeBitmask(boolean isNamed)
Constructor of a bitmask from XML element.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addBitName(int bitValue,
@NotNull java.lang.String name)
Defines a bit name for a bit value.
|
void |
addName(@NotNull java.lang.String name,
int value)
Adds a readable name for a bit value.
|
void |
addNamedValue(@NotNull java.lang.String name,
int value)
Adds a name for external encoding of a value.
|
boolean |
containsEncoding(int value)
Returns whether an external encoding for value exists.
|
int |
decodeValue(@NotNull java.lang.String encodedValue)
Convert a value from external representation.
|
@NotNull java.lang.String |
encodeValue(int value)
Convert a value to external representation.
|
@Nullable java.lang.String |
getBitName(int index)
Returns the name of a bitmask value.
|
int |
getMaxValue()
Returns the maximum allowed bitmask value.
|
int |
getNumber()
Returns the number of bitmask entries (not counting zero).
|
@NotNull java.lang.String |
getText(int value)
Generate the text to be displayed for a given bitmask value.
|
public AttributeBitmask(boolean isNamed)
isNamed
- whether this attribute's bitmask values are to be encoded
as strings in external representation@NotNull public @NotNull java.lang.String getText(int value)
value
- bitmask valueString
with all entries belonging to the bitmask@NotNull public @NotNull java.lang.String encodeValue(int value)
Note that this function does not always return the shortest or simplest possible external representation. This is intentional to create the exact same result as the Crossfire server.
value
- the value to convertpublic int decodeValue(@NotNull @NotNull java.lang.String encodedValue)
encodedValue
- the value in external representationpublic int getMaxValue()
public int getNumber()
@Nullable public @Nullable java.lang.String getBitName(int index)
index
- the index of the bitmask valuenull
if this index is not definedpublic void addName(@NotNull @NotNull java.lang.String name, int value)
name
- the namevalue
- the bit valuepublic void addNamedValue(@NotNull @NotNull java.lang.String name, int value)
name
- the namevalue
- the valuepublic boolean containsEncoding(int value)
value
- the valuepublic boolean addBitName(int bitValue, @NotNull @NotNull java.lang.String name)
bitValue
- the bit valuename
- the name