Class Value

  • Direct Known Subclasses:
    DoubleCompatibleValue, StringValue, TensorValue

    public abstract class Value
    extends java.lang.Object
    The result of a ranking expression evaluation. Concrete subclasses of this provides implementations of these methods or throws UnsupportedOperationException if the operation is not supported.
    Author:
    bratseth
    • Constructor Summary

      Constructors 
      Constructor Description
      Value()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract Value add​(Value value)  
      abstract Value and​(Value value)  
      abstract boolean asBoolean()
      Returns this value as a boolean.
      abstract double asDouble()
      Returns this value as a double, or throws UnsupportedOperationException if it cannot be represented as a double
      DoubleValue asDoubleValue()
      Returns this value as a double value, or throws UnsupportedOperationException if it cannot be represented as a double
      abstract Value asMutable()
      Returns this is mutable, or a mutable copy otherwise
      abstract com.yahoo.tensor.Tensor asTensor()
      Returns this as a tensor value
      abstract Value compare​(TruthOperator operator, Value value)
      Perform the comparison specified by the operator between this value and the given value
      abstract Value divide​(Value value)  
      protected com.yahoo.tensor.Tensor doubleAsTensor​(double value)
      A utility method for wrapping a double in a rank 0 tensor
      abstract boolean equals​(java.lang.Object other)  
      Value freeze()
      Irreversibly makes this immutable.
      abstract Value function​(Function function, Value value)
      Perform the given binary function on this value and the given value
      abstract boolean hasDouble()
      Returns true if this value can return itself as a double, i.e asDoubleValue will return a value and not throw
      abstract int hashCode()  
      boolean isFrozen()
      Returns true if this is immutable, false otherwise
      boolean isNaN()
      Returns true if this has a double value which is NaN
      abstract Value modulo​(Value value)  
      abstract Value multiply​(Value value)  
      abstract Value negate()  
      abstract Value not()  
      static Value of​(double scalar)  
      static Value of​(com.yahoo.tensor.Tensor tensor)  
      abstract Value or​(Value value)  
      static Value parse​(java.lang.String value)
      Parses the given string to a value and returns it.
      abstract Value power​(Value value)  
      abstract Value subtract​(Value value)  
      abstract java.lang.String toString()  
      abstract com.yahoo.tensor.TensorType type()
      Returns the type of this value
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Value

        public Value()
    • Method Detail

      • type

        public abstract com.yahoo.tensor.TensorType type()
        Returns the type of this value
      • asDouble

        public abstract double asDouble()
        Returns this value as a double, or throws UnsupportedOperationException if it cannot be represented as a double
      • asDoubleValue

        public DoubleValue asDoubleValue()
        Returns this value as a double value, or throws UnsupportedOperationException if it cannot be represented as a double
      • isNaN

        public boolean isNaN()
        Returns true if this has a double value which is NaN
      • asTensor

        public abstract com.yahoo.tensor.Tensor asTensor()
        Returns this as a tensor value
      • doubleAsTensor

        protected com.yahoo.tensor.Tensor doubleAsTensor​(double value)
        A utility method for wrapping a double in a rank 0 tensor
      • hasDouble

        public abstract boolean hasDouble()
        Returns true if this value can return itself as a double, i.e asDoubleValue will return a value and not throw
      • asBoolean

        public abstract boolean asBoolean()
        Returns this value as a boolean.
      • negate

        public abstract Value negate()
      • add

        public abstract Value add​(Value value)
      • subtract

        public abstract Value subtract​(Value value)
      • multiply

        public abstract Value multiply​(Value value)
      • divide

        public abstract Value divide​(Value value)
      • modulo

        public abstract Value modulo​(Value value)
      • and

        public abstract Value and​(Value value)
      • not

        public abstract Value not()
      • power

        public abstract Value power​(Value value)
      • compare

        public abstract Value compare​(TruthOperator operator,
                                      Value value)
        Perform the comparison specified by the operator between this value and the given value
      • function

        public abstract Value function​(Function function,
                                       Value value)
        Perform the given binary function on this value and the given value
      • freeze

        public Value freeze()
        Irreversibly makes this immutable. Overriders must always call super.freeze() and return this
        Returns:
        this for convenience
      • isFrozen

        public final boolean isFrozen()
        Returns true if this is immutable, false otherwise
      • asMutable

        public abstract Value asMutable()
        Returns this is mutable, or a mutable copy otherwise
      • toString

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

        public abstract boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public abstract int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • parse

        public static Value parse​(java.lang.String value)
        Parses the given string to a value and returns it. Different subtypes of Value will be returned depending on the string.
        Returns:
        a mutable Value
        Throws:
        java.lang.IllegalArgumentException - if the given string is not parseable as a value
      • of

        public static Value of​(com.yahoo.tensor.Tensor tensor)
      • of

        public static Value of​(double scalar)