Package org.apache.avro.idl
Class IdlSchemaParser
java.lang.Object
org.apache.avro.idl.IdlSchemaParser
- All Implemented Interfaces:
FormattedSchemaParser
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionparse
(ParseContext parseContext, URI baseUri, CharSequence formattedSchema) Parse schema definitions from a text based source.
-
Constructor Details
-
IdlSchemaParser
public IdlSchemaParser()
-
-
Method Details
-
parse
public Schema parse(ParseContext parseContext, URI baseUri, CharSequence formattedSchema) throws IOException, SchemaParseException Description copied from interface:FormattedSchemaParser
Parse schema definitions from a text based source.
Notes for implementers:
- Schema definitions are expected not to be in the format the parser expects. So when the input clearly doesn't make sense (e.g., reading "/**" when expecting JSON), it is a good idea not to do anything (especially calling methods on the @code ParseContext}).
- The parameter
parseContext
is not thread-safe. - All named schema definitions that are parsed should be added to the
provided
ParseContext
. - Optionally, you may return a "main" schema. Some schema definitions have
one, for example the schema defined by the root of the JSON document in a
standard schema
definition. If unsure, return
null
. - If parsing fails, throw a
SchemaParseException
. This will let the parsing process recover and continue. - Throwing anything other than a
SchemaParseException
will abort the parsing process, so reserve that for rethrowing exceptions.
- Specified by:
parse
in interfaceFormattedSchemaParser
- Parameters:
parseContext
- the current parse context: all named schemata that are parsed should be added here, otherwise resolving schemata can fail; contains all previously known typesbaseUri
- the base location of the schema, ornull
if not knownformattedSchema
- the text of the schema definition(s) to parse- Returns:
- the main schema, if any
- Throws:
IOException
- when the schema cannot be readSchemaParseException
- when the schema cannot be parsed
-