com.hp.hpl.jena.graph.query
Class Mapping

java.lang.Object
  extended by com.hp.hpl.jena.graph.query.Mapping
All Implemented Interfaces:
VariableIndexes

public class Mapping
extends Object
implements VariableIndexes

this class is used to record the mapping from [variable] Node's to the indexes they are bound to in a Query. Nodes bound to negative values are predeclared; the negative value is converted on index allocation.


Constructor Summary
Mapping(Node[] preDeclare)
          Create a new mapping in which all variables are unbound and the variables of preDeclare will be allocated the first slots in the map in their natural order.
 
Method Summary
 boolean hasBound(Node v)
          Answer true iff we have already bound v (predeclaration doesn't count)
 int indexOf(Node v)
          get the index of a node in the mapping; undefined if the node is not mapped.
 int indexOf(String name)
          Answer the index of name, or throw an exception if that name is not bound in this mapping.
 int lookUp(Node v)
          get the index of a node in the mapping; return -1 if the node is not mapped.
 int newIndex(Node v)
          allocate an index to the node v.
 int size()
          Answer the number of names currently held in the map
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Mapping

public Mapping(Node[] preDeclare)
Create a new mapping in which all variables are unbound and the variables of preDeclare will be allocated the first slots in the map in their natural order. [This is so that the query domain elements that come out of the matching process will be positioned to be suitable as query answers.]

Method Detail

indexOf

public int indexOf(Node v)
get the index of a node in the mapping; undefined if the node is not mapped.

Parameters:
v - the node to look up
Returns:
the index of v in the mapping

indexOf

public int indexOf(String name)
Description copied from interface: VariableIndexes
Answer the index of name, or throw an exception if that name is not bound in this mapping.

Specified by:
indexOf in interface VariableIndexes

lookUp

public int lookUp(Node v)
get the index of a node in the mapping; return -1 if the node is not mapped.

Parameters:
v - the node to look up
Returns:
the index of v in the mapping

newIndex

public int newIndex(Node v)
allocate an index to the node v. v must not already be mapped.

Parameters:
v - the node to be given an index
Returns:
the value of the allocated index

size

public int size()
Answer the number of names currently held in the map

Returns:
the number of names in the map

hasBound

public boolean hasBound(Node v)
Answer true iff we have already bound v (predeclaration doesn't count)

Parameters:
v - the node to look up
Returns:
true iff this mapping has seen a binding occurance of v

toString

public String toString()
Overrides:
toString in class Object
Returns:
a string representing this mapping


Licenced under the Apache License, Version 2.0