类 JsonProcessor


  • public abstract class JsonProcessor
    extends java.lang.Object
    Json processor, used to decode/encode json values, blocking and non-blocking.
    作者:
    Liu Dong
    • 方法概要

      所有方法 实例方法 抽象方法 具体方法 
      修饰符和类型 方法 说明
      <T> net.dongliu.xhttp.AsyncResponseHandler<T> asyncResponseHandler​(java.lang.Class<T> cls)
      Return a AsyncResponseHandler, which deserialize json from ByteBuffers async, with charset and type.
      protected <T> net.dongliu.xhttp.AsyncResponseHandler<T> asyncResponseHandler​(java.lang.reflect.Type type)
      Return a AsyncResponseHandler, which deserialize json from ByteBuffers async, with charset and type.
      <T> net.dongliu.xhttp.AsyncResponseHandler<T> asyncResponseHandler​(TypeToken<T> typeToken)
      Return a AsyncResponseHandler, which deserialize json from ByteBuffers async, with charset and type.
      <T> net.dongliu.xhttp.body.Body<T> jsonBody​(T value)
      Create a new json http body
      <T> net.dongliu.xhttp.body.Body<T> jsonBody​(T value, java.nio.charset.Charset charset)
      Create a new json http body
      protected abstract void marshal​(java.lang.Object value, java.io.OutputStream out, java.nio.charset.Charset charset)
      Serialize value to json, and write to writer.
      <T> net.dongliu.xhttp.ResponseHandler<T> responseHandler​(java.lang.Class<T> type)
      Return a ResponseHandler, which deserialize json with charset and type.
      <T> net.dongliu.xhttp.ResponseHandler<T> responseHandler​(TypeToken<T> type)
      Return a ResponseHandler, which deserialize json with charset and type.
      protected abstract <T> T unmarshal​(java.io.InputStream in, java.nio.charset.Charset charset, java.lang.reflect.Type type)
      Deserialize json from Reader, to specific type.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • JsonProcessor

        public JsonProcessor()
    • 方法详细资料

      • marshal

        protected abstract void marshal​(java.lang.Object value,
                                        java.io.OutputStream out,
                                        java.nio.charset.Charset charset)
                                 throws java.io.IOException
        Serialize value to json, and write to writer. The output stream is leaved unclosed.
        抛出:
        java.io.IOException
      • unmarshal

        protected abstract <T> T unmarshal​(java.io.InputStream in,
                                           java.nio.charset.Charset charset,
                                           java.lang.reflect.Type type)
                                    throws java.io.IOException
        Deserialize json from Reader, to specific type. The input stream is closed when finished or error occurred.
        参数:
        charset - the charset, cannot be null
        抛出:
        java.io.IOException
      • jsonBody

        public <T> net.dongliu.xhttp.body.Body<T> jsonBody​(T value)
        Create a new json http body
        类型参数:
        T - the value type
        参数:
        value - the value of body, to be marshall by this processor
        返回:
        json http body
      • jsonBody

        public <T> net.dongliu.xhttp.body.Body<T> jsonBody​(T value,
                                                           java.nio.charset.Charset charset)
        Create a new json http body
        类型参数:
        T - the value type
        参数:
        value - the value of body, to be marshall by this processor
        返回:
        json http body
      • responseHandler

        public <T> net.dongliu.xhttp.ResponseHandler<T> responseHandler​(java.lang.Class<T> type)
        Return a ResponseHandler, which deserialize json with charset and type.
      • responseHandler

        public <T> net.dongliu.xhttp.ResponseHandler<T> responseHandler​(TypeToken<T> type)
        Return a ResponseHandler, which deserialize json with charset and type.
      • asyncResponseHandler

        public <T> net.dongliu.xhttp.AsyncResponseHandler<T> asyncResponseHandler​(TypeToken<T> typeToken)
        Return a AsyncResponseHandler, which deserialize json from ByteBuffers async, with charset and type.
      • asyncResponseHandler

        public <T> net.dongliu.xhttp.AsyncResponseHandler<T> asyncResponseHandler​(java.lang.Class<T> cls)
        Return a AsyncResponseHandler, which deserialize json from ByteBuffers async, with charset and type.
      • asyncResponseHandler

        protected <T> net.dongliu.xhttp.AsyncResponseHandler<T> asyncResponseHandler​(java.lang.reflect.Type type)
        Return a AsyncResponseHandler, which deserialize json from ByteBuffers async, with charset and type. Default impl read all data of response body unblocking, and then unmarshal using blocking api. Override this method if implementation can decode json with non-blocking API.