MethodParser Class
- java.
lang. Object - com.
microsoft. azure. sdk. iot. service. methods. serializers. MethodParser
- com.
public class MethodParser
Representation of a single Direct Method Access collection with a Json serializer and deserializer.
Constructor Summary
Constructor | Description |
---|---|
MethodParser() |
CONSTRUCTOR Create a MethodParser instance with provided values. |
MethodParser(Object payload) |
CONSTRUCTOR Create a MethodParser instance with provided values. |
MethodParser(String name, int responseTimeout, int connectTimeout, Object payload) |
CONSTRUCTOR Create a MethodParser instance with provided values. |
Method Summary
Modifier and Type | Method and Description |
---|---|
synchronized void |
fromJson(String json)
Set the Method collection with the provided information in the json. |
Object |
getPayload()
Return an Object with the payload. |
String |
toJson()
Create a String with a json content that represents all the information in the method collection. |
JsonElement |
toJsonElement()
Create a JsonElement with a content that represents all the information in the method collection. |
Constructor Details
MethodParser
public MethodParser()
CONSTRUCTOR Create a MethodParser instance with provided values.
MethodParser
public MethodParser(Object payload)
CONSTRUCTOR Create a MethodParser instance with provided values.
Parameters:
- Object that contains the payload defined by the user. It can benull
</code> . </p>
MethodParser
public MethodParser(String name, int responseTimeout, int connectTimeout, Object payload)
CONSTRUCTOR Create a MethodParser instance with provided values.
Parameters:
name
- - method name [required].
responseTimeout
- - maximum interval of time, in seconds, that the Direct Method will wait for answer. It can benull
</code> . </p>
connectTimeout
- - maximum interval of time, in seconds, that the Direct Method will wait for the connection. It can benull
</code> . </p>
payload
- - Object that contains the payload defined by the user. It can benull
</code> . </p>
Throws:
IllegalArgumentException
- This exception is thrown if the one of the provided information do not fits the requirements.
Method Details
fromJson
public synchronized void fromJson(String json)
Set the Method collection with the provided information in the json.
Parameters:
json
- - Json with the information to change the collection.If contains `methodName`, it is a full method including `methodName`, `responseTimeoutInSeconds`, `connectTimeoutInSeconds`, and `payload`.
- If contains `status`, it is a response with `status` and `payload`.
- Otherwise, it is only `payload`.
Throws:
IllegalArgumentException
- This exception is thrown if the one of the provided information do not fits the requirements.
getPayload
public Object getPayload()
Return an Object with the payload.
Returns:
An Object with the payload. It can benull
</code> . </p>
toJson
public String toJson()
Create a String with a json content that represents all the information in the method collection.
Returns:
String with the json content.
Throws:
IllegalArgumentException
- This exception is thrown if the one of the provided information do not fits the requirements.
toJsonElement
public JsonElement toJsonElement()
Create a JsonElement with a content that represents all the information in the method collection.
Returns:
JsonElement with the content.
Throws:
IllegalArgumentException
- This exception is thrown if the one of the provided information do not fits the requirements.
Applies to
Azure SDK for Java