public class CsdlParser
extends java.lang.Object
Parser for Open Data Protocol (OData) service metadata documents (CSDL).
A new parser should be created for each CsdlParser.parse
call. A parser should not be shared by multiple threads.
Constructor and Description |
---|
CsdlParser() |
Modifier and Type | Method and Description |
---|---|
CsdlFetcher |
getCsdlFetcher()
Return (nullable) A callback which will be used to resolve any CSDL Reference that is encountered during parsing, in order to fetch the referenced metadata.
|
int |
getCsdlOptions()
Return a bitmask of CSDL parser options.
|
boolean |
getExcludeServerOnly()
Return skip server-only elements in the csdl xml to be parsed and added to CsdlDocument.
|
XmlElementList |
getIncludeElements()
Return extra CSDL child elements for main schema (e.g.
|
XmlElementList |
getIncludeReferences()
Return supplementary edmx:Reference elements.
|
DataSchemaList |
getIncludeSchemas()
Return pre-parsed schemas.
|
boolean |
getLogErrors()
Return should parser errors be logged before they are thrown?
|
boolean |
getLogWarnings()
Return should parser warnings be logged?
|
java.lang.String |
getServiceName()
Return (nullable) Data service name.
|
boolean |
getTraceRequests()
Return should parsing requests be traced?
|
void |
includeNamespace(java.lang.String ns)
|
void |
includeNamespace(java.lang.String ns,
java.lang.String alias)
Add to
CsdlParser.includeReferences a supplementary CSDL edmx:Reference (with embedded edmx:Include). |
void |
includeReference(java.lang.String uri,
java.lang.String ns)
|
void |
includeReference(java.lang.String uri,
java.lang.String ns,
java.lang.String alias)
Add to
CsdlParser.includeReferences a supplementary CSDL edmx:Reference (with embedded edmx:Include). |
void |
includeSchema(DataSchema schema)
Include the definitions of a pre-parsed schema into the document to be parsed.
|
CsdlDocument |
parse(java.lang.String text,
java.lang.String url)
|
CsdlDocument |
parseInProxy(java.lang.String text,
java.lang.String url)
For internal use only.
|
void |
setCsdlFetcher(CsdlFetcher value)
Set a callback which will be used to resolve any CSDL Reference that is encountered during parsing, in order to fetch the referenced metadata.
|
void |
setCsdlOptions(int value)
Set a bitmask of CSDL parser options.
|
void |
setExcludeServerOnly(boolean value)
Set skip server-only elements in the csdl xml to be parsed and added to CsdlDocument.
|
void |
setIncludeElements(XmlElementList value)
Set extra CSDL child elements for main schema (e.g.
|
void |
setIncludeReferences(XmlElementList value)
Set supplementary edmx:Reference elements.
|
void |
setIncludeSchemas(DataSchemaList value)
Set pre-parsed schemas.
|
void |
setLogErrors(boolean value)
Set should parser errors be logged before they are thrown?
|
void |
setLogWarnings(boolean value)
Set should parser warnings be logged?
|
void |
setServiceName(java.lang.String value)
Set data service name.
|
void |
setTraceRequests(boolean value)
Set should parsing requests be traced?
|
public CsdlFetcher getCsdlFetcher()
Return (nullable) A callback which will be used to resolve any CSDL Reference that is encountered during parsing, in order to fetch the referenced metadata.
Must be set before CsdlParser.parse
is called, or else any CSDL Reference that is encountered during parsing will result in a CsdlException
being thrown.
public int getCsdlOptions()
Return a bitmask of CSDL parser options.
public boolean getExcludeServerOnly()
Return skip server-only elements in the csdl xml to be parsed and added to CsdlDocument.
An element is server-only if it contains the
public XmlElementList getIncludeElements()
Return extra CSDL child elements for main schema (e.g. external annotations).
public XmlElementList getIncludeReferences()
Return supplementary edmx:Reference elements. Defaults to an empty list.
public DataSchemaList getIncludeSchemas()
Return pre-parsed schemas. Defaults to an empty list.
public boolean getLogErrors()
Return should parser errors be logged before they are thrown?
public boolean getLogWarnings()
Return should parser warnings be logged?
public java.lang.String getServiceName()
Return (nullable) Data service name. If data metrics are required, this property should be set before CsdlParser.parse
is called,
so that all DataMethod
and EntitySet
in the parsed document will have appropriately named metrics.
CsdlParser.parse
is called,public boolean getTraceRequests()
Return should parsing requests be traced?
public void includeNamespace(java.lang.String ns)
ns
- Ns parameter.public void includeNamespace(java.lang.String ns, java.lang.String alias)
Add to CsdlParser.includeReferences
a supplementary CSDL edmx:Reference (with embedded edmx:Include).
Call this function before CsdlParser.parse
if the document to be parsed is missing expected edmx:Reference elements for well-known schemas.
This function generates an edmx:Reference with a fabricated "Uri" (with value "include/ns
.xml").
It can be used together with a CsdlParser.csdlFetcher
which resolves documents either by fabricated location (include/ns
.xml) or by namespace (ns
).
ns
- For the "Namespace" attribute of "edmx:Include".alias
- (nullable) For the "Alias" attribute of "edmx:Include".public void includeReference(java.lang.String uri, java.lang.String ns)
uri
- Uri parameter.ns
- Ns parameter.public void includeReference(java.lang.String uri, java.lang.String ns, java.lang.String alias)
Add to CsdlParser.includeReferences
a supplementary CSDL edmx:Reference (with embedded edmx:Include).
Call this function before CsdlParser.parse
if the document to be parsed is missing expected edmx:Reference elements for well-known schemas.
This function generates an edmx:Reference with a caller-specified "Uri".
It can be used together with a CsdlParser.csdlFetcher
which resolves documents either by caller-specified location (uri
) or by namespace (ns
).
uri
- For the "Uri" attribute of "edmx:Reference".ns
- For the "Namespace" attribute of "edmx:Include".alias
- (nullable) For the "Alias" attribute of "edmx:Include".public void includeSchema(DataSchema schema)
Include the definitions of a pre-parsed schema into the document to be parsed.
Call this function before CsdlParser.parse
if the document to be parsed has an edmx:Reference element for a well-known schema,
and the pre-parsed schema should be used rather than loading the referenced schema over the network.
schema
- Pre-parsed schema.public CsdlDocument parse(java.lang.String text, java.lang.String url)
Parse the text of an Open Data Protocol (OData) service metadata (CSDL) document. Supports OData versions 1.0 to 4.0.
text
- Text of the service metadata document.url
- URL of the service metadata document. Used for resolving relative URLs if any CSDL Reference is encountered during parsing. May also be included in exception messages.public CsdlDocument parseInProxy(java.lang.String text, java.lang.String url)
For internal use only.
text
- (internal use only)url
- (internal use only)public void setCsdlFetcher(CsdlFetcher value)
Set a callback which will be used to resolve any CSDL Reference that is encountered during parsing, in order to fetch the referenced metadata.
Must be set before CsdlParser.parse
is called, or else any CSDL Reference that is encountered during parsing will result in a CsdlException
being thrown.
value
- A callback which will be used to resolve any CSDL Reference that is encountered during parsing, in order to fetch the referenced metadata.public void setCsdlOptions(int value)
Set a bitmask of CSDL parser options.
value
- A bitmask of CSDL parser options.public void setExcludeServerOnly(boolean value)
Set skip server-only elements in the csdl xml to be parsed and added to CsdlDocument.
An element is server-only if it contains the
value
- Skip server-only elements in the csdl xml to be parsed and added to CsdlDocument.public void setIncludeElements(XmlElementList value)
Set extra CSDL child elements for main schema (e.g. external annotations).
value
- Extra CSDL child elements for main schema (e.g. external annotations).public void setIncludeReferences(XmlElementList value)
Set supplementary edmx:Reference elements. Defaults to an empty list.
value
- Supplementary edmx:Reference elements. Defaults to an empty list.public void setIncludeSchemas(DataSchemaList value)
Set pre-parsed schemas. Defaults to an empty list.
value
- Pre-parsed schemas. Defaults to an empty list.public void setLogErrors(boolean value)
Set should parser errors be logged before they are thrown?
value
- Should parser errors be logged before they are thrown?public void setLogWarnings(boolean value)
Set should parser warnings be logged?
value
- Should parser warnings be logged?public void setServiceName(java.lang.String value)
Set data service name. If data metrics are required, this property should be set before CsdlParser.parse
is called,
so that all DataMethod
and EntitySet
in the parsed document will have appropriately named metrics.
value
- Data service name. If data metrics are required, this property should be set before CsdlParser.parse
is called,public void setTraceRequests(boolean value)
Set should parsing requests be traced?
value
- Should parsing requests be traced?