KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > search > impl > lucene > query > AbstractStructuredFieldPosition


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.search.impl.lucene.query;
18
19 public abstract class AbstractStructuredFieldPosition implements StructuredFieldPosition
20 {
21     private String JavaDoc termText;
22
23     private boolean isTerminal;
24
25     private boolean isAbsolute;
26
27     private CachingTermPositions tps;
28
29     public AbstractStructuredFieldPosition(String JavaDoc termText, boolean isTerminal, boolean isAbsolute)
30     {
31         super();
32         this.termText = termText;
33         this.isTerminal = isTerminal;
34         this.isAbsolute = isAbsolute;
35     }
36
37     public boolean isTerminal()
38     {
39         return isTerminal;
40     }
41
42     protected void setTerminal(boolean isTerminal)
43     {
44         this.isTerminal = isTerminal;
45     }
46
47     public boolean isAbsolute()
48     {
49         return isAbsolute;
50     }
51
52     public boolean isRelative()
53     {
54         return !isAbsolute;
55     }
56
57     public String JavaDoc getTermText()
58     {
59         return termText;
60     }
61
62     public int getPosition()
63     {
64         return -1;
65     }
66
67     public void setCachingTermPositions(CachingTermPositions tps)
68     {
69         this.tps = tps;
70     }
71
72     public CachingTermPositions getCachingTermPositions()
73     {
74         return this.tps;
75     }
76
77     
78     
79     public boolean allowsLinkingBySelf()
80     {
81        return false;
82     }
83
84     public boolean allowslinkingByParent()
85     {
86         return true;
87     }
88
89     public boolean linkParent()
90     {
91         return true;
92     }
93
94     public boolean linkSelf()
95     {
96        return false;
97     }
98
99     public String JavaDoc toString()
100     {
101         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(256);
102         buffer.append(getDescription());
103         buffer.append("<"+getTermText()+"> at "+getPosition());
104         buffer.append(" Terminal = "+isTerminal());
105         buffer.append(" Absolute = "+isAbsolute());
106         return buffer.toString();
107     }
108     
109     public abstract String JavaDoc getDescription();
110
111     public boolean isDescendant()
112     {
113         return false;
114     }
115     
116     public boolean matchesAll()
117     {
118         return getCachingTermPositions() == null;
119     }
120
121  
122
123     
124 }
125
Popular Tags