1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 package com.isenshi.util.extlib;
40
41 import java.util.Collection;
42
43 import org.apache.slide.content.NodeProperty.NamespaceCache;
44 import org.apache.slide.search.BadQueryException;
45 import org.apache.slide.search.PropertyProvider;
46 import org.apache.slide.search.basic.IBasicExpression;
47 import org.apache.slide.search.basic.IBasicExpressionFactory;
48 import org.apache.slide.search.basic.IBasicQuery;
49 import org.jdom.Element;
50
51 /***
52 * This factory creates executable BasicExpressions. An instance is created for
53 * each SEARCH request.
54 * */
55 public class BasicExpressionFactoryTxtContainsCJK implements IBasicExpressionFactory
56 {
57
58
59 private IBasicQuery query;
60 protected PropertyProvider propertyProvider;
61
62 private String rootPath;
63
64 /***
65 * Constructor
66 *
67 * @param rootPath path to the content files
68 *
69 */
70 public BasicExpressionFactoryTxtContainsCJK (String rootPath)
71 {
72 this.rootPath = rootPath;
73 }
74
75 /***
76 * called for merge expressions (or, and). Not defined here
77 *
78 * @param mergeOperator and, or
79 * @param namespace the namespace of this expression
80 * @param expressionsToMerge all expressions, that shall be merged
81 *
82 * @return an IBasicExpression
83 *
84 * @throws BadQueryException
85 *
86 */
87 public IBasicExpression createMergeExpression (String mergeOperator,
88 String namespace,
89 Collection expressionsToMerge)
90 throws BadQueryException
91 {
92 return null;
93 }
94
95 /***
96 * Called by the expression compiler for each leave expression.
97 *
98 * @param element an Element discribing the expression
99 *
100 * @return an IBasicExpression
101 *
102 * @throws BadQueryException
103 *
104 */
105 public IBasicExpression createExpression (Element element)
106 throws BadQueryException
107 {
108 BasicExpressionTxtContainsCJK result = null;
109
110 if (element == null)
111 {
112 throw new BadQueryException ("expected a where criteria");
113 }
114 else
115 {
116 String namespace = element.getNamespace().getURI();
117 if (namespace.equals (NamespaceCache.DEFAULT_URI))
118 result = createDAVExpression (element);
119
120
121
122
123 }
124 result.setFactory(this);
125 return result;
126 }
127
128
129 /***
130 * Called, when the expression is in the default (DAV:) namespace.
131 *
132 *
133 * @param e an Element
134 *
135 * @return a BasicExpressionTemplate
136 *
137 */
138 private BasicExpressionTxtContainsCJK createDAVExpression (Element e)
139 {
140 String name = e.getName();
141 BasicExpressionTxtContainsCJK result = null;
142
143 if (name.equals ("contains"))
144 {
145 String searchedText = e.getTextTrim();
146 result = new BasicExpressionTxtContainsCJK (searchedText, rootPath);
147 }
148
149 return result;
150 }
151
152 /***
153 * called by BasicExpressionCompiler after construction.
154 *
155 * @param query the associated BasicQuery
156 * @param propertyProvider the PropertyProvider for this expression.
157 *
158 * @throws BadQueryException
159 *
160 */
161 public void init(IBasicQuery query, PropertyProvider propertyProvider)
162 throws BadQueryException
163 {
164 this.query = (IBasicQuery) query;
165 this.propertyProvider = propertyProvider;
166 }
167
168 /***
169 * Method getPropertyProvider
170 *
171 * @return the PropertyProvider
172 *
173 */
174 public PropertyProvider getPropertyProvider()
175 {
176 return propertyProvider;
177 }
178
179 /***
180 * Method getQuery
181 *
182 * @return the IBasicQuery
183 *
184 */
185 public IBasicQuery getQuery()
186 {
187 return query;
188 }
189
190 }
191