KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > fulltext > dql > condition > ContainsPredicate


1 package com.daffodilwoods.daffodildb.server.sql99.fulltext.dql.condition;
2
3 import com.daffodilwoods.database.resource.DException;
4 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator;
5 import com.daffodilwoods.database.sqlinitiator._Order;
6 import com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexTable;
7 import com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation;
8 import com.daffodilwoods.daffodildb.server.sql99.utils.parser.ConditionParser;
9 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.booleanvalueexpression;
10 import com.daffodilwoods.daffodildb.server.sql99.utils.VariableValues;
11 import com.daffodilwoods.daffodildb.server.sql99.utils.ConditionVariableValue;
12 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.condition.IndexedFilterIterator;
13 import com.daffodilwoods.daffodildb.server.sql99.utils._VariableValues;
14 import com.daffodilwoods.daffodildb.server.sql99.fulltext.dql.iterator.ContainsIterator;
15 import com.daffodilwoods.daffodildb.server.sql99.common.GeneralPurposeStaticClass;
16
17 /**
18  * It represents top level plan for 'contains clause'. It is needed beacuse all
19  * other full text predicates provides the resultset which is needed for
20  * navigation, but they do not provide the functionality of retrieving the
21  * values of other columns except full text index enabled column.
22  * <p>Title: </p>
23  * <p>Description: </p>
24  * <p>Copyright: Copyright (c) 2003</p>
25  * <p>Company: </p>
26  * @author not attributable
27  * @version 1.0
28  */

29
30 public class ContainsPredicate implements _FullTextPredicate {
31   /**
32    * It represents underlying plan on which we put cover of Contains plan
33    */

34   _FullTextPredicate fullTextPredicate;
35   /**
36    * It represents columnName against which serach paatren is searched.
37    */

38   String JavaDoc columnName ;
39   private _Order order;
40
41   booleanvalueexpression condition;
42
43   public ContainsPredicate(_FullTextPredicate fullTextPredicate) throws DException {
44     this.fullTextPredicate = fullTextPredicate;
45     condition = ConditionParser.parseCondition("rowid = ?");
46   }
47   /**
48    * this method is used to get type of plan which is required by plan merger
49    * to merged two plan either with Logically AND and OR Operator.
50    * @return type of plan
51    * @throws DException
52    */

53   public int getType() throws DException {
54     return PredicateConstant.containsPredicate;
55   }
56   /**
57    * It is used to get columnName of searched column against which search
58    * pattern is searched.
59    * @param colName
60    * @throws DException
61    */

62   public String JavaDoc getColumn() throws DException {
63     return columnName = fullTextPredicate.getColumn();
64   }
65
66   /**
67    * It is used to set columnName of searched column against which search
68    * pattern is searched.
69    * @param colName
70    * @throws DException
71    */

72   public void setColumn(String JavaDoc column) throws DException {
73     fullTextPredicate.setColumn(column);
74   }
75   public double getCost() throws DException {
76     return 0.0;
77   }
78   public double getCost(Object JavaDoc session) throws DException {
79     return 0.0;
80   }
81   /**
82    * It is required for plan execution.It provides resultset,which contains two
83    * resultsets one for navigation and other for retrieval of values.
84    * @param session
85    * @return
86    * @throws DException
87    */

88   public _Iterator execute(Object JavaDoc session) throws DException {
89    _Iterator fullTextIterator = fullTextPredicate.execute(session);
90    _Iterator tableIterator = GeneralPurposeStaticClass.getIndexedFilteredIterator(((_IndexTable)session).getDefaultIterator(),condition);
91    return new ContainsIterator(fullTextIterator,tableIterator);
92
93     }
94
95   public double getEstimatedRow() throws DException {
96     return 1;
97   }
98   public void setOrder(_Order order) throws DException {
99    this.order = order;
100   }
101   public _Order getOrder() throws DException {
102     return order;
103   }
104
105   /**
106    * It is required for plan execution.It provides resultset,which contains two
107    * resultsets one for navigation and other for retrieval of values.
108    * @param session
109    * @return
110    * @throws DException
111    */

112   public _Iterator executeForSortedResult(Object JavaDoc indexTable) throws DException{
113     return execute(indexTable);
114   }
115
116
117 }
118
Popular Tags