Class SerializationContextImpl

java.lang.Object
org.eclipse.yasson.internal.ProcessingContext
org.eclipse.yasson.internal.SerializationContextImpl
All Implemented Interfaces:
jakarta.json.bind.serializer.SerializationContext

public class SerializationContextImpl extends ProcessingContext implements jakarta.json.bind.serializer.SerializationContext
JSONB marshaller. Created each time marshalling operation called.
  • Constructor Details

    • SerializationContextImpl

      public SerializationContextImpl(JsonbContext jsonbContext, Type rootRuntimeType)
      Creates Marshaller for generation to String.
      Parameters:
      jsonbContext - Current context.
      rootRuntimeType - Type of root object.
    • SerializationContextImpl

      public SerializationContextImpl(JsonbContext jsonbContext)
      Creates Marshaller for generation to String.
      Parameters:
      jsonbContext - Current context.
  • Method Details

    • setKey

      public void setKey(String key)
      Set new current property key name.
      Parameters:
      key - key name
    • getKey

      public String getKey()
      Current property key name.
      Returns:
      current property key name
    • isRoot

      public boolean isRoot()
      Serialized value is a root value.
      Returns:
      is root value
    • setRoot

      public void setRoot(boolean root)
      Set whether serialized value is root value.
      Parameters:
      root - is root value
    • isContainerWithNulls

      public boolean isContainerWithNulls()
      Value from this property is only used in NullSerializer. It should not be used anywhere else.
      Returns:
      if container supports nulls
    • setContainerWithNulls

      public void setContainerWithNulls(boolean writeNulls)
      Set if container supports null values.
      Parameters:
      writeNulls - should write nulls in container
    • marshall

      public void marshall(Object object, jakarta.json.stream.JsonGenerator jsonGenerator, boolean close)
      Marshals given object to provided Writer or OutputStream.
      Parameters:
      object - object to marshall
      jsonGenerator - generator to use
      close - if generator should be closed
    • marshall

      public void marshall(Object object, jakarta.json.stream.JsonGenerator jsonGenerator)
      Marshals given object to provided Writer or OutputStream. Closes the generator on completion.
      Parameters:
      object - object to marshall
      jsonGenerator - generator to use
    • marshallWithoutClose

      public void marshallWithoutClose(Object object, jakarta.json.stream.JsonGenerator jsonGenerator)
      Marshals given object to provided Writer or OutputStream. Leaves generator open for further interaction after completion.
      Parameters:
      object - object to marshall
      jsonGenerator - generator to use
    • serialize

      public <T> void serialize(String key, T object, jakarta.json.stream.JsonGenerator generator)
      Specified by:
      serialize in interface jakarta.json.bind.serializer.SerializationContext
    • serialize

      public <T> void serialize(T object, jakarta.json.stream.JsonGenerator generator)
      Specified by:
      serialize in interface jakarta.json.bind.serializer.SerializationContext
    • serializeObject

      public <T> void serializeObject(T root, jakarta.json.stream.JsonGenerator generator)
      Serializes root element.
      Type Parameters:
      T - Root type
      Parameters:
      root - Root.
      generator - JSON generator.
    • getRootSerializer

      public ModelSerializer getRootSerializer(Type type)
    • addProcessedObject

      public boolean addProcessedObject(Object object)
      Adds currently processed object to the Set.
      Overrides:
      addProcessedObject in class ProcessingContext
      Parameters:
      object - processed object
      Returns:
      if object was added
    • removeProcessedObject

      public boolean removeProcessedObject(Object object)
      Removes processed object from the Set.
      Overrides:
      removeProcessedObject in class ProcessingContext
      Parameters:
      object - processed object
      Returns:
      if object was removed