org.openanzo.glitter.query
Class PatternSolutionImpl

java.lang.Object
  extended by org.openanzo.glitter.query.PatternSolutionImpl
All Implemented Interfaces:
java.lang.Comparable<PatternSolution>, PatternSolution

public class PatternSolutionImpl
extends java.lang.Object
implements PatternSolution

Implements a PatternSolution as a Map from Bindable objects to RDFTerms.

Author:
lee

Nested Class Summary
static class PatternSolutionImpl.SetSolutionComparator
          Used to provide a stable sort to two PatternSolutions.
 
Constructor Summary
PatternSolutionImpl()
          Constructs an empty solution (no bindings).
PatternSolutionImpl(Bindable k, RDFTerm v)
          Constructs a solution with a single binding.
PatternSolutionImpl(java.util.Map<Bindable,RDFTerm> m)
          Constructs a solution from a map of bindables and values.
PatternSolutionImpl(PatternSolution other)
          Clones an existing solution.
 
Method Summary
 int compareTo(PatternSolution o)
           
 PatternSolution conjoin(PatternSolution other)
          See: http://wiki.atg.ibm.com/index.php?title=SPARQL_algebra#Conjunction
static boolean containMatchingBindings(PatternSolution p1, PatternSolution p2)
           
 RDFTerm getBinding(Bindable variable)
          Returns the binding for the given variable or blank node.
 java.util.Map<Bindable,RDFTerm> getBindings()
           
 java.util.Collection<Bindable> getBoundDomain(boolean sort)
          Returns the domain of variables and blank nodes in this solution.
 Bindable[] getBoundDomainArray()
           
 java.util.Collection<Variable> getBoundVariables()
          As in PatternSolution.getBoundDomain(boolean) with a false argument, but only returns Variables, not BlankNodeManager.BlankNodes.
 void setBinding(Bindable k, RDFTerm v)
          Sets a Bindable+value pair in this solution
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PatternSolutionImpl

public PatternSolutionImpl()
Constructs an empty solution (no bindings).


PatternSolutionImpl

public PatternSolutionImpl(Bindable k,
                           RDFTerm v)
Constructs a solution with a single binding.

Parameters:
k - The variable or blank node being bound.
v - The bound value.

PatternSolutionImpl

public PatternSolutionImpl(java.util.Map<Bindable,RDFTerm> m)
Constructs a solution from a map of bindables and values.

Parameters:
m -

PatternSolutionImpl

public PatternSolutionImpl(PatternSolution other)
Clones an existing solution.

Parameters:
other - The existing solution.
Method Detail

getBindings

public java.util.Map<Bindable,RDFTerm> getBindings()
Specified by:
getBindings in interface PatternSolution
Returns:
All the bindings that comprise this solution.

toString

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

setBinding

public void setBinding(Bindable k,
                       RDFTerm v)
Description copied from interface: PatternSolution
Sets a Bindable+value pair in this solution

Specified by:
setBinding in interface PatternSolution
Parameters:
k - The key.
v - The value.

getBinding

public RDFTerm getBinding(Bindable variable)
Description copied from interface: PatternSolution
Returns the binding for the given variable or blank node.

Specified by:
getBinding in interface PatternSolution
Returns:
The value of this variable or blank node; null if the variable is not bound.

getBoundDomain

public java.util.Collection<Bindable> getBoundDomain(boolean sort)
Description copied from interface: PatternSolution
Returns the domain of variables and blank nodes in this solution.

Specified by:
getBoundDomain in interface PatternSolution
Parameters:
sort - If true, the Bindables will be sorted stably
Returns:
A (possibly-sorted) collection representing the bound variables and blank nodes in this solution

size

public int size()
Specified by:
size in interface PatternSolution
Returns:
The number of bindings in this solution.

getBoundDomainArray

public Bindable[] getBoundDomainArray()
Specified by:
getBoundDomainArray in interface PatternSolution
Returns:
the domain of variables and blank nodes in this solution as an array.

getBoundVariables

public java.util.Collection<Variable> getBoundVariables()
Description copied from interface: PatternSolution
As in PatternSolution.getBoundDomain(boolean) with a false argument, but only returns Variables, not BlankNodeManager.BlankNodes.

Specified by:
getBoundVariables in interface PatternSolution
Returns:
set of Variables

conjoin

public PatternSolution conjoin(PatternSolution other)
Description copied from interface: PatternSolution
See: http://wiki.atg.ibm.com/index.php?title=SPARQL_algebra#Conjunction

Specified by:
conjoin in interface PatternSolution
Parameters:
other - The second operand of the conjunction operation.
Returns:
The result of conjoining these two pattern solutions, or null if the two solutions are mutually exclusive.

compareTo

public int compareTo(PatternSolution o)
Specified by:
compareTo in interface java.lang.Comparable<PatternSolution>

containMatchingBindings

public static boolean containMatchingBindings(PatternSolution p1,
                                              PatternSolution p2)


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.