QueryResult Class
- java.
lang. Object - com.
microsoft. azure. sdk. iot. provisioning. service. configs. QueryResult
- com.
public class QueryResult
Representation of a single Device Provisioning Service query response with a JSON deserializer.
It is the result of any query for the provisioning service. This class will parse the result and return it in a best format possible. For the known formats in QueryResultType, you can just cast the items. In case of unknown type, the items will contain a list of Strings
and you shall parse it by your own.
The provisioning service query result is composed by 2 system properties and a body. This class exposes it with 3 getters, getType(), getContinuationToken(), and getItems().
The system properties are:
type:
Identify the type of the content in the body. You can use it to cast the objects in the items list. See QueryResultType for the possible types and classes to cast.
continuationToken:
Contains the token the uniquely identify the next page of information. The service will return the next page of this query when you send a new query with this token,
And the body is a JSON list of the specific type. For instance, if the system property type is IndividualEnrollment, the body will look like:
[
{
"registrationId":"validRegistrationId-1",
"deviceId":"ContosoDevice-1",
"attestation":{
"type":"tpm",
"tpm":{
"endorsementKey":"validEndorsementKey"
}
},
"iotHubHostName":"ContosoIoTHub.azure-devices.net",
"provisioningStatus":"enabled"
},
{
"registrationId":"validRegistrationId-2",
"deviceId":"ContosoDevice-2",
"attestation":{
"type":"tpm",
"tpm":{
"endorsementKey":"validEndorsementKey"
}
},
"iotHubHostName":"ContosoIoTHub.azure-devices.net",
"provisioningStatus":"enabled"
}
]
Constructor Summary
Modifier | Constructor | Description |
---|---|---|
protected | QueryResult() |
Empty constructor |
QueryResult(String type, String body, String continuationToken) |
CONSTRUCTOR |
Method Summary
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getContinuationToken()
Getter for the continuation |
java.lang.Object[] |
getItems()
Getter for the items. |
Query |
getType()
Getter for the type. |
java.lang.String |
toString()
Creates a pretty print JSON with the content of this class and subclasses. |
Methods inherited from java.lang.Object
Constructor Details
QueryResult
protected QueryResult()
Empty constructor
Used only by the tools that will deserialize this class.
QueryResult
public QueryResult(String type, String body, String continuationToken)
CONSTRUCTOR
This constructor creates an instance of the QueryResult.
Parameters:
String
with type of the content in the body. It cannot be null
String
with the body in a JSON list format. It cannot be null
, or empty, if the type is different than unknown
.
String
with the continuation token. It can be null
.
Method Details
getContinuationToken
public String getContinuationToken()
Getter for the continuationToken.
Returns:
String
with the unique token that identify the next page of this query.getItems
public Object[] getItems()
Getter for the items.
Returns:
Object[]
with the results of the query. You can cast it using the type.getType
public QueryResultType getType()
Getter for the type.
Returns:
QueryResultType
with the type of the items Objects.toString
public String toString()
Creates a pretty print JSON with the content of this class and subclasses.
The result of this function is not a valid JSON for the provisioning service, it is just to provide a way to print its content.
Overrides:
QueryResult.toString()Returns:
String
with the pretty print JSON.Applies to
Azure SDK for Java