public class QueryResult
extends java.lang.Object
Holds a data query and its result value. Allows conversion of the result to optional/required/list values for basic, complex and entity types.
Constructor and Description |
---|
QueryResult(DataQuery query,
DataValue result)
|
QueryResult(DataQuery query,
DataValue result,
int status)
|
QueryResult(DataQuery query,
DataValue result,
int status,
DataServiceException error)
Construct a new query result.
|
Modifier and Type | Method and Description |
---|---|
void |
check()
See check(int).
|
void |
check(int fixOptions)
Check if the
QueryResult.result is valid with respect to the QueryResult.query . |
DataValueList |
getBasicList()
Return the basic list for this result.
|
ComplexValueList |
getComplexList()
Return the complex list for this result.
|
long |
getCount()
Return the "count" for this result.
|
java.lang.String |
getDeltaLink()
Return (nullable) The "delta link" for this result.
|
DeltaStream |
getDeltaStream()
Return the delta stream for this result.
|
EntityValueList |
getEntityList()
Return the entity list for this result.
|
EntityStream |
getEntityStream()
Return the entity stream for this result.
|
DataServiceException |
getError()
Return (nullable) Error if
status does not represent a successful response. |
long |
getInlineCount()
Return the inline "total count" for this result.
|
java.lang.String |
getNextLink()
Return (nullable) The "next link" for this result.
|
DataQuery |
getNextQuery()
Return the "next query" for this result.
|
DataValue |
getOptionalBasic()
Return (nullable) The optional basic value of this result.
|
ComplexValue |
getOptionalComplex()
Return (nullable) The optional complex value of this result.
|
EntityValue |
getOptionalEntity()
Return (nullable) The optional entity value of this result.
|
DataQuery |
getQuery()
Return data query.
|
DataValue |
getRequiredBasic()
Return the required basic value of this result.
|
ComplexValue |
getRequiredComplex()
Return the required complex value of this result.
|
EntityValue |
getRequiredEntity()
Return the required entity value of this result.
|
DataValue |
getResult()
Return (nullable) Result value.
|
int |
getStatus()
Return result status (e.g.
|
public QueryResult(DataQuery query, DataValue result)
query
- Query parameter.result
- Result parameter.public QueryResult(DataQuery query, DataValue result, int status)
query
- Query parameter.result
- Result parameter.status
- Status parameter.public QueryResult(DataQuery query, DataValue result, int status, DataServiceException error)
Construct a new query result.
query
- Data query.result
- (nullable) Result value.status
- Result status (using HTTP status codes).error
- (nullable) Error, if the query failed, otherwise null
.public void check()
public void check(int fixOptions)
Check if the QueryResult.result
is valid with respect to the QueryResult.query
.
A result will be considered invalid if it is missing properties that were expected according to the use of DataQuery.select
or DataQuery.expand
in the QueryResult.query
.
QueryResultException
if the result is definitely not valid.
fixOptions
- Flags for fixing invalid OData payloadpublic DataValueList getBasicList()
Return the basic list for this result.
QueryResultException
if the result does not have the expected type.
public ComplexValueList getComplexList()
Return the complex list for this result.
QueryResultException
if the result does not have the expected type.
public long getCount()
Return the "count" for this result.
QueryResultException
if the result does not have the expected type.
public java.lang.String getDeltaLink()
Return (nullable) The "delta link" for this result.
QueryResultException
if the result does not have the expected type.
public DeltaStream getDeltaStream()
Return the delta stream for this result.
QueryResultException
if the result does not have the expected type.
public EntityValueList getEntityList()
Return the entity list for this result.
QueryResultException
if the result does not have the expected type.
public void entityListExample() { NorthwindService service = this.getService(); DataQuery query = new DataQuery() .select(Customer.customerID, Customer.companyName, Customer.contactName) .orderBy(Customer.companyName); Customer__List customers = service.getCustomers(query); for (Customer customer : customers) { this.showCustomer(customer); } }
public void entityListExample() { DataService service = this.getService(); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property customerIDProperty = customerEntityType.getProperty("CustomerID"); Property companyNameProperty = customerEntityType.getProperty("CompanyName"); Property contactNameProperty = customerEntityType.getProperty("ContactName"); DataQuery query = new DataQuery() .select(customerIDProperty, companyNameProperty, contactNameProperty) .from(customersEntitySet).orderBy(companyNameProperty); EntityValueList customers = service.executeQuery(query).getEntityList(); for (EntityValue customer : customers) { this.showCustomer(customer); } }
public EntityStream getEntityStream()
Return the entity stream for this result.
QueryResultException
if the result does not have the expected type.
public DataServiceException getError()
Return (nullable) Error if status
does not represent a successful response.
status
does not represent a successful response.public long getInlineCount()
Return the inline "total count" for this result.
QueryResultException
if the result does not have an inline "total count".
public java.lang.String getNextLink()
Return (nullable) The "next link" for this result.
QueryResultException
if the result does not have the expected type.
public DataQuery getNextQuery()
Return the "next query" for this result. The query will have a non-null
URL if this result includes a nextLink.
QueryResultException
if the result does not have the expected type.
public DataValue getOptionalBasic()
Return (nullable) The optional basic value of this result.
QueryResultException
if the result does not have the expected type.
public ComplexValue getOptionalComplex()
Return (nullable) The optional complex value of this result.
QueryResultException
if the result does not have the expected type.
public EntityValue getOptionalEntity()
Return (nullable) The optional entity value of this result.
QueryResultException
if the result does not have the expected type.
public void optionalEntityExample() { NorthwindService service = this.getService(); DataQuery query = new DataQuery() .select(Customer.customerID, Customer.companyName, Customer.contactName) .orderBy(Customer.companyName).top(1); Customer customer = example.internal.Single_optional_Customer.from(service.getCustomers(query)); if (customer != null) { this.showCustomer(customer); } }
public void optionalEntityExample() { DataService service = this.getService(); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property customerIDProperty = customerEntityType.getProperty("CustomerID"); Property companyNameProperty = customerEntityType.getProperty("CompanyName"); Property contactNameProperty = customerEntityType.getProperty("ContactName"); DataQuery query = new DataQuery() .select(customerIDProperty, companyNameProperty, contactNameProperty) .from(customersEntitySet).orderBy(companyNameProperty).top(1); EntityValue customer = service.executeQuery(query).getOptionalEntity(); if (customer != null) { this.showCustomer(customer); } }
public DataQuery getQuery()
Return data query.
public DataValue getRequiredBasic()
Return the required basic value of this result.
QueryResultException
if the result does not have the expected type.
public ComplexValue getRequiredComplex()
Return the required complex value of this result.
QueryResultException
if the result does not have the expected type.
public EntityValue getRequiredEntity()
Return the required entity value of this result.
QueryResultException
if the result does not have the expected type.
public void requiredEntityExample() { NorthwindService service = this.getService(); DataQuery query = new DataQuery() .select(Customer.customerID, Customer.companyName, Customer.contactName) .orderBy(Customer.companyName).top(1); Customer customer = service.getCustomer(query); this.showCustomer(customer); }
public void requiredEntityExample() { DataService service = this.getService(); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property customerIDProperty = customerEntityType.getProperty("CustomerID"); Property companyNameProperty = customerEntityType.getProperty("CompanyName"); Property contactNameProperty = customerEntityType.getProperty("ContactName"); DataQuery query = new DataQuery() .select(customerIDProperty, companyNameProperty, contactNameProperty) .from(customersEntitySet).orderBy(companyNameProperty).top(1); EntityValue customer = service.executeQuery(query).getRequiredEntity(); this.showCustomer(customer); }
public DataValue getResult()
Return (nullable) Result value.
public int getStatus()
Return result status (e.g. HTTP status code 200 = OK).