Class AttributeBitmask


  • public class AttributeBitmask
    extends java.lang.Object
    This 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
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AttributeBitmask

        public AttributeBitmask​(boolean isNamed)
        Constructor of a bitmask from XML element.
        Parameters:
        isNamed - whether this attribute's bitmask values are to be encoded as strings in external representation
    • 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:
        String with 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 null if 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 name
        value - 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 name
        value - 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 value
        name - the name
        Returns:
        whether the entry was added