public class DataContext
extends java.lang.Object
For internal use by formatting and parsing functions.
Modifier and Type | Field and Description |
---|---|
static int |
CHANGES_ONLY
When formatting a value, this flag is used to indicate that only changed properties should be included.
|
static int |
FULL_METADATA
When formatting a value, this flag is used to indicate that full metadata is required.
|
static int |
IEEE_754_COMPATIBLE
When formatting or parsing a value, this flag is used to indicate that decimal/long values will be formatted as JSON strings rather than JSON numbers.
|
static int |
IN_QUERY_STRING
When formatting a value, this flag is used to indicate formatting of the query string.
|
static int |
IN_REQUEST_PATH
When formatting a value, this flag is used to indicate formatting of the request path.
|
static int |
IS_DELTA_RESPONSE
When formatting a value, this flag is used to indicate formatting of a delta response.
|
static int |
IS_REQUEST_PAYLOAD
When formatting a value, specifies that the content is for request payload (as opposed to response payload).
|
static int |
ISO_8601_COMPATIBLE
When formatting or parsing a date/time value, this flag is used to indicate that values will be formatted in ISO 8601 compatible format.
|
static int |
KEY_AND_CHANGES
When formatting a value, this flag is used to indicate that key and changed properties should be included.
|
static int |
KEY_ONLY
When formatting a value, this flag is used to indicate that only key properties should be included.
|
static int |
RECEIVE_FROM_CLIENT
When parsing a value, this flag is used to indicate that the value is to be received from client by server.
|
static int |
REQUIRES_ID
When formatting a value, this flag is used to indicate that entity id is required.
|
static int |
REQUIRES_TYPE
When formatting a value, this flag is used to indicate that type metadata is required.
|
static int |
SAP_ENTITY_STATE_ANNOTATIONS
When formatting a value, this flag is used to indicate that "@sap.*" annotations are included to distinguish entity states.
|
static int |
SAP_OLD_ENTITY_VALUES
When formatting a value, this flag is used to indicate that old entity state should be included for modified entities.
|
static int |
SEND_TO_CLIENT
When formatting a value, this flag is used to indicate that the value is to be sent from server to client.
|
static int |
SUPPORTS_ALIAS
When formatting a value, this flag is used to indicate that a parameter alias may be used.
|
static int |
VALUE_TO_STRING
When formatting a value, this flag is used to indicate conversion to string format for display, not for OData interchange.
|
static int |
ZONELESS_DATE_TIME
When formatting or parsing a date/time value, this flag is used to indicate that values will be formatted in ISO 8601 compatible format without zone offset.
|
Constructor and Description |
---|
DataContext(CsdlDocument csdl)
Construct a new data context.
|
Modifier and Type | Method and Description |
---|---|
static ComplexType |
findActualComplex(ComplexType formalType,
java.lang.String typeName)
Return (nullable) The actual complex type, which may be a subtype of the formal complex type.
|
static EntityType |
findActualEntity(EntityType formalType,
java.lang.String typeName)
Return (nullable) The actual entity type, which may be a subtype of the formal entity type.
|
static DataContext |
forConversionToString()
Return a data context which can be used to convert structured (complex/entity) values to strings.
|
DataValueMap |
getAliasValues()
Return (nullable) Alias values needed for query formatting with special characters.
|
java.lang.String |
getAvoidInPaths()
Return (nullable) Characters that should be avoided in request paths.
|
int |
getBindOptions()
Return bind options: a bit mask of flags for binding, formatting and parsing.
|
ComplexType |
getComplexType(java.lang.String name)
Return the complex type with the specified name.
|
java.lang.String |
getContextURL()
Return (nullable) Context URL for response.
|
CsdlDocument |
getCsdlDocument()
Return CSDL document (OData service metadata).
|
DataMethod |
getDataMethod(java.lang.String name)
Return the data method with the specified name.
|
DataQuery |
getDataQuery()
Return (nullable) Data query for evaluation of select items, or
null if all properties should be selected. |
StructureType |
getDerivedType()
Return (nullable) Derived type for expected query results, or
null if no derived type is expected. |
EntitySet |
getEntitySet(java.lang.String name)
Return the entity set with the specified name.
|
EntityType |
getEntityType(java.lang.String name)
Return the entity type with the specified name.
|
boolean |
getFollowNext()
Return follow next links? (defaults to true)
|
DataMethod |
getOptionalDataMethod(java.lang.String name)
Return (nullable) The data method with the specified name, or
null if no such data method exists. |
EntitySet |
getOptionalEntitySet(java.lang.String name)
Return (nullable) The entity set with the specified name, or
null if no such entity set exists. |
java.lang.String |
getServiceRoot()
Return the service root URL for the OData service.
|
int |
getVersionCode()
Return data version.
|
boolean |
hasMetadata()
Return
true if this context has metadata. |
boolean |
hasStructureType(java.lang.String name)
Return
true if the metadata of this context has a structure (complex/entity) type with the specified name . |
boolean |
inferEntitySet(java.lang.String url)
If this context has no expected entity set, then infer it from the context URL (and push it).
|
DataContext |
inRequest()
Change the
DataContext.bindOptions for this context to include IS_REQUEST_PAYLOAD. |
DataContext |
inResponse()
Change the
DataContext.bindOptions for this context to exclude IS_REQUEST_PAYLOAD. |
java.lang.String |
makeRelative(java.lang.String url)
Return (nullable) The
url parameter, converted from an absolute URL to a relative URL (if possible), otherwise null . |
java.lang.String |
maybeRelative(java.lang.String url)
Return (nullable) The
url parameter, converted from an absolute URL to a relative URL (if possible), otherwise url . |
void |
popExpected()
Pop the top expected entity set from the context stack.
|
void |
prepareToFormat(DataValue value)
For internal use only.
|
void |
prepareToPatch(DataValue value,
DataValue old)
For internal use only.
|
void |
pushExpected(EntitySet entitySet)
|
void |
pushExpected(EntitySet entitySet,
StructureType derivedType)
Push an expected entity set onto the context stack.
|
DataType |
resolveAnyType(java.lang.String name)
Return (nullable) The data type with the specified name, or
null if no such type exists. |
void |
setAliasValues(DataValueMap value)
Set alias values needed for query formatting with special characters.
|
void |
setAvoidInPaths(java.lang.String value)
Set characters that should be avoided in request paths.
|
void |
setBindOptions(int value)
Set bind options: a bit mask of flags for binding, formatting and parsing.
|
void |
setContextURL(java.lang.String value)
Set context URL for response.
|
void |
setCsdlDocument(CsdlDocument value)
Set CSDL document (OData service metadata).
|
void |
setDataQuery(DataQuery value)
Set data query for evaluation of select items, or
null if all properties should be selected. |
void |
setDerivedType(StructureType value)
Set derived type for expected query results, or
null if no derived type is expected. |
void |
setFollowNext(boolean value)
Set follow next links? (defaults to true)
|
void |
setVersionCode(int value)
Set data version.
|
ExpectedItem |
topExpected()
Return the top expected item from the context stack, or an item with
EntitySet.undefined if the stack is empty. |
DataContext |
withExpected(EntitySet entitySet)
|
DataContext |
withExpected(EntitySet entitySet,
StructureType derivedType)
Push an expected entity set onto the context stack.
|
DataContext |
withOptions(int options)
Change the
DataContext.versionCode for this context. |
DataContext |
withVersion(int version)
Change the
DataContext.versionCode for this context. |
public static final int KEY_ONLY
When formatting a value, this flag is used to indicate that only key properties should be included.
public static final int CHANGES_ONLY
When formatting a value, this flag is used to indicate that only changed properties should be included.
public static final int KEY_AND_CHANGES
When formatting a value, this flag is used to indicate that key and changed properties should be included.
public static final int SEND_TO_CLIENT
When formatting a value, this flag is used to indicate that the value is to be sent from server to client.
public static final int VALUE_TO_STRING
When formatting a value, this flag is used to indicate conversion to string format for display, not for OData interchange.
public static final int FULL_METADATA
When formatting a value, this flag is used to indicate that full metadata is required.
public static final int REQUIRES_TYPE
When formatting a value, this flag is used to indicate that type metadata is required.
public static final int SUPPORTS_ALIAS
When formatting a value, this flag is used to indicate that a parameter alias may be used.
public static final int IN_REQUEST_PATH
When formatting a value, this flag is used to indicate formatting of the request path.
public static final int IN_QUERY_STRING
When formatting a value, this flag is used to indicate formatting of the query string.
public static final int IS_DELTA_RESPONSE
When formatting a value, this flag is used to indicate formatting of a delta response.
public static final int SAP_ENTITY_STATE_ANNOTATIONS
When formatting a value, this flag is used to indicate that "@sap.*" annotations are included to distinguish entity states.
public static final int SAP_OLD_ENTITY_VALUES
When formatting a value, this flag is used to indicate that old entity state should be included for modified entities.
public static final int REQUIRES_ID
When formatting a value, this flag is used to indicate that entity id is required.
public static final int IEEE_754_COMPATIBLE
When formatting or parsing a value, this flag is used to indicate that decimal/long values will be formatted as JSON strings rather than JSON numbers. This avoids overflow or loss of precision for clients that parse all JSON numbers as IEEE double precision values.
public static final int IS_REQUEST_PAYLOAD
When formatting a value, specifies that the content is for request payload (as opposed to response payload).
public static final int RECEIVE_FROM_CLIENT
When parsing a value, this flag is used to indicate that the value is to be received from client by server.
public static final int ISO_8601_COMPATIBLE
When formatting or parsing a date/time value, this flag is used to indicate that values will be formatted in ISO 8601 compatible format. This may override the usual encoding for the OData version (e.g. overriding OData 2.0 Verbose JSON 'tick' format).
public static final int ZONELESS_DATE_TIME
When formatting or parsing a date/time value, this flag is used to indicate that values will be formatted in ISO 8601 compatible format without zone offset. This may override the usual encoding for the OData version (applying even to DataType.GLOBAL_DATE_TIME).
public DataContext(CsdlDocument csdl)
Construct a new data context.
csdl
- CSDL document (OData service metadata).public static ComplexType findActualComplex(ComplexType formalType, java.lang.String typeName)
Return (nullable) The actual complex type, which may be a subtype of the formal complex type.
formalType
- Complex type expected by a caller.typeName
- Type name, which may be for a subtype of the formal type.public static EntityType findActualEntity(EntityType formalType, java.lang.String typeName)
Return (nullable) The actual entity type, which may be a subtype of the formal entity type.
formalType
- Entity type expected by a caller.typeName
- Type name, which may be for a subtype of the formal type.public static DataContext forConversionToString()
Return a data context which can be used to convert structured (complex/entity) values to strings.
public DataValueMap getAliasValues()
Return (nullable) Alias values needed for query formatting with special characters.
public java.lang.String getAvoidInPaths()
Return (nullable) Characters that should be avoided in request paths.
public int getBindOptions()
Return bind options: a bit mask of flags for binding, formatting and parsing.
public ComplexType getComplexType(java.lang.String name)
Return the complex type with the specified name.
UsageException
if no such complex type exists.
name
- Complex type name.public java.lang.String getContextURL()
Return (nullable) Context URL for response.
public final CsdlDocument getCsdlDocument()
Return CSDL document (OData service metadata).
public DataMethod getDataMethod(java.lang.String name)
Return the data method with the specified name.
UsageException
if no such data method exists.
name
- Data method name.public DataQuery getDataQuery()
Return (nullable) Data query for evaluation of select items, or null
if all properties should be selected.
null
if all properties should be selected.public StructureType getDerivedType()
Return (nullable) Derived type for expected query results, or null
if no derived type is expected.
null
if no derived type is expected.public EntitySet getEntitySet(java.lang.String name)
Return the entity set with the specified name.
UsageException
if no such entity set exists.
name
- Entity set name.public EntityType getEntityType(java.lang.String name)
Return the entity type with the specified name.
UsageException
if no such entity type exists.
name
- Entity type name.public boolean getFollowNext()
Return follow next links? (defaults to true)
public DataMethod getOptionalDataMethod(java.lang.String name)
Return (nullable) The data method with the specified name, or null
if no such data method exists.
name
- Data method name.null
if no such data method exists.public EntitySet getOptionalEntitySet(java.lang.String name)
Return (nullable) The entity set with the specified name, or null
if no such entity set exists.
name
- Entity set name.null
if no such entity set exists.public java.lang.String getServiceRoot()
Return the service root URL for the OData service.
public final int getVersionCode()
Return data version.
public boolean hasMetadata()
Return true
if this context has metadata.
true
if this context has metadata.public boolean hasStructureType(java.lang.String name)
Return true
if the metadata of this context has a structure (complex/entity) type with the specified name
.
name
- Type name.true
if the metadata of this context has a structure (complex/entity) type with the specified name
.public DataContext inRequest()
Change the DataContext.bindOptions
for this context to include IS_REQUEST_PAYLOAD.
public DataContext inResponse()
Change the DataContext.bindOptions
for this context to exclude IS_REQUEST_PAYLOAD.
public boolean inferEntitySet(java.lang.String url)
If this context has no expected entity set, then infer it from the context URL (and push it).
url
- (nullable) Optional context URL.public java.lang.String makeRelative(java.lang.String url)
Return (nullable) The url
parameter, converted from an absolute URL to a relative URL (if possible), otherwise null
.
url
- (nullable) URL, which may be absolute, relative, or null
.url
parameter, converted from an absolute URL to a relative URL (if possible), otherwise null
.public java.lang.String maybeRelative(java.lang.String url)
Return (nullable) The url
parameter, converted from an absolute URL to a relative URL (if possible), otherwise url
.
url
- (nullable) URL, which may be absolute, relative, or null
.url
parameter, converted from an absolute URL to a relative URL (if possible), otherwise url
.public void popExpected()
Pop the top expected entity set from the context stack.
public void prepareToFormat(DataValue value)
For internal use only.
value
- (internal use only)public void prepareToPatch(DataValue value, DataValue old)
For internal use only.
value
- (internal use only)old
- (internal use only)public void pushExpected(EntitySet entitySet)
entitySet
- EntitySet parameter.public void pushExpected(EntitySet entitySet, StructureType derivedType)
Push an expected entity set onto the context stack.
entitySet
- New top expected entity set.derivedType
- (nullable) Derived type for query results.public DataType resolveAnyType(java.lang.String name)
Return (nullable) The data type with the specified name, or null
if no such type exists.
name
- Data type qualified name.null
if no such type exists.public void setAliasValues(DataValueMap value)
Set alias values needed for query formatting with special characters.
value
- Alias values needed for query formatting with special characters.public void setAvoidInPaths(java.lang.String value)
Set characters that should be avoided in request paths.
value
- Characters that should be avoided in request paths.public void setBindOptions(int value)
Set bind options: a bit mask of flags for binding, formatting and parsing.
value
- Bind options: a bit mask of flags for binding, formatting and parsing.public void setContextURL(java.lang.String value)
Set context URL for response.
value
- Context URL for response.public final void setCsdlDocument(CsdlDocument value)
Set CSDL document (OData service metadata).
value
- CSDL document (OData service metadata).public void setDataQuery(DataQuery value)
Set data query for evaluation of select items, or null
if all properties should be selected.
value
- Data query for evaluation of select items, or null
if all properties should be selected.public void setDerivedType(StructureType value)
Set derived type for expected query results, or null
if no derived type is expected.
value
- Derived type for expected query results, or null
if no derived type is expected.public void setFollowNext(boolean value)
Set follow next links? (defaults to true)
value
- Follow next links? (defaults to true)public final void setVersionCode(int value)
Set data version.
value
- Data version.public ExpectedItem topExpected()
Return the top expected item from the context stack, or an item with EntitySet.undefined
if the stack is empty.
EntitySet.undefined
if the stack is empty.public DataContext withExpected(EntitySet entitySet)
entitySet
- EntitySet parameter.public DataContext withExpected(EntitySet entitySet, StructureType derivedType)
Push an expected entity set onto the context stack.
entitySet
- New top expected entity set.derivedType
- (nullable) Derived type for query results.public DataContext withOptions(int options)
Change the DataContext.versionCode
for this context.
options
- Bind options.public DataContext withVersion(int version)
Change the DataContext.versionCode
for this context.
version
- Data version.