Class AttributeBitmask
- java.lang.Object
-
- net.sf.gridarta.model.archetypetype.AttributeBitmask
-
public class AttributeBitmask extends java.lang.ObjectThis class manages bitmask values which appear in Gridarta archetype attributes. Attack type, spell path and material are such bitmasks. They are disguised for the user, with the help of the attribute dialog.
-
-
Constructor Summary
Constructors Constructor Description AttributeBitmask(boolean isNamed)Constructor of a bitmask from XML element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddBitName(int bitValue, @NotNull java.lang.String name)Defines a bit name for a bit value.voidaddName(@NotNull java.lang.String name, int value)Adds a readable name for a bit value.voidaddNamedValue(@NotNull java.lang.String name, int value)Adds a name for external encoding of a value.booleancontainsEncoding(int value)Returns whether an external encoding for value exists.intdecodeValue(@NotNull java.lang.String encodedValue)Convert a value from external representation.@NotNull java.lang.StringencodeValue(int value)Convert a value to external representation.@Nullable java.lang.StringgetBitName(int index)Returns the name of a bitmask value.intgetMaxValue()Returns the maximum allowed bitmask value.intgetNumber()Returns the number of bitmask entries (not counting zero).@NotNull java.lang.StringgetText(int value)Generate the text to be displayed for a given bitmask value.
-
-
-
Method Detail
-
getText
@NotNull public @NotNull java.lang.String getText(int value)
Generate the text to be displayed for a given bitmask value.- Parameters:
value- bitmask value- Returns:
Stringwith all entries belonging to the bitmask
-
encodeValue
@NotNull public @NotNull java.lang.String encodeValue(int value)
Convert a value to external representation.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.
- Parameters:
value- the value to convert- Returns:
- the external representation of the value
-
decodeValue
public int decodeValue(@NotNull @NotNull java.lang.String encodedValue)Convert a value from external representation.- Parameters:
encodedValue- the value in external representation- Returns:
- the decoded value
-
getMaxValue
public int getMaxValue()
Returns the maximum allowed bitmask value.- Returns:
- the maximum allowed bitmask value
-
getNumber
public int getNumber()
Returns the number of bitmask entries (not counting zero).- Returns:
- the number of bitmask entries
-
getBitName
@Nullable public @Nullable java.lang.String getBitName(int index)
Returns the name of a bitmask value.- Parameters:
index- the index of the bitmask value- Returns:
- the name or
nullif this index is not defined
-
addName
public void addName(@NotNull @NotNull java.lang.String name, int value)Adds a readable name for a bit value.- Parameters:
name- the namevalue- the bit value
-
addNamedValue
public void addNamedValue(@NotNull @NotNull java.lang.String name, int value)Adds a name for external encoding of a value.- Parameters:
name- the namevalue- the value
-
containsEncoding
public boolean containsEncoding(int value)
Returns whether an external encoding for value exists.- Parameters:
value- the value- Returns:
- whether an external encoding exists
-
addBitName
public boolean addBitName(int bitValue, @NotNull @NotNull java.lang.String name)Defines a bit name for a bit value.- Parameters:
bitValue- the bit valuename- the name- Returns:
- whether the entry was added
-
-