~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to solr/core/src/java/org/apache/solr/response/QueryResponseWriter.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 
 * contributor license agreements.  See the NOTICE file distributed with
4
 
 * this work for additional information regarding copyright ownership.
5
 
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 
 * (the "License"); you may not use this file except in compliance with
7
 
 * the License.  You may obtain a copy of the License at
8
 
 *
9
 
 *     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
 
 */
17
 
 
18
 
package org.apache.solr.response;
19
 
 
20
 
import java.io.Writer;
21
 
import java.io.IOException;
22
 
 
23
 
import org.apache.solr.common.util.NamedList;
24
 
import org.apache.solr.request.SolrQueryRequest;
25
 
import org.apache.solr.util.plugin.NamedListInitializedPlugin;
26
 
 
27
 
/**
28
 
 * Implementations of <code>QueryResponseWriter</code> are used to format responses to query requests.
29
 
 *
30
 
 * Different <code>QueryResponseWriter</code>s are registered with the <code>SolrCore</code>.
31
 
 * One way to register a QueryResponseWriter with the core is through the <code>solrconfig.xml</code> file.
32
 
 * <p>
33
 
 * Example <code>solrconfig.xml</code> entry to register a <code>QueryResponseWriter</code> implementation to
34
 
 * handle all queries with a writer type of "simple":
35
 
 * <p>
36
 
 * <code>
37
 
 *    &lt;queryResponseWriter name="simple" class="foo.SimpleResponseWriter" /&gt;
38
 
 * </code>
39
 
 * <p>
40
 
 * A single instance of any registered QueryResponseWriter is created
41
 
 * via the default constructor and is reused for all relevant queries.
42
 
 *
43
 
 * @version $Id: QueryResponseWriter.java 1075192 2011-02-28 00:50:09Z uschindler $
44
 
 */
45
 
public interface QueryResponseWriter extends NamedListInitializedPlugin {
46
 
  public static String CONTENT_TYPE_XML_UTF8="application/xml; charset=UTF-8";
47
 
  public static String CONTENT_TYPE_TEXT_UTF8="text/plain; charset=UTF-8";
48
 
  public static String CONTENT_TYPE_TEXT_ASCII="text/plain; charset=US-ASCII";
49
 
 
50
 
  /**
51
 
   * Write a SolrQueryResponse, this method must be thread save.
52
 
   *
53
 
   * <p>
54
 
   * Information about the request (in particular: formating options) may be 
55
 
   * obtained from <code>req</code> but the dominant source of information 
56
 
   * should be <code>rsp</code>.
57
 
   * <p>
58
 
   * There are no mandatory actions that write must perform.
59
 
   * An empty write implementation would fulfill
60
 
   * all interface obligations.
61
 
   * </p> 
62
 
   */
63
 
  public void write(Writer writer, SolrQueryRequest request, SolrQueryResponse response) throws IOException;
64
 
 
65
 
  /** 
66
 
   * Return the applicable Content Type for a request, this method 
67
 
   * must be thread safe.
68
 
   *
69
 
   * <p>
70
 
   * QueryResponseWriter's must implement this method to return a valid 
71
 
   * HTTP Content-Type header for the request, that will logically 
72
 
   * correspond with the output produced by the write method.
73
 
   * </p>
74
 
   * @return a Content-Type string, which may not be null.
75
 
   */
76
 
  public String getContentType(SolrQueryRequest request, SolrQueryResponse response);
77
 
  
78
 
  /** <code>init</code> will be called just once, immediately after creation.
79
 
   * <p>The args are user-level initialization parameters that
80
 
   * may be specified when declaring a response writer in
81
 
   * solrconfig.xml
82
 
   */
83
 
  public void init(NamedList args);
84
 
}
85
 
 
86
 
 
87