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,
java.lang.String name)
Defines a bit name for a bit value.
|
void |
addName(java.lang.String name,
int value)
Adds a readable name for a bit value.
|
void |
addNamedValue(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(java.lang.String encodedValue)
Convert a value from external representation.
|
java.lang.String |
encodeValue(int value)
Convert a value to external representation.
|
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).
|
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 java.lang.String getText(int value)
value
- bitmask valueString
with all entries belonging to the bitmask@NotNull public 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 java.lang.String encodedValue)
encodedValue
- the value in external representationpublic int getMaxValue()
public int getNumber()
@Nullable public java.lang.String getBitName(int index)
index
- the index of the bitmask valuenull
if this index is not definedpublic void addName(@NotNull java.lang.String name, int value)
name
- the namevalue
- the bit valuepublic void addNamedValue(@NotNull java.lang.String name, int value)
name
- the namevalue
- the valuepublic boolean containsEncoding(int value)
value
- the valuepublic boolean addBitName(int bitValue, @NotNull java.lang.String name)
bitValue
- the bit valuename
- the name