Class NodeRanges

All Implemented Interfaces:
Cloneable, Contradictable

public class NodeRanges extends VSpaceBase<ComparableNodeValue,Object> implements Contradictable, Cloneable
Track ranges of nodes in their respective value space classifications (vsc). An empty set of ranges is treated as 'contradiction'. This means it is not possible FIXME Use of non-singletons in the 'unknown' value space must be handled as effectively unconstrained FIXME Extend the API with meta-interfaces. e.g. Dimension classes (for numeric, string, iri, etc) could check whether values are within their range. | zzz 999 | | ... .. | a 1 |______________ -> value spaces | | string int ...
Author:
raven
  • Constructor Details

    • NodeRanges

      public NodeRanges(boolean isVscExhaustive)
    • NodeRanges

      public NodeRanges(boolean isVscExhaustive, Map<Object,com.google.common.collect.RangeSet<ComparableNodeValue>> vscToRangeSets)
  • Method Details

    • getIriRanges

      public com.google.common.collect.RangeSet<ComparableNodeValue> getIriRanges()
    • clone

      public NodeRanges clone()
      Create an independent copy of this object
      Overrides:
      clone in class Object
    • createOpen

      public static NodeRanges createOpen()
      Create a NodeRange that contains everything
    • createClosed

      public static NodeRanges createClosed()
      Create a NodeRange that contains nothing
    • addEmptyDimension

      public NodeRanges addEmptyDimension(Object dimension)
      Description copied from class: VSpaceBase
      Add a new empty dimension. Do nothing if it already exists or if the dimensions are exhaustive
      Overrides:
      addEmptyDimension in class VSpaceBase<ComparableNodeValue,Object>
    • addOpenDimension

      public NodeRanges addOpenDimension(Object dimension)
      Description copied from class: VSpaceBase
      Add a new unconstrained dimension. Do nothing if it already exists or dimensions are non-exhaustive
      Overrides:
      addOpenDimension in class VSpaceBase<ComparableNodeValue,Object>
    • stateValue

      public NodeRanges stateValue(org.apache.jena.graph.Node value)
      Constrain the value space to only the given node - this is an intersection operation
    • addValue

      public NodeRanges addValue(org.apache.jena.graph.Node value)
      Add a constant to its respective value space This is a union-like operation - its does not constrain the space to the given value
    • substractValue

      public boolean substractValue(org.apache.jena.graph.Node value)
      Add the negation of a value; e.g. ?x != 5 This only excludes the value from its respective value space. Any other value space or whether their enumeration is exhaustive is unaffected.
      Parameters:
      value -
      Returns:
      True if this is in conflicting state
    • isVscExhaustive

      public boolean isVscExhaustive()
    • getValueSpaces

      public Set<?> getValueSpaces()
    • contains

      public boolean contains(org.apache.jena.graph.Node node)
    • contains

      public boolean contains(org.apache.jena.sparql.expr.NodeValue nodeValue)
    • isDiscrete

      public boolean isDiscrete()
      True iff all ranges are singletons; i.e. if this object can be converted into a possible empty enumeration of nodes
    • streamDiscrete

      public Stream<org.apache.jena.graph.Node> streamDiscrete()
    • isConstant

      public boolean isConstant()
      Returns true if there is exactly one value space with exactly one singleton
    • getConstant

      public org.apache.jena.graph.Node getConstant()
      Always first check isConstant() before calling this method
    • subsumes

      public boolean subsumes(NodeRanges other)
      Return true if this node range subsumes the other one, i.e. this node range is less-or-equal restrictive than the other.
      Parameters:
      other -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • classifyValueSpace

      protected Object classifyValueSpace(com.google.common.collect.Range<ComparableNodeValue> range)
      Specified by:
      classifyValueSpace in class VSpaceBase<ComparableNodeValue,Object>
    • classifyValueSpaceCore

      public static org.apache.jena.sparql.expr.ValueSpace classifyValueSpaceCore(com.google.common.collect.Range<ComparableNodeValue> range)
      Return some object that acts as a key for a value space. Different value spaces are assumed to be disjoint.
    • nodeRangesForPrefix

      public static NodeRanges nodeRangesForPrefix(String prefix)
    • rangeForStringPrefix

      public static com.google.common.collect.Range<ComparableNodeValue> rangeForStringPrefix(String prefix)
      Result is a string range (not IRI)
    • incrementLastCharacter

      public static String incrementLastCharacter(String str)
      Increment the last character of a string. Useful for defining the upper bound of a range of strings with a certain prefix. TODO We should better represent string using bytes (or code points)
    • main

      public static void main(String[] args)