01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.solr.schema;
17:
18: import org.apache.lucene.search.SortField;
19: import org.apache.lucene.document.Fieldable;
20: import org.apache.solr.request.XMLWriter;
21: import org.apache.solr.request.TextResponseWriter;
22:
23: import java.util.Map;
24: import java.io.IOException;
25:
26: /** <code>TextField</code> is the basic type for configurable text analysis.
27: * Analyzers for field types using this implementation should be defined in the schema.
28: * @author yonik
29: * @version $Id: TextField.java 479793 2006-11-27 22:40:21Z klaas $
30: */
31: public class TextField extends CompressableField {
32: protected void init(IndexSchema schema, Map<String, String> args) {
33: properties |= TOKENIZED;
34: super .init(schema, args);
35: }
36:
37: public SortField getSortField(SchemaField field, boolean reverse) {
38: return new SortField(field.name, SortField.STRING, reverse);
39: }
40:
41: public void write(XMLWriter xmlWriter, String name, Fieldable f)
42: throws IOException {
43: xmlWriter.writeStr(name, f.stringValue());
44: }
45:
46: public void write(TextResponseWriter writer, String name,
47: Fieldable f) throws IOException {
48: writer.writeStr(name, f.stringValue(), true);
49: }
50: }
|