Class Feature


  • public class Feature
    extends java.lang.Object
    A feature is a single "feature" in a license. It has a
    • name,
    • a type
    • and a value.
    The type can be one of the types that are defined in the enumeration Feature.Type.

    There is a utility class inside this class called Feature.Create that contains public static methods to create features for each type. Invoking one of those methods is the way to create a new feature instance.

    A feature can be tested against the type calling one of the boolean methods isXXX(), where XXX is one of the types. Getting the value from a type should be via the methods getXXX, where, again, XXX is one of the types. Invoking getXXX for a feature that has a type that is not XXX will throw IllegalArgumentException.

    Features can be serialized to a byte array invoking the method serialized(). The same byte array can be used as an argument to the utility method Feature.Create.from(byte[]) to create a Feature of the same name and the same value.

    • Method Detail

      • name

        public java.lang.String name()
        Returns:
        the name of the feature.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • valueString

        public java.lang.String valueString()
        Returns:
        the string representation of the value of the feature.
      • serialized

        public byte[] serialized()
        Convert a feature to byte array. The bytes will have the following structure
              [4-byte type][4-byte name length][4-byte value length][name][value]
          
        or
              [4-byte type][4-byte name length][name][value]
          
        if the length of the value can be determined from the type (some types have fixed length values).
        Returns:
        the byte array representation of the feature
      • isBinary

        public boolean isBinary()
      • isString

        public boolean isString()
      • isByte

        public boolean isByte()
      • isShort

        public boolean isShort()
      • isInt

        public boolean isInt()
      • isLong

        public boolean isLong()
      • isFloat

        public boolean isFloat()
      • isDouble

        public boolean isDouble()
      • isBigInteger

        public boolean isBigInteger()
      • isBigDecimal

        public boolean isBigDecimal()
      • isDate

        public boolean isDate()
      • isUUID

        public boolean isUUID()
      • getBinary

        public byte[] getBinary()
      • getString

        public java.lang.String getString()
      • getByte

        public byte getByte()
      • getShort

        public short getShort()
      • getInt

        public int getInt()
      • getLong

        public long getLong()
      • getFloat

        public float getFloat()
      • getDouble

        public double getDouble()
      • getBigInteger

        public java.math.BigInteger getBigInteger()
      • getBigDecimal

        public java.math.BigDecimal getBigDecimal()
      • getUUID

        public java.util.UUID getUUID()
      • getDate

        public java.util.Date getDate()