Package com.linkedin.data.schema

Examples of com.linkedin.data.schema.JsonBuilder


    fileName += RestConstants.SNAPSHOT_FILENAME_EXTENTION;
    final File file = new File(outdirFile, fileName);

    FileOutputStream fileOutputStream = new FileOutputStream(file);

    JsonBuilder jsonBuilder = new JsonBuilder(JsonBuilder.Pretty.INDENTED);
    SchemaToJsonEncoder encoder = new SchemaToJsonEncoder(jsonBuilder);

    jsonBuilder.writeStartObject();
    jsonBuilder.writeFieldName(Snapshot.MODELS_KEY);
    jsonBuilder.writeStartArray();

    List<NamedDataSchema> models = generateModelList();

    for(DataSchema model : models){
      encoder.encode(model);
    }

    jsonBuilder.writeEndArray();

    jsonBuilder.writeFieldName(Snapshot.SCHEMA_KEY);
    jsonBuilder.writeStartObject();
    jsonBuilder.writeProperties(_topLevelSchema.data());
    jsonBuilder.writeEndObject();

    jsonBuilder.writeEndObject();

    try
    {
      fileOutputStream.write(jsonBuilder.result().getBytes());
    }
    finally
    {
      fileOutputStream.close();
      jsonBuilder.close();
    }
    return file;
  }
View Full Code Here


    if (schema instanceof PrimitiveDataSchema || schema instanceof NamedDataSchema)
    {
      return schema.getUnionMemberKey();
    }

    JsonBuilder builder = null;
    try
    {
      builder = new JsonBuilder(JsonBuilder.Pretty.SPACES);
      final SchemaToJsonEncoder encoder = new NamedSchemaReferencingJsonEncoder(builder);
      encoder.encode(schema);
      return builder.result();
    }
    catch (IOException e)
    {
      throw new RestLiInternalException("could not encode schema for '" + schema.toString() "'", e);
    }
    finally
    {
      if (builder != null)
      {
        builder.closeQuietly();
      }
    }
  }
View Full Code Here

    else
    {
      schemaToEncode = dataSchema;
    }

    JsonBuilder builder = null;
    try
    {
      builder = new JsonBuilder(JsonBuilder.Pretty.SPACES);
      final SchemaToJsonEncoder encoder = new NamedSchemaReferencingJsonEncoder(builder);
      encoder.encode(schemaToEncode);
      return builder.result();
    }
    catch (IOException e)
    {
      throw new RestLiInternalException("could not encode schema for '" + type.getName() + "'", e);
    }
    finally
    {
      if (builder != null)
      {
        builder.closeQuietly();
      }
    }
  }
View Full Code Here

   */
  static String schemaToAvro(DataSchema schema,
                             SchemaTranslator.FieldDefaultValueProvider fieldDefaultValueProvider,
                             DataToAvroSchemaTranslationOptions options)
  {
    JsonBuilder builder = null;
    try
    {
      builder = new JsonBuilder(options.getPretty());
      final SchemaToAvroJsonEncoder serializer = new SchemaToAvroJsonEncoder(builder, schema, fieldDefaultValueProvider, options);
      serializer.encode(schema);
      return builder.result();
    }
    catch (IOException exc)
    {
      throw new IllegalStateException(exc);
    }
    finally
    {
      if (builder != null)
      {
        builder.closeQuietly();
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.linkedin.data.schema.JsonBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.