org.infinispan.schematic.document

## Class Bson

- java.lang.Object
- - org.infinispan.schematic.document.Bson

-     public class Bson
      extends Object

  A utility class for working with BSON documents.
  Since:
    5.1

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Bson.BinaryType` The bytes used for the subtypes of a binary value within a BSON stream.
    `static class` | `Bson.Type` The bytes used for the types within a BSON stream.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DATE_FORMAT`
    `protected static String` | `DATE_FORMAT_FOR_PARSING`
    `static byte` | `END_OF_DOCUMENT` Byte used for the end of a document within a BSON stream.
    `static byte` | `END_OF_STRING` Byte used for the end of a string within a BSON stream.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Bson()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static BsonWriter` | `getBsonWriter()`
    `static DateFormat` | `getDateFormatter()` Obtain a `DateFormat` object that can be used within the current thread to format `Date` objects.
    `static DateFormat` | `getDateParsingFormatter()`
    `protected static BsonReader` | `getReader()`
    `static int` | `getTypeForValue(Object value)` Get the `Bson.Type` constant that describes the type of value for the given field name.
    `static Document` | `read(DataInput input)` Read the binary BSON representation from supplied data input and construct the `Document` representation.
    `static Document` | `read(InputStream stream)` Read the binary BSON representation from supplied input stream and construct the `Document` representation.
    `static void` | `write(Document bson, ObjectOutput output)` Write to the supplied output the binary BSON representation of the supplied in-memory `Document`.
    `static void` | `write(Document bson, OutputStream stream)` Write to the supplied stream the binary BSON representation of the supplied in-memory `Document`.
    `static byte[]` | `write(Object object)` Return the array of bytes containing the standard BSON binary form of the supplied in-memory `Document`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DATE_FORMAT

          public static final String DATE_FORMAT

      See Also:
        Constant Field Values

    - #### DATE_FORMAT_FOR_PARSING

          protected static final String DATE_FORMAT_FOR_PARSING

      See Also:
        Constant Field Values

    - #### END_OF_DOCUMENT

          public static final byte END_OF_DOCUMENT

      Byte used for the end of a document within a BSON stream.
      See Also:
        Constant Field Values

    - #### END_OF_STRING

          public static final byte END_OF_STRING

      Byte used for the end of a string within a BSON stream.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Bson

          public Bson()

  - ### Method Detail

    - #### getDateFormatter

          public static DateFormat getDateFormatter()

      Obtain a `DateFormat` object that can be used within the current thread to format `Date` objects.
      Returns:
        the formatter; never null

    - #### getDateParsingFormatter

          public static DateFormat getDateParsingFormatter()

    - #### getBsonWriter

          protected static BsonWriter getBsonWriter()

    - #### write

          public static void write(Document bson,
                   OutputStream stream)
                            throws IOException

      Write to the supplied stream the binary BSON representation of the supplied in-memory `Document`.
      Parameters:
        `bson` - the BSON object or BSON value; may not be null
        `stream` - the output stream; may not be null
      Throws:
        `IOException` - if there was a problem writing to the stream

    - #### write

          public static void write(Document bson,
                   ObjectOutput output)
                            throws IOException

      Write to the supplied output the binary BSON representation of the supplied in-memory `Document`.
      Parameters:
        `bson` - the BSON object or BSON value; may not be null
        `output` - the output; may not be null
      Throws:
        `IOException` - if there was a problem writing to the ObjectOutput

    - #### write

          public static byte[] write(Object object)
                              throws IOException

      Return the array of bytes containing the standard BSON binary form of the supplied in-memory `Document`.
      Parameters:
        `object` - the BSON object or BSON value; may not be null
      Returns:
        the bytes
      Throws:
        `IOException` - if there was a problem reading from the stream

    - #### getReader

          protected static BsonReader getReader()

    - #### read

          public static Document read(InputStream stream)
                               throws IOException

      Read the binary BSON representation from supplied input stream and construct the `Document` representation.
      Parameters:
        `stream` - the input stream; may not be null
      Returns:
        the in-memory `Document` representation
      Throws:
        `IOException` - if there was a problem reading from the stream

    - #### read

          public static Document read(DataInput input)
                               throws IOException

      Read the binary BSON representation from supplied data input and construct the `Document` representation.
      Parameters:
        `input` - the data input; may not be null
      Returns:
        the in-memory `Document` representation
      Throws:
        `IOException` - if there was a problem reading from the stream

    - #### getTypeForValue

          public static int getTypeForValue(Object value)

      Get the `Bson.Type` constant that describes the type of value for the given field name.
      Parameters:
        `value` - The value
      Returns:
        the `Bson.Type` constant describing the value

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.