TwinParser Class
- java.
lang. Object - com.
microsoft. azure. sdk. iot. deps. serializer. TwinParser
- com.
public class TwinParser
Note
This class has been deprecated. As of release 0.4.0, replaced by TwinState
TwinParser Representation including the twin collection and Json serializer and deserializer.
Field Summary
Modifier and Type | Field and Description |
---|---|
protected
Register |
manager |
protected
Twin |
properties |
protected
Twin |
tags |
Constructor Summary
Constructor | Description |
---|---|
TwinParser() |
CONSTRUCTOR Create a Twin |
TwinParser(TwinChangedCallback onDesiredCallback) |
CONSTRUCTOR Create a Twin |
TwinParser(TwinChangedCallback onDesiredCallback, TwinChangedCallback onReportedCallback) |
CONSTRUCTOR Create a Twin |
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
enableMetadata()
Enable metadata report in the Json. |
void |
enableTags()
Enable tags in the Twin collection and in the Json. |
Twin |
getConnectionState()
Getter for connection state |
java.lang.String |
getConnectionStateUpdatedTime()
Getter for connection state updated date and time |
java.util.Map<java.lang.String,java.lang.Object> |
getDesiredPropertyMap()
Return a map with all `desired` properties in the collection. |
java.lang.Integer |
getDesiredPropertyVersion()
Return the `desired` property version. |
java.lang.String |
getDeviceId()
Getter for device name |
java.lang.String |
getETag()
Getter for ETag |
java.lang.String |
getGenerationId()
Getter for device generation name |
java.lang.String |
getLastActivityTime()
Getter for last activity time |
java.util.Map<java.lang.String,java.lang.Object> |
getReportedPropertyMap()
Return a map with all `reported` properties in the collection. |
java.lang.Integer |
getReportedPropertyVersion()
Return the `reported` property version. |
Twin |
getStatus()
Getter for device status |
java.lang.String |
getStatusReason()
Getter for status reason |
java.lang.String |
getStatusUpdatedTime()
Getter for status updated date and time |
java.util.Map<java.lang.String,java.lang.Object> |
getTagsMap()
Return a map with all `tags` in the collection. |
java.lang.Integer |
getVersion()
Getter for Twin version |
java.lang.String |
resetDesiredProperty(Map<String,Object> propertyMap)
Reset the `desired` properties information in the collection, deleting all old properties and add all the new provided ones. |
java.lang.String |
resetReportedProperty(Map<String,Object> propertyMap)
Reset the `reported` properties information in the collection, deleting all old properties and add all the new provided ones. |
java.lang.String |
resetTags(Map<String,Object> tagsMap)
Reset the `tags` information in the collection, deleting all old tags and add all the new provided ones. |
void |
setDesiredCallback(TwinChangedCallback onDesiredCallback)
Set the callback function to report changes on the `Desired` collection when `Twin |
void |
setDeviceId(String deviceId)
Setter for device name |
void |
setETag(String eTag)
Setter for ETag. |
void |
setReportedCallback(TwinChangedCallback onReportedCallback)
Set the callback function to report changes on the `Reported` collection when `Twin |
void |
setTagsCallback(TwinChangedCallback onTagsCallback)
Set the callback function to report changes on the `tags` collection when `Twin |
java.lang.String |
toJson()
Create a String with a json content that represents all the information in the Twin |
com.google.gson.JsonElement |
toJsonElement()
Create a Json |
void |
updateDesiredProperty(String json)
Update the `desired` properties information in the collection, using the information parsed from the provided json. |
java.lang.String |
updateDesiredProperty(Map<String,Object> propertyMap)
Update the `desired` properties information in the collection, and return a string with a json that contains a sub-collection of added properties, or properties with new value. |
java.lang.String |
updateDeviceManager(String deviceId, TwinStatus status, String statusReason)
Update the device manager information in the collection, and return a string with a json that contains a the new device manager description, including new and old values. |
void |
updateReportedProperty(String json)
Update the `reported` properties information in the collection, using the information parsed from the provided json. |
java.lang.String |
updateReportedProperty(Map<String,Object> propertyMap)
Update the `reported` properties information in the collection, and return a string with a json that contains a sub-collection of added properties, or properties with new value. |
java.lang.String |
updateTags(Map<String,Object> tagsMap)
Update the `tags` information in the collection, and return a string with a json that contains a sub-collection of added tags, or tags with new value. |
void |
updateTwin(String json)
Update the properties information in the collection, using the information parsed from the provided json. |
java.lang.String |
updateTwin(Map<String,Object> desiredPropertyMap, Map<String,Object> reportedPropertyMap, Map<String,Object> tagsMap)
Update properties and tags information in the collection, and return a string with a json that contains a sub-collection of added properties, properties with new value, added tags, and tags with new values. |
Methods inherited from java.lang.Object
Field Details
manager
protected RegisterManagerParser manager
properties
protected TwinProperties properties
tags
protected TwinTags tags
Constructor Details
TwinParser
public TwinParser()
CONSTRUCTOR Create a TwinParser instance with default values. set OnDesiredCallback as null set OnReportedCallback as null set Tags as null
TwinParser
public TwinParser(TwinChangedCallback onDesiredCallback)
CONSTRUCTOR Create a TwinParser instance with default values. set OnReportedCallback as null set Tags as null
Parameters:
- Callback function to report changes on the
Desired
collection.
TwinParser
public TwinParser(TwinChangedCallback onDesiredCallback, TwinChangedCallback onReportedCallback)
CONSTRUCTOR Create a TwinParser instance with default values. set Tags as null
Parameters:
- Callback function to report changes on the
Desired
collection.
- Callback function to report changes on the
Reported
collection.
Method Details
enableMetadata
public void enableMetadata()
Enable metadata report in the Json.
enableTags
public void enableTags()
Enable tags in the Twin collection and in the Json.
getConnectionState
public TwinConnectionState getConnectionState()
Getter for connection state
Returns:
getConnectionStateUpdatedTime
public String getConnectionStateUpdatedTime()
Getter for connection state updated date and time
Returns:
getDesiredPropertyMap
public Map
Return a map with all `desired` properties in the collection.
Returns:
desired
properties in the collection (it can be null).getDesiredPropertyVersion
public Integer getDesiredPropertyVersion()
Return the `desired` property version.
Returns:
desired
property version (it can be null).getDeviceId
public String getDeviceId()
Getter for device name
Returns:
- {'-', ':', '.', '+', '%', '_', '#', '*', '?', '!', '(', ')', ',', '=', '@', ';', '$', '''}.
getETag
public String getETag()
Getter for ETag
Returns:
getGenerationId
public String getGenerationId()
Getter for device generation name
Returns:
getLastActivityTime
public String getLastActivityTime()
Getter for last activity time
Returns:
getReportedPropertyMap
public Map
Return a map with all `reported` properties in the collection.
Returns:
reported
properties in the collection (it can be null).getReportedPropertyVersion
public Integer getReportedPropertyVersion()
Return the `reported` property version.
Returns:
reported
property version (it can be null).getStatus
public TwinStatus getStatus()
Getter for device status
Returns:
getStatusReason
public String getStatusReason()
Getter for status reason
Returns:
getStatusUpdatedTime
public String getStatusUpdatedTime()
Getter for status updated date and time
Returns:
getTagsMap
public Map
Return a map with all `tags` in the collection.
Returns:
tags
in the collection (it can be null).Throws:
getVersion
public Integer getVersion()
Getter for Twin version
Returns:
null
resetDesiredProperty
public String resetDesiredProperty(Map
Reset the `desired` properties information in the collection, deleting all old properties and add all the new provided ones. Return a string with a json that contains a sub-collection of added properties.
Parameters:
- Map of
desired
property to change the collection.
Returns:
Throws:
resetReportedProperty
public String resetReportedProperty(Map
Reset the `reported` properties information in the collection, deleting all old properties and add all the new provided ones. Return a string with a json that contains a sub-collection of added properties.
Parameters:
- Map of
reported
property to change the collection.
Returns:
Throws:
resetTags
public String resetTags(Map
Reset the `tags` information in the collection, deleting all old tags and add all the new provided ones. Return a string with a json that contains a sub-collection of added tags.
Parameters:
- Map of
tags
to change the collection.
Returns:
Throws:
setDesiredCallback
public void setDesiredCallback(TwinChangedCallback onDesiredCallback)
Set the callback function to report changes on the `Desired` collection when `TwinParser` receives a new json.
Parameters:
- Callback function to report changes on the
Desired
collection.
setDeviceId
public void setDeviceId(String deviceId)
Setter for device name
Parameters:
- {'-', ':', '.', '+', '%', '_', '#', '*', '?', '!', '(', ')', ',', '=', '@', ';', '$', '''}
Throws:
setETag
public void setETag(String eTag)
Setter for ETag.
Parameters:
Throws:
setReportedCallback
public void setReportedCallback(TwinChangedCallback onReportedCallback)
Set the callback function to report changes on the `Reported` collection when `TwinParser` receives a new json.
Parameters:
- Callback function to report changes on the
Reported
collection.
setTagsCallback
public void setTagsCallback(TwinChangedCallback onTagsCallback)
Set the callback function to report changes on the `tags` collection when `TwinParser` receives a new json.
Parameters:
- Callback function to report changes on the
Reported
collection.
toJson
public String toJson()
Create a String with a json content that represents all the information in the TwinParser class and innerClasses.
Returns:
toJsonElement
public JsonElement toJsonElement()
Create a JsonElement that represents all the information in the TwinParser class and innerClasses.
Returns:
updateDesiredProperty
public void updateDesiredProperty(String json)
Update the `desired` properties information in the collection, using the information parsed from the provided json. It will fire a callback if any property was added, excluded, or had its value updated.
Parameters:
- Json with
desired
property to change the collection.
Throws:
updateDesiredProperty
public String updateDesiredProperty(Map
Update the `desired` properties information in the collection, and return a string with a json that contains a sub-collection of added properties, or properties with new value.
Parameters:
- Map of
desired
property to change the collection.
Returns:
Throws:
updateDeviceManager
public String updateDeviceManager(String deviceId, TwinStatus status, String statusReason)
Update the device manager information in the collection, and return a string with a json that contains a the new device manager description, including new and old values.
Parameters:
- Device name
- Device status("enabled", "disabled")
- A 128 char long string storing the reason of suspension (for status="disabled").
Returns:
Throws:
updateReportedProperty
public void updateReportedProperty(String json)
Update the `reported` properties information in the collection, using the information parsed from the provided json. It will fire a callback if any property was added, excluded, or had its value updated.
Parameters:
- Json with
reported
property to change the collection.
Throws:
updateReportedProperty
public String updateReportedProperty(Map
Update the `reported` properties information in the collection, and return a string with a json that contains a sub-collection of added properties, or properties with new value.
Parameters:
- Map of
reported
property to change the collection.
Returns:
Throws:
updateTags
public String updateTags(Map
Update the `tags` information in the collection, and return a string with a json that contains a sub-collection of added tags, or tags with new value.
Parameters:
- Map of
tags
to change the collection.
Returns:
Throws:
updateTwin
public void updateTwin(String json)
Update the properties information in the collection, using the information parsed from the provided json. It will fire a callback if any property was added, excluded, or had its value updated.
Parameters:
- Json with property to change the collection.
Throws:
updateTwin
public String updateTwin(Map
Update properties and tags information in the collection, and return a string with a json that contains a sub-collection of added properties, properties with new value, added tags, and tags with new values.
Parameters:
- Map of
desired
property to change the collection.
- Map of
reported
property to change the collection.
- Map of
tags
to change the collection.
Returns:
Throws:
Applies to
Azure SDK for Java
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for