net.ontopia.topicmaps.query.impl.basic
Class QueryMatches

java.lang.Object
  extended by net.ontopia.topicmaps.query.impl.basic.QueryMatches

public class QueryMatches
extends java.lang.Object

INTERNAL: Object used to hold query results during computation.


Field Summary
 int colcount
           
 java.lang.Object[] columnDefinitions
           
 java.lang.Object[][] data
           
static int initialSize
           
 int last
           
 int size
           
 
Constructor Summary
QueryMatches(java.util.Collection columnDefs, QueryContext context)
          INTERNAL: Creates a new matches object with the given column definitions.
QueryMatches(QueryMatches matches)
          INTERNAL: Creates a new (empty) matches object with the same column definitions as the QueryMatches object passed in the parameter.
 
Method Summary
 void add(java.lang.Object[][] newdata, int length)
          EXPERIMENTAL: Adds input array to this table.
 void add(QueryMatches extra)
          INTERNAL: Adds all the matches in the given table to this table.
 void add(QueryResultIF extra)
          EXPERIMENTAL: Adds QueryResultIF matches to this table.
protected  void addNonRedundant(QueryMatches matches)
          INTERNAL: Adds all rows which do not already exist.
 boolean bound(int colix)
          INTERNAL: Checks whether the variable represented by the indexed column is bound.
 void clear()
          INTERNAL: Empties the table.
 java.lang.String dump()
           
 void ensureCapacity(int requirement)
          INTERNAL: Ensures that the table has at least the given size.
 java.lang.Object getColumnDefinition(int ix)
          INTERNAL: Returns definition of column.
 int getIndex(java.lang.Float num)
          INTERNAL: Returns the index of the given float constant in the table.
 int getIndex(java.lang.Integer num)
          INTERNAL: Returns the index of the given integer constant in the table.
 int getIndex(java.lang.Object argument)
          INTERNAL: Returns the column index of the given object in the table.
 int getIndex(java.lang.String str)
          INTERNAL: Returns the index of the given string constant in the table.
 int getIndex(TMObjectIF constant)
          INTERNAL: Returns the index of the given constant in the table.
 int getIndex(Variable var)
          INTERNAL: Returns the index of the given variable in the table.
 QueryContext getQueryContext()
          INTERNAL: Returns the query context.
 int[][] getTranslationSpec(java.lang.Object[] intarguments, QueryMatches extmatches, java.lang.Object[] extarguments)
          INTERNAL: Computes the translation specification array, which gives the connection between this and the other match table.
 int getVariableIndex(java.lang.String varname)
          INTERNAL: Returns the index of the given variable in the table.
 boolean hasLiteralColumns()
          INTERNAL: Checks whether any of the columns are literal columns representing a literal in the query.
 void increaseCapacity()
          INTERNAL: Used to increase the size of the table when full.
 void insertConstants()
          INTERNAL: Inserts the constant values in the constant columns.
 boolean isEmpty()
          INTERNAL: Returns true if there are no matches.
 QueryMatches merge(int[] intspec, QueryMatches extmatches, int[] extspec, int[] equalpairs)
          INTERNAL: Merges this match table (from inside a rule) with another match table (from the calling context), producing a new set of matches (corresponding to the result of the rule, as viewed from the outside).
protected  void remove(QueryMatches matches)
          INTERNAL: Removes the rows which have matching counterparts in the argument.
 QueryMatches removeDuplicates()
           
 void translate(int[] fromCols, QueryMatches toQM, int[] toCols)
          INTERNAL: Translates matches in this table into corresponding matches in the other.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initialSize

public static int initialSize

last

public int last

size

public int size

data

public java.lang.Object[][] data

columnDefinitions

public java.lang.Object[] columnDefinitions

colcount

public int colcount
Constructor Detail

QueryMatches

public QueryMatches(java.util.Collection columnDefs,
                    QueryContext context)
INTERNAL: Creates a new matches object with the given column definitions.


QueryMatches

public QueryMatches(QueryMatches matches)
INTERNAL: Creates a new (empty) matches object with the same column definitions as the QueryMatches object passed in the parameter.

Method Detail

getVariableIndex

public int getVariableIndex(java.lang.String varname)
INTERNAL: Returns the index of the given variable in the table.


getIndex

public int getIndex(TMObjectIF constant)
INTERNAL: Returns the index of the given constant in the table.


getIndex

public int getIndex(Variable var)
INTERNAL: Returns the index of the given variable in the table.


getIndex

public int getIndex(java.lang.String str)
INTERNAL: Returns the index of the given string constant in the table.


getIndex

public int getIndex(java.lang.Integer num)
INTERNAL: Returns the index of the given integer constant in the table.


getIndex

public int getIndex(java.lang.Float num)
INTERNAL: Returns the index of the given float constant in the table.


getIndex

public int getIndex(java.lang.Object argument)
INTERNAL: Returns the column index of the given object in the table.


getColumnDefinition

public java.lang.Object getColumnDefinition(int ix)
INTERNAL: Returns definition of column.


increaseCapacity

public void increaseCapacity()
INTERNAL: Used to increase the size of the table when full.


ensureCapacity

public void ensureCapacity(int requirement)
INTERNAL: Ensures that the table has at least the given size.


clear

public void clear()
INTERNAL: Empties the table.


getQueryContext

public QueryContext getQueryContext()
INTERNAL: Returns the query context.


hasLiteralColumns

public boolean hasLiteralColumns()
INTERNAL: Checks whether any of the columns are literal columns representing a literal in the query.


isEmpty

public boolean isEmpty()
INTERNAL: Returns true if there are no matches.


insertConstants

public void insertConstants()
INTERNAL: Inserts the constant values in the constant columns. Uses the information in the column definitions to do this.


bound

public boolean bound(int colix)
INTERNAL: Checks whether the variable represented by the indexed column is bound.


add

public void add(QueryMatches extra)
INTERNAL: Adds all the matches in the given table to this table. Note that the two tables must have the same layout.


add

public void add(java.lang.Object[][] newdata,
                int length)
EXPERIMENTAL: Adds input array to this table.


add

public void add(QueryResultIF extra)
EXPERIMENTAL: Adds QueryResultIF matches to this table.


remove

protected void remove(QueryMatches matches)
INTERNAL: Removes the rows which have matching counterparts in the argument.


addNonRedundant

protected void addNonRedundant(QueryMatches matches)
INTERNAL: Adds all rows which do not already exist. Matching ignores nulls in the rows being added.


getTranslationSpec

public int[][] getTranslationSpec(java.lang.Object[] intarguments,
                                  QueryMatches extmatches,
                                  java.lang.Object[] extarguments)
                           throws InvalidQueryException
INTERNAL: Computes the translation specification array, which gives the connection between this and the other match table.

Parameters:
intarguments - Actual received parameters in rule invocation.
extarguments - Declared parameters in rule declaration.
Returns:
an array of type int[][] that looks like [intspec, extspec], where intspec is the specification for this match and extspec is the specification for the other match.
Throws:
InvalidQueryException

translate

public void translate(int[] fromCols,
                      QueryMatches toQM,
                      int[] toCols)
INTERNAL: Translates matches in this table into corresponding matches in the other.


merge

public QueryMatches merge(int[] intspec,
                          QueryMatches extmatches,
                          int[] extspec,
                          int[] equalpairs)
INTERNAL: Merges this match table (from inside a rule) with another match table (from the calling context), producing a new set of matches (corresponding to the result of the rule, as viewed from the outside).

Parameters:
intspec - Mapping from general column no (?) to column no in this QM object.
extspec - Mapping from general column no (?) to column no in extmatches.
equalpairs - See RulePredicate.getEqualPairs() for explanation. Numbers are argument numbers.

removeDuplicates

public QueryMatches removeDuplicates()

dump

public java.lang.String dump()


Copyright © 2000-2012 Ontopia.