public class CsdlFormatter
extends java.lang.Object
Formatter for Open Data Protocol (OData) service metadata documents (CSDL).
A new formatter should be created for each CsdlFormatter.formatXML
or CsdlFormatter.formatJSON
call. A formatter should not be shared by multiple threads.
Constructor and Description |
---|
CsdlFormatter() |
Modifier and Type | Method and Description |
---|---|
JsonObject |
formatJSON(CsdlDocument metadata)
|
JsonObject |
formatJSON(CsdlDocument metadata,
int version)
Return OData CSDL JSON generated from
metadata . |
XmlDocument |
formatXML(CsdlDocument metadata)
|
XmlDocument |
formatXML(CsdlDocument metadata,
int version)
Return OData CSDL XML generated from
metadata . |
boolean |
getDefaultEntitySets()
Return set this to
true to generate a default entity set for each entity type that has no associated entity set. |
boolean |
getDefaultMethodImports()
Return set this to
true to generate a default ActionImport/FunctionImport for each data method that has no associated import. |
boolean |
getDefaultPathBindings()
Return set this to
true to generate a default path binding for each navigation property that has no associated path binding. |
boolean |
getReturnTypeElements()
Return set this to
true to generate ReturnType elements even for OData V2 (which normally uses XML attributes). |
boolean |
getReturnTypeFacets()
Return set this to
true to generate ReturnType facets even for OData V2/V3 (which normally disallow return facets). |
void |
setDefaultEntitySets(boolean value)
Set set this to
true to generate a default entity set for each entity type that has no associated entity set. |
void |
setDefaultMethodImports(boolean value)
Set set this to
true to generate a default ActionImport/FunctionImport for each data method that has no associated import. |
void |
setDefaultPathBindings(boolean value)
Set set this to
true to generate a default path binding for each navigation property that has no associated path binding. |
void |
setReturnTypeElements(boolean value)
Set set this to
true to generate ReturnType elements even for OData V2 (which normally uses XML attributes). |
void |
setReturnTypeFacets(boolean value)
Set set this to
true to generate ReturnType facets even for OData V2/V3 (which normally disallow return facets). |
public JsonObject formatJSON(CsdlDocument metadata)
metadata
- Metadata parameter.public JsonObject formatJSON(CsdlDocument metadata, int version)
Return OData CSDL JSON generated from metadata
.
metadata
- CSDL document.version
- CSDL version for generation. If zero, defaults to CsdlDocument.versionCode
.metadata
.public XmlDocument formatXML(CsdlDocument metadata)
metadata
- Metadata parameter.public XmlDocument formatXML(CsdlDocument metadata, int version)
Return OData CSDL XML generated from metadata
.
metadata
- CSDL document.version
- CSDL version for generation. If zero, defaults to CsdlDocument.versionCode
.metadata
.public boolean getDefaultEntitySets()
Return set this to true
to generate a default entity set for each entity type that has no associated entity set.
true
to generate a default entity set for each entity type that has no associated entity set.public boolean getDefaultMethodImports()
Return set this to true
to generate a default ActionImport/FunctionImport for each data method that has no associated import.
Not applicable to data methods with DataMethod.isBound
== true
.
true
to generate a default ActionImport/FunctionImport for each data method that has no associated import.public boolean getDefaultPathBindings()
Return set this to true
to generate a default path binding for each navigation property that has no associated path binding.
true
to generate a default path binding for each navigation property that has no associated path binding.public boolean getReturnTypeElements()
Return set this to true
to generate ReturnType
elements even for OData V2 (which normally uses XML attributes).
This results in non-standard CSDL (but may be useful for datatype coverage testing).
true
to generate ReturnType
elements even for OData V2 (which normally uses XML attributes).public boolean getReturnTypeFacets()
Return set this to true
to generate ReturnType
facets even for OData V2/V3 (which normally disallow return facets).
This results in non-standard CSDL (but may be useful for datatype coverage testing).
true
to generate ReturnType
facets even for OData V2/V3 (which normally disallow return facets).public void setDefaultEntitySets(boolean value)
Set set this to true
to generate a default entity set for each entity type that has no associated entity set.
value
- Set this to true
to generate a default entity set for each entity type that has no associated entity set.public void setDefaultMethodImports(boolean value)
Set set this to true
to generate a default ActionImport/FunctionImport for each data method that has no associated import.
Not applicable to data methods with DataMethod.isBound
== true
.
value
- Set this to true
to generate a default ActionImport/FunctionImport for each data method that has no associated import.public void setDefaultPathBindings(boolean value)
Set set this to true
to generate a default path binding for each navigation property that has no associated path binding.
value
- Set this to true
to generate a default path binding for each navigation property that has no associated path binding.public void setReturnTypeElements(boolean value)
Set set this to true
to generate ReturnType
elements even for OData V2 (which normally uses XML attributes).
This results in non-standard CSDL (but may be useful for datatype coverage testing).
value
- Set this to true
to generate ReturnType
elements even for OData V2 (which normally uses XML attributes).public void setReturnTypeFacets(boolean value)
Set set this to true
to generate ReturnType
facets even for OData V2/V3 (which normally disallow return facets).
This results in non-standard CSDL (but may be useful for datatype coverage testing).
value
- Set this to true
to generate ReturnType
facets even for OData V2/V3 (which normally disallow return facets).