Class FlagCoding

  • All Implemented Interfaces:
    Extensible

    public class FlagCoding
    extends SampleCoding
    Provides the information required to decode integer sample values that are combined of single flags (bit indexes).
    • Constructor Detail

      • FlagCoding

        public FlagCoding​(String name)
        Constructs a new flag coding object with the given name.
        Parameters:
        name - the name
    • Method Detail

      • getFlag

        public MetadataAttribute getFlag​(String name)
        Returns a metadata attribute wich is the representation of the flag with the given name. This method delegates to getPropertyValue(String).
        Parameters:
        name - the flag name
        Returns:
        a metadata attribute wich is the representation of the flag with the given name
      • getFlagNames

        public String[] getFlagNames()
        Returns a string array which contains the names of all flags contained in this FlagCoding object.
        Returns:
        a string array which contains all names of this FlagCoding.
        If this FlagCoding does not contain any flag, null is returned
      • addFlag

        public MetadataAttribute addFlag​(String name,
                                         int flagMask,
                                         String description)
        Adds a new flag definition to this flags coding.
        Parameters:
        name - the flag name
        flagMask - the flag's bit mask
        description - the description text
        Returns:
        A new attribute representing the flag.
        Throws:
        IllegalArgumentException - if name is null
      • addFlag

        public MetadataAttribute addFlag​(String name,
                                         int flagMask,
                                         int flagValue,
                                         String description)
        Adds a new flag definition to this flags coding.
        Parameters:
        name - the flag name
        flagMask - the flag's bit mask
        description - the description text
        Returns:
        A new attribute representing the flag.
        Throws:
        IllegalArgumentException - if name is null
        Since:
        SNAP 0.5
      • getFlagMask

        public int getFlagMask​(String name)
        Returns the flag mask value for the specified flag name.
        Parameters:
        name - the flag name
        Returns:
        flagMask the flag's bit mask as a 32 bit integer
        Throws:
        IllegalArgumentException - if name is null, or a flag with the name does not exist
      • acceptVisitor

        public void acceptVisitor​(ProductVisitor visitor)
        Accepts the given visitor. This method implements the well known 'Visitor' design pattern of the gang-of-four. The visitor pattern allows to define new operations on the product data model without the need to add more code to it. The new operation is implemented by the visitor.

        The method simply calls visitor.visit(this).

        Overrides:
        acceptVisitor in class MetadataElement
        Parameters:
        visitor - the visitor, must not be null