Class SchemaUtils

java.lang.Object
org.apache.pulsar.client.impl.schema.SchemaUtils

public final class SchemaUtils extends Object
Utils for schemas.
  • Method Details

    • validateFieldSchema

      public static void validateFieldSchema(String name, SchemaType type, Object val)
    • toAvroObject

      public static Object toAvroObject(Object value)
    • getStringSchemaVersion

      public static String getStringSchemaVersion(byte[] schemaVersionBytes)
    • jsonifySchemaInfo

      public static String jsonifySchemaInfo(SchemaInfo schemaInfo)
      Jsonify the schema info.
      Parameters:
      schemaInfo - the schema info
      Returns:
      the jsonified schema info
    • jsonifySchemaInfoWithVersion

      public static String jsonifySchemaInfoWithVersion(SchemaInfoWithVersion schemaInfoWithVersion)
      Jsonify the schema info with version.
      Parameters:
      schemaInfoWithVersion - the schema info
      Returns:
      the jsonified schema info with version
    • toJsonElement

      public static com.google.gson.JsonElement toJsonElement(String str)
    • jsonifyKeyValueSchemaInfo

      public static String jsonifyKeyValueSchemaInfo(KeyValue<SchemaInfo,SchemaInfo> kvSchemaInfo)
      Jsonify the key/value schema info.
      Parameters:
      kvSchemaInfo - the key/value schema info
      Returns:
      the jsonified schema info
    • convertKeyValueSchemaInfoDataToString

      public static String convertKeyValueSchemaInfoDataToString(KeyValue<SchemaInfo,SchemaInfo> kvSchemaInfo) throws IOException
      Convert the key/value schema info data to string.
      Parameters:
      kvSchemaInfo - the key/value schema info
      Returns:
      the convert schema info data string
      Throws:
      IOException
    • convertKeyValueDataStringToSchemaInfoSchema

      public static byte[] convertKeyValueDataStringToSchemaInfoSchema(byte[] keyValueSchemaInfoDataJsonBytes)
      Convert the key/value schema info data json bytes to key/value schema info data bytes.
      Parameters:
      keyValueSchemaInfoDataJsonBytes - the key/value schema info data json bytes
      Returns:
      the key/value schema info data bytes
    • serializeSchemaProperties

      public static String serializeSchemaProperties(Map<String,String> properties)
      Serialize schema properties.
      Parameters:
      properties - schema properties
      Returns:
      the serialized schema properties
    • deserializeSchemaProperties

      public static Map<String,String> deserializeSchemaProperties(String serializedProperties)
      Deserialize schema properties from a serialized schema properties.
      Parameters:
      serializedProperties - serialized properties
      Returns:
      the deserialized properties