org.apache.solr.response

## Class JSONResponseWriter

- java.lang.Object
- - org.apache.solr.response.JSONResponseWriter

- All Implemented Interfaces:
    QueryResponseWriter, NamedListInitializedPlugin
  Direct Known Subclasses:
    GeoJSONResponseWriter

      public class JSONResponseWriter
      extends Object
      implements QueryResponseWriter

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CONTENT_TYPE_JSON_UTF8`

    - ### Fields inherited from interface org.apache.solr.response.QueryResponseWriter

      `CONTENT_TYPE_TEXT_ASCII, CONTENT_TYPE_TEXT_UTF8, CONTENT_TYPE_XML_UTF8`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JSONResponseWriter()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getContentType(SolrQueryRequest request, SolrQueryResponse response)` Return the applicable Content Type for a request, this method must be thread safe.
    `void` | `init(NamedList namedList)` `init` will be called just once, immediately after creation.
    `void` | `write(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp)` Write a SolrQueryResponse, this method must be thread save.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### CONTENT_TYPE_JSON_UTF8

          public static String CONTENT_TYPE_JSON_UTF8

  - ### Constructor Detail

    - #### JSONResponseWriter

          public JSONResponseWriter()

  - ### Method Detail

    - #### init

          public void init(NamedList namedList)

      Description copied from interface: `QueryResponseWriter`
      `init` will be called just once, immediately after creation.

      The args are user-level initialization parameters that may be specified when declaring a response writer in solrconfig.xml

      Specified by:
        `init` in interface `QueryResponseWriter`
      Specified by:
        `init` in interface `NamedListInitializedPlugin`

    - #### write

          public void write(Writer writer,
                            SolrQueryRequest req,
                            SolrQueryResponse rsp)
                     throws IOException

      Description copied from interface: `QueryResponseWriter`
      Write a SolrQueryResponse, this method must be thread save.

      Information about the request (in particular: formatting options) may be obtained from `req` but the dominant source of information should be `rsp`.

      There are no mandatory actions that write must perform. An empty write implementation would fulfill all interface obligations.

      Specified by:
        `write` in interface `QueryResponseWriter`
      Throws:
        `IOException`

    - #### getContentType

          public String getContentType(SolrQueryRequest request,
                                       SolrQueryResponse response)

      Description copied from interface: `QueryResponseWriter`
      Return the applicable Content Type for a request, this method must be thread safe.

      QueryResponseWriter's must implement this method to return a valid HTTP Content-Type header for the request, that will logically correspond with the output produced by the write method.

      Specified by:
        `getContentType` in interface `QueryResponseWriter`
      Returns:
        a Content-Type string, which may not be null.

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.