one.world.io
Class Query

java.lang.Object
  |
  +--one.world.core.Tuple
        |
        +--one.world.io.Query
All Implemented Interfaces:
Cloneable, Serializable

public class Query
extends Tuple

Implementation of a query. Queries are used to select specific tuples when performing input operations. Queries are either empty, unary, binary, or comparison queries. Empty queries are always true. Unary queries apply a unary operator on another query. Binary queries apply a binary operator on two other queries. Finally, comparison queries compare the field of a tuple to a value. The field of a tuple is specified as a string, giving the field's name. The tuple itself can be specified by using the empty string. Nested fields of nested tuples can be specified by using the corresponding chain of field names, where the individual field names are separated by dots ('.').

Whether a comparison query is valid for a given field, depends on the type of the field. For the tuple itself, only queries for its type, subtype, or declared type are valid. For arbitrary objects, only queries for the type, subtype, declared type, equality, or inequality are valid. For numeric types, either in their primitive or in their boxed form, all comparisons besides begins-with, contains, ends-with are valid. Finally, for strings and binary data, all comparisons are valid.

Version:
$Revision: 1.11 $
See Also:
Serialized Form

Field Summary
static int BINARY_AND
          The and binary operator.
static int BINARY_OR
          The or binary operator.
static int COMPARE_BEGINS_WITH
          The begins with comparison operator.
static int COMPARE_CONTAINS
          The contains comparison operator.
static int COMPARE_ENDS_WITH
          The ends with comparison operator.
static int COMPARE_EQUAL
          The equal comparison operator.
static int COMPARE_GREATER
          The greater than comparison operator.
static int COMPARE_GREATER_EQUAL
          The greater equal comparison operator.
static int COMPARE_HAS_DECLARED_TYPE
          The has declared type comparison operation.
static int COMPARE_HAS_FIELD
          The has field comparison operator.
static int COMPARE_HAS_SUBTYPE
          The has subtype comparison operator.
static int COMPARE_HAS_TYPE
          The has type comparison operator.
static int COMPARE_LESS
          The less than comparison operator.
static int COMPARE_LESS_EQUAL
          The less equal comparison operator.
static int COMPARE_NOT_EQUAL
          The not equal comparison operator.
 String field
          The field specifier for comparison queries.
 int op
          The operator for unary, binary, and comparison queries.
 Query query1
          The first query for unary and binary queries.
 Query query2
          The second query for binary queries.
 int type
          The type of this query.
static int TYPE_BINARY
          The binary type.
static int TYPE_COMPARE
          The comparison type.
static int TYPE_EMPTY
          The empty type.
static int TYPE_UNARY
          The unary type.
static int UNARY_NOT
          The not unary operator.
 Object value
          The value for comparison queries.
 
Fields inherited from class one.world.core.Tuple
CLOSURE, id, ID, META_DATA, metaData, SOURCE
 
Constructor Summary
Query()
          Create a new empty query.
Query(int op, Query query1)
          Create a new unary query.
Query(Query query1, int op, Query query2)
          Create a new binary query.
Query(String field, int op, Object value)
          Create a new comparison query.
 
Method Summary
 void validate()
          Validate this query.
 
Methods inherited from class one.world.core.Tuple
clone, containsNonSymbolicHandler, equals, fields, get, getMetaData, getType, hasField, hashCode, hasMetaData, remove, set, setMetaData, toString, wrap
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_EMPTY

public static final int TYPE_EMPTY
The empty type.

TYPE_UNARY

public static final int TYPE_UNARY
The unary type.

TYPE_BINARY

public static final int TYPE_BINARY
The binary type.

TYPE_COMPARE

public static final int TYPE_COMPARE
The comparison type.

UNARY_NOT

public static final int UNARY_NOT
The not unary operator.

BINARY_AND

public static final int BINARY_AND
The and binary operator.

BINARY_OR

public static final int BINARY_OR
The or binary operator.

COMPARE_EQUAL

public static final int COMPARE_EQUAL
The equal comparison operator.

COMPARE_NOT_EQUAL

public static final int COMPARE_NOT_EQUAL
The not equal comparison operator.

COMPARE_GREATER

public static final int COMPARE_GREATER
The greater than comparison operator.

COMPARE_GREATER_EQUAL

public static final int COMPARE_GREATER_EQUAL
The greater equal comparison operator.

COMPARE_LESS

public static final int COMPARE_LESS
The less than comparison operator.

COMPARE_LESS_EQUAL

public static final int COMPARE_LESS_EQUAL
The less equal comparison operator.

COMPARE_BEGINS_WITH

public static final int COMPARE_BEGINS_WITH
The begins with comparison operator.

COMPARE_CONTAINS

public static final int COMPARE_CONTAINS
The contains comparison operator.

COMPARE_ENDS_WITH

public static final int COMPARE_ENDS_WITH
The ends with comparison operator.

COMPARE_HAS_TYPE

public static final int COMPARE_HAS_TYPE
The has type comparison operator. Has type comparisons compare the actual value of a tuple or field with the specified type.

COMPARE_HAS_SUBTYPE

public static final int COMPARE_HAS_SUBTYPE
The has subtype comparison operator. Has subtype comparisons compare the actual value of a tuple or field with the specified type.

COMPARE_HAS_DECLARED_TYPE

public static final int COMPARE_HAS_DECLARED_TYPE
The has declared type comparison operation. Has declared type comparisons compare the declared type of a field with the specified type. The declared type of a tuple is the type of the tuple. The declared type of the dynamically typed fields of a dynamic tuple is java.lang.Object.

COMPARE_HAS_FIELD

public static final int COMPARE_HAS_FIELD
The has field comparison operator. Has field comparisons return true if the tuple has a field with the given fieldname. The value parameter is unused and should be set to null.

type

public int type
The type of this query.

op

public int op
The operator for unary, binary, and comparison queries.

query1

public Query query1
The first query for unary and binary queries.

query2

public Query query2
The second query for binary queries.

field

public String field
The field specifier for comparison queries.

value

public Object value
The value for comparison queries.
Constructor Detail

Query

public Query()
Create a new empty query.

Query

public Query(int op,
             Query query1)
Create a new unary query.
Parameters:
op - The unary operator.
query1 - The query to operate on.

Query

public Query(Query query1,
             int op,
             Query query2)
Create a new binary query.
Parameters:
query1 - The first query to operate on.
op - The binary operator.
query2 - The second query to operate on.

Query

public Query(String field,
             int op,
             Object value)
Create a new comparison query.
Parameters:
field - The field for the comparison.
op - The comparison operator.
value - The value for the comparison.
Method Detail

validate

public void validate()
              throws TupleException
Validate this query.
Overrides:
validate in class Tuple
Following copied from class: one.world.core.Tuple
Throws:
TupleException - Signals that the tuple is either malformed (i.e., does not conform to the tuple specification) or invalid (i.e., does not conform to the semantic constraints of its type).
See Also:
MalformedTupleException, InvalidTupleException, Type.validate(Class)


(C) Copyright 2001 UW CSE