Class SchemaUtils


  • public final class SchemaUtils
    extends java.lang.Object
    Utils for schemas.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] convertKeyValueDataStringToSchemaInfoSchema​(byte[] keyValueSchemaInfoDataJsonBytes)
      convert the key/value schema info data json bytes to key/value schema info data bytes
      static java.lang.String convertKeyValueSchemaInfoDataToString​(org.apache.pulsar.common.schema.KeyValue<org.apache.pulsar.common.schema.SchemaInfo,​org.apache.pulsar.common.schema.SchemaInfo> kvSchemaInfo)
      convert the key/value schema info data to string
      static java.util.Map<java.lang.String,​java.lang.String> deserializeSchemaProperties​(java.lang.String serializedProperties)
      Deserialize schema properties from a serialized schema properties.
      static java.lang.String getStringSchemaVersion​(byte[] schemaVersionBytes)  
      static java.lang.String jsonifyKeyValueSchemaInfo​(org.apache.pulsar.common.schema.KeyValue<org.apache.pulsar.common.schema.SchemaInfo,​org.apache.pulsar.common.schema.SchemaInfo> kvSchemaInfo)
      Jsonify the key/value schema info.
      static java.lang.String jsonifySchemaInfo​(org.apache.pulsar.common.schema.SchemaInfo schemaInfo)
      Jsonify the schema info.
      static java.lang.String jsonifySchemaInfoWithVersion​(org.apache.pulsar.common.schema.SchemaInfoWithVersion schemaInfoWithVersion)
      Jsonify the schema info with verison.
      static java.lang.String serializeSchemaProperties​(java.util.Map<java.lang.String,​java.lang.String> properties)
      Serialize schema properties
      static java.lang.Object toAvroObject​(java.lang.Object value)  
      static com.google.gson.JsonObject toJsonObject​(java.lang.String json)  
      static void validateFieldSchema​(java.lang.String name, org.apache.pulsar.common.schema.SchemaType type, java.lang.Object val)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • validateFieldSchema

        public static void validateFieldSchema​(java.lang.String name,
                                               org.apache.pulsar.common.schema.SchemaType type,
                                               java.lang.Object val)
      • toAvroObject

        public static java.lang.Object toAvroObject​(java.lang.Object value)
      • getStringSchemaVersion

        public static java.lang.String getStringSchemaVersion​(byte[] schemaVersionBytes)
      • jsonifySchemaInfo

        public static java.lang.String jsonifySchemaInfo​(org.apache.pulsar.common.schema.SchemaInfo schemaInfo)
        Jsonify the schema info.
        Parameters:
        schemaInfo - the schema info
        Returns:
        the jsonified schema info
      • jsonifySchemaInfoWithVersion

        public static java.lang.String jsonifySchemaInfoWithVersion​(org.apache.pulsar.common.schema.SchemaInfoWithVersion schemaInfoWithVersion)
        Jsonify the schema info with verison.
        Parameters:
        schemaInfoWithVersion - the schema info
        Returns:
        the jsonified schema info with version
      • toJsonObject

        public static com.google.gson.JsonObject toJsonObject​(java.lang.String json)
      • jsonifyKeyValueSchemaInfo

        public static java.lang.String jsonifyKeyValueSchemaInfo​(org.apache.pulsar.common.schema.KeyValue<org.apache.pulsar.common.schema.SchemaInfo,​org.apache.pulsar.common.schema.SchemaInfo> kvSchemaInfo)
        Jsonify the key/value schema info.
        Parameters:
        kvSchemaInfo - the key/value schema info
        Returns:
        the jsonified schema info
      • convertKeyValueSchemaInfoDataToString

        public static java.lang.String convertKeyValueSchemaInfoDataToString​(org.apache.pulsar.common.schema.KeyValue<org.apache.pulsar.common.schema.SchemaInfo,​org.apache.pulsar.common.schema.SchemaInfo> kvSchemaInfo)
                                                                      throws java.io.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:
        java.io.IOException
      • convertKeyValueDataStringToSchemaInfoSchema

        public static byte[] convertKeyValueDataStringToSchemaInfoSchema​(byte[] keyValueSchemaInfoDataJsonBytes)
                                                                  throws java.io.IOException
        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
        Throws:
        java.io.IOException
      • serializeSchemaProperties

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

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