Package com.solace.serdes.avro
Class AvroSchemaParser<U>
- java.lang.Object
-
- com.solace.serdes.avro.AvroSchemaParser<U>
-
- Type Parameters:
U- The type of the data container
- All Implemented Interfaces:
SchemaParser<org.apache.avro.Schema,U>
- Direct Known Subclasses:
DereferencedAvroSchemaParser
public class AvroSchemaParser<U> extends Object implements SchemaParser<org.apache.avro.Schema,U>
An implementation of SchemaParser specifically for Avro schemas. This parser handles the parsing, validation, and resolution of Avro schemas, including complex schemas with nested types and references to other schemas. It supports extracting schemas from Avro records and managing schema dependencies.
-
-
Constructor Summary
Constructors Constructor Description AvroSchemaParser()Constructs a new AvroSchemaParser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringartifactType()Retrieves the artifact type of the schema parser.ParsedSchema<org.apache.avro.Schema>getSchemaFromData(Record<U> data)Extracts the schema from a given data record.ParsedSchema<org.apache.avro.Schema>parse(byte[] rawSchemaBytes, Map<String,byte[]> references)Parses an Avro schema from a byte array, considering any referenced schemas.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.solace.serdes.common.resolver.SchemaParser
getSchemaFromLocation, supportsGetSchemaFromData, supportsGetSchemaFromLocation
-
-
-
-
Method Detail
-
parse
public ParsedSchema<org.apache.avro.Schema> parse(byte[] rawSchemaBytes, Map<String,byte[]> references)
Parses an Avro schema from a byte array, considering any referenced schemas.- Specified by:
parsein interfaceSchemaParser<org.apache.avro.Schema,U>- Parameters:
rawSchemaBytes- Raw schema content as byte array.references- A map of referenced schemas, where the key is the reference name and the value is the raw schema content as a byte array.- Returns:
- A parsed Avro schema
- Throws:
UncheckedIOException- if there's an issue parsing the schema
-
getSchemaFromData
public ParsedSchema<org.apache.avro.Schema> getSchemaFromData(Record<U> data)
Description copied from interface:SchemaParserExtracts the schema from a given data record. This method is particularly useful for artifact types like AVRO, where the schema can be extracted directly from the Java object.- Specified by:
getSchemaFromDatain interfaceSchemaParser<org.apache.avro.Schema,U>- Parameters:
data- The record from which to extract the schema.- Returns:
- A
ParsedSchemacontaining both the raw schema (as bytes) and the parsed schema.
-
artifactType
public String artifactType()
Description copied from interface:SchemaParserRetrieves the artifact type of the schema parser.- Specified by:
artifactTypein interfaceSchemaParser<org.apache.avro.Schema,U>- Returns:
- The artifact type of the schema parser.
-
-