Class JsonLdSerializer

java.lang.Object
cz.cvut.kbss.jsonld.serialization.JsonLdSerializer
All Implemented Interfaces:
Configured
Direct Known Subclasses:
CompactedJsonLdSerializer, ContextBuildingJsonLdSerializer

public abstract class JsonLdSerializer extends Object implements Configured
Base class for all JSON-LD serializers.

The serializers will mostly differ in the form of the generated JSON. E.g. the output can be expanded, using contexts etc.

  • Field Details

  • Constructor Details

  • Method Details

    • configuration

      public Configuration configuration()
      Description copied from interface: Configured
      Gets the configuration holder for this JSON-LD processor.
      Specified by:
      configuration in interface Configured
      Returns:
      Configuration
    • registerSerializer

      public <T> void registerSerializer(Class<T> type, ValueSerializer<T> serializer)
      Registers a custom serializer for the specified type.

      If a serializer already existed for the type, it is replaced by the new one.

      Type Parameters:
      T - Serialized type
      Parameters:
      type - Type to register the serializer for
      serializer - Serializer to register
    • serialize

      public void serialize(Object root)
      Serializes object graph with the specified root.

      The serialization builds a JSON-LD tree model and then writes it using a JsonGenerator, which was passed to this instance in constructor.

      Parameters:
      root - Object graph root
    • initSerializers

      protected abstract ValueSerializers initSerializers()
    • buildJsonTree

      protected abstract JsonNode buildJsonTree(Object root)
      Builds the JSON-LD tree model.
      Parameters:
      root - Object graph root
      Returns:
      JsonNode corresponding to the JSON-LD's tree root
    • createCompactedJsonLdSerializer

      public static JsonLdSerializer createCompactedJsonLdSerializer(JsonGenerator jsonWriter)
    • createCompactedJsonLdSerializer

      public static JsonLdSerializer createCompactedJsonLdSerializer(JsonGenerator jsonWriter, Configuration configuration)
    • createContextBuildingJsonLdSerializer

      public static JsonLdSerializer createContextBuildingJsonLdSerializer(JsonGenerator jsonWriter)
    • createContextBuildingJsonLdSerializer

      public static JsonLdSerializer createContextBuildingJsonLdSerializer(JsonGenerator jsonWriter, Configuration configuration)