KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > fulltext > expression > word


1 package com.daffodilwoods.daffodildb.server.sql99.fulltext.expression;
2
3 import com.daffodilwoods.database.resource.*;
4 import com.daffodilwoods.daffodildb.server.sql99.token.*;
5 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference;
6 import com.daffodilwoods.daffodildb.utils.field.FieldString;
7 import com.daffodilwoods.daffodildb.utils.BufferRange;
8 import com.daffodilwoods.daffodildb.utils.field.FieldStringLiteral;
9 import com.daffodilwoods.daffodildb.utils.field.FieldBase;
10 import com.daffodilwoods.daffodildb.server.sql99.common.Datatypes;
11 import com.daffodilwoods.daffodildb.server.sql99.fulltext.common.FullTextByteParser;
12 import java.util.ArrayList JavaDoc;
13 import com.daffodilwoods.daffodildb.server.sql99.fulltext.common.ByteToken;
14 import com.daffodilwoods.daffodildb.server.sql99.fulltext.dql.condition._FullTextPredicate;
15 import com.daffodilwoods.daffodildb.server.sql99.fulltext.dql.condition.WordRepresentation;
16 import com.daffodilwoods.daffodildb.server.sql99.fulltext.dql.condition.PhraseRepresentation;
17 import com.daffodilwoods.daffodildb.utils.FieldUtility;
18 import com.daffodilwoods.fulltext.common._FullTextDocumentParser;
19 import com.daffodilwoods.fulltext.common._Token;
20 import com.daffodilwoods.daffodildb.server.sql99.token.delimitedidentifier;
21
22 /**
23  * NOTE Phrase is also parsed in this class.
24  * This class represents single word of the search expression. It allows user to
25  * get a plan which is self executable. This plan helps in obtaining the desired
26  * documents in which this word is present.
27  * <p>Title: </p>
28  * <p>Description: </p>
29  * <p>Copyright: Copyright (c) 2003</p>
30  * <p>Company: </p>
31  * @author not attributable
32  * @version 1.0
33  */

34
35 public class word implements com.daffodilwoods.daffodildb.utils.parser.StatementExecuter,textliteral {
36
37   public delimitedidentifier _word0;
38   public _Token[] tokenList;
39   boolean flagForOneTimeSematicChecking = true;
40
41   public Object JavaDoc run(Object JavaDoc object) throws DException {
42     return null;
43   }
44
45   public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
46     delimitedidentifier Delimitedidentifier = (delimitedidentifier) _word0.clone();
47     word Word = new word();
48     Word._word0 = Delimitedidentifier;
49     return Word;
50   }
51   /**
52    * CheckSemantic check search pattern which is single word is valid or invalid.
53    * if search pattern conatin all delimiter or word which are present in
54    * stop word list then this search pattern is invalid else search pattern is valid
55    * @param parent
56    * @return _References[]
57    * @throws DException
58    */

59   public _Reference[] checkSemantic(com.daffodilwoods.daffodildb.server.serversystem._ServerSession parent) throws DException {
60     if(flagForOneTimeSematicChecking) {
61       _FullTextDocumentParser byteParser = new FullTextByteParser();
62       ArrayList JavaDoc listOfToken = new ArrayList JavaDoc(5);
63       FieldBase obj = FieldUtility.getField(Datatypes.VARCHAR, (String JavaDoc)_word0.run(parent)); //new FieldStringLiteral(_word0.toString(), Datatypes.VARCHAR);
64
com.daffodilwoods.fulltext.common._Tokenizer byteTokenizer = byteParser.getTokenizer(obj,0);
65       while (byteTokenizer.hasMoreToken()) {
66         _Token token = byteTokenizer.nextToken();
67         listOfToken.add(token);//.getTerm()
68
}
69       tokenList = (_Token[]) listOfToken.toArray(new ByteToken[listOfToken.size()]);
70       flagForOneTimeSematicChecking = false;
71       if (tokenList.length > 0)
72         return null;
73
74      throw new DException("DSE6002",null);
75     }
76     return null;
77   }
78   /**
79    * GetFullTextPredicate used to get the plan of search pattern.which is self executable.
80    * @return _FullTextPredicate (Either WordReprenstation or PhraseRepresentation)
81    * @throws DException
82    */

83   public _FullTextPredicate getFullTextPrdicate() throws DException{
84     if (tokenList.length == 1)
85           return new WordRepresentation((FieldBase) (tokenList[0].getTerm()));//new String((byte[]) ( (FieldBase) (tokenList[0].getTerm())).getObject())
86

87     else {
88       WordRepresentation wordList[] = new WordRepresentation[tokenList.length];
89       for (int i = 0; i < tokenList.length; i++) {
90         wordList[i] = new WordRepresentation((FieldBase) (tokenList[i].getTerm()) );//.getTerm()//new String((byte[])( (FieldBase) tokenList[i].getTerm()).getObject())
91
}
92       return new PhraseRepresentation(wordList);
93     }
94   }
95
96   public String JavaDoc toString(){
97     return _word0.toString();
98   }
99
100 }
101
Popular Tags