Package org.eclipse.lsp4j.jsonrpc.json
Class MessageJsonHandler
- java.lang.Object
-
- org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler
-
public class MessageJsonHandler extends java.lang.ObjectA wrapper around Gson that includes configuration required for JSON-RPC messages.
-
-
Field Summary
Fields Modifier and Type Field Description static JsonRpcMethodCANCEL_METHOD
-
Constructor Summary
Constructors Constructor Description MessageJsonHandler(java.util.Map<java.lang.String,JsonRpcMethod> supportedMethods)MessageJsonHandler(java.util.Map<java.lang.String,JsonRpcMethod> supportedMethods, java.util.function.Consumer<com.google.gson.GsonBuilder> configureGson)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringformat(java.lang.Object object)Perform JSON serialization of the given object using the configuration of JSON-RPC messages enhanced with the pretty printing option.com.google.gson.GsonBuildergetDefaultGsonBuilder()Create aGsonBuilderwith default settings for parsing JSON-RPC messages.com.google.gson.GsongetGson()JsonRpcMethodgetJsonRpcMethod(java.lang.String name)Resolve an RPC method by name.MethodProvidergetMethodProvider()MessageparseMessage(java.io.Reader input)MessageparseMessage(java.lang.CharSequence input)java.lang.Stringserialize(Message message)voidserialize(Message message, java.io.Writer output)voidsetMethodProvider(MethodProvider methodProvider)static java.lang.StringtoString(java.lang.Object object)Perform JSON serialization of the given object using the default configuration of JSON-RPC messages enhanced with the pretty printing option.
-
-
-
Field Detail
-
CANCEL_METHOD
public static final JsonRpcMethod CANCEL_METHOD
-
-
Constructor Detail
-
MessageJsonHandler
public MessageJsonHandler(java.util.Map<java.lang.String,JsonRpcMethod> supportedMethods)
- Parameters:
supportedMethods- - a map used to resolve RPC methods ingetJsonRpcMethod(String)
-
MessageJsonHandler
public MessageJsonHandler(java.util.Map<java.lang.String,JsonRpcMethod> supportedMethods, java.util.function.Consumer<com.google.gson.GsonBuilder> configureGson)
- Parameters:
supportedMethods- - a map used to resolve RPC methods ingetJsonRpcMethod(String)configureGson- - a function that contributes to the GsonBuilder created bygetDefaultGsonBuilder()
-
-
Method Detail
-
getDefaultGsonBuilder
public com.google.gson.GsonBuilder getDefaultGsonBuilder()
Create aGsonBuilderwith default settings for parsing JSON-RPC messages.
-
getGson
public com.google.gson.Gson getGson()
-
getJsonRpcMethod
public JsonRpcMethod getJsonRpcMethod(java.lang.String name)
Resolve an RPC method by name.
-
getMethodProvider
public MethodProvider getMethodProvider()
-
setMethodProvider
public void setMethodProvider(MethodProvider methodProvider)
-
parseMessage
public Message parseMessage(java.lang.CharSequence input) throws com.google.gson.JsonParseException
- Throws:
com.google.gson.JsonParseException
-
parseMessage
public Message parseMessage(java.io.Reader input) throws com.google.gson.JsonParseException
- Throws:
com.google.gson.JsonParseException
-
serialize
public java.lang.String serialize(Message message)
-
serialize
public void serialize(Message message, java.io.Writer output) throws com.google.gson.JsonIOException
- Throws:
com.google.gson.JsonIOException
-
format
public java.lang.String format(java.lang.Object object)
Perform JSON serialization of the given object using the configuration of JSON-RPC messages enhanced with the pretty printing option.
-
toString
public static java.lang.String toString(java.lang.Object object)
Perform JSON serialization of the given object using the default configuration of JSON-RPC messages enhanced with the pretty printing option.
-
-