Package org.bson

Class AbstractBsonWriter.Context

  • Direct Known Subclasses:
    JsonWriter.Context
    Enclosing class:
    AbstractBsonWriter

    public class AbstractBsonWriter.Context
    extends java.lang.Object
    The context for the writer. Records the parent context, creating a bread crumb trail to trace back up to the root context of the reader. Also records the BsonContextType, indicating whether the writer is reading a document, array, or other complex sub-structure.
    • Constructor Detail

      • Context

        public Context​(AbstractBsonWriter.Context from)
        Creates a new instance, copying values from an existing context.
        Parameters:
        from - the Context to copy values from
      • Context

        public Context​(AbstractBsonWriter.Context parentContext,
                       BsonContextType contextType)
        Creates a new instance.
        Parameters:
        parentContext - the context of the parent node
        contextType - the context type.
    • Method Detail

      • getParentContext

        public AbstractBsonWriter.Context getParentContext()
        Returns the parent context. Allows users of this context object to transition to this parent context.
        Returns:
        the context that came before this one
      • getContextType

        public BsonContextType getContextType()
        Gets the current context type.
        Returns:
        the current context type.
      • copy

        public AbstractBsonWriter.Context copy()
        Copies the values from this Context into a new instance.
        Returns:
        the new instance with the same values as this context.