Package org.aksw.jenax.constraint.util
Class NodeRanges
java.lang.Object
org.aksw.jenax.constraint.util.VSpaceBase<ComparableNodeValue,Object>
org.aksw.jenax.constraint.util.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
-
Field Summary
Fields inherited from class org.aksw.jenax.constraint.util.VSpaceBase
isVscExhaustive, vscToRangeSets -
Constructor Summary
ConstructorsConstructorDescriptionNodeRanges(boolean isVscExhaustive) NodeRanges(boolean isVscExhaustive, Map<Object, com.google.common.collect.RangeSet<ComparableNodeValue>> vscToRangeSets) -
Method Summary
Modifier and TypeMethodDescriptionaddEmptyDimension(Object dimension) Add a new empty dimension.addOpenDimension(Object dimension) Add a new unconstrained dimension.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 valueprotected ObjectclassifyValueSpace(com.google.common.collect.Range<ComparableNodeValue> range) static org.apache.jena.sparql.expr.ValueSpaceclassifyValueSpaceCore(com.google.common.collect.Range<ComparableNodeValue> range) Return some object that acts as a key for a value space.clone()Create an independent copy of this objectbooleancontains(org.apache.jena.graph.Node node) booleancontains(org.apache.jena.sparql.expr.NodeValue nodeValue) static NodeRangesCreate a NodeRange that contains nothingstatic NodeRangesCreate a NodeRange that contains everythingorg.apache.jena.graph.NodeAlways first checkisConstant()before calling this methodcom.google.common.collect.RangeSet<ComparableNodeValue>Set<?>static StringIncrement the last character of a string.booleanReturns true if there is exactly one value space with exactly one singletonbooleanTrue iff all ranges are singletons; i.e.booleanstatic voidstatic NodeRangesnodeRangesForPrefix(String prefix) static com.google.common.collect.Range<ComparableNodeValue>rangeForStringPrefix(String prefix) Result is a string range (not IRI)stateValue(org.apache.jena.graph.Node value) Constrain the value space to only the given node - this is an intersection operationStream<org.apache.jena.graph.Node>booleansubstractValue(org.apache.jena.graph.Node value) Add the negation of a value; e.g.booleansubsumes(NodeRanges other) Return true if this node range subsumes the other one, i.e.toString()Methods inherited from class org.aksw.jenax.constraint.util.VSpaceBase
add, getDimension, getOrCreateDimension, isConflicting, isUnconstrained, removeDimension, setDimension, stateIntersection, stateUnion, substractMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.aksw.jenax.constraint.api.Contradictable
isConflicting
-
Constructor Details
-
NodeRanges
public NodeRanges(boolean isVscExhaustive) -
NodeRanges
public NodeRanges(boolean isVscExhaustive, Map<Object, com.google.common.collect.RangeSet<ComparableNodeValue>> vscToRangeSets)
-
-
Method Details
-
getIriRanges
-
clone
Create an independent copy of this object -
createOpen
Create a NodeRange that contains everything -
createClosed
Create a NodeRange that contains nothing -
addEmptyDimension
Description copied from class:VSpaceBaseAdd a new empty dimension. Do nothing if it already exists or if the dimensions are exhaustive- Overrides:
addEmptyDimensionin classVSpaceBase<ComparableNodeValue,Object>
-
addOpenDimension
Description copied from class:VSpaceBaseAdd a new unconstrained dimension. Do nothing if it already exists or dimensions are non-exhaustive- Overrides:
addOpenDimensionin classVSpaceBase<ComparableNodeValue,Object>
-
stateValue
Constrain the value space to only the given node - this is an intersection operation -
addValue
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
-
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
-
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 checkisConstant()before calling this method -
subsumes
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
-
classifyValueSpace
- Specified by:
classifyValueSpacein classVSpaceBase<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
-
rangeForStringPrefix
public static com.google.common.collect.Range<ComparableNodeValue> rangeForStringPrefix(String prefix) Result is a string range (not IRI) -
incrementLastCharacter
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
-