Package oracle.soda

Interface OracleDocumentFactory

    • Method Detail

      • createDocumentFromString

        OracleDocument createDocumentFromString​(String key,
                                                String content,
                                                String mediaType)
                                         throws OracleException
        Creates a new document with the provided key, String content, and media type.

        If the media type is "application/json" or null, the provided content must be JSON, as defined in RFC 4627.

        Parameters:
        key - document key. Can be null
        content - document content. Can be null
        mediaType - document media type. Can be null, in which case the media type defaults to "application/json". An implementation might not support any particular media type
        Returns:
        created OracleDocument
        Throws:
        OracleException - if the document cannot be created
      • createDocumentFrom

        OracleDocument createDocumentFrom​(String key,
                                          Object content)
                                   throws OracleException
        Creates a new document with the provided key and JSON content object. The content object must be an instance of one of the following types:

         
        Class Description
        javax.json.JsonValue
        jakarta.json.JsonValue
        oracle.sql.json.OracleJsonValue
        A instance of JsonValue or OracleJsonValue. This includes derivations such as JsonObject and JsonArray. For example:
         JsonBuilderFactory factory = Json.createBuilderFactory(null);
         JsonObject obj = factory.createObjectBuilder()
                                 .add("name", "pear")
                                 .add("count", 47)
                                 .build();
         OracleDocument doc = db.createDocumentFrom(obj);
         
        javax.json.stream.JsonParser
        jakarta.json.stream.JsonParser
        oracle.sql.json.OracleJsonParser
        A JSON event stream.
        java.lang.String
        java.lang.CharSequence
        java.io.Reader
        A JSON text value.
        Deprecation Notice: support for javax.json will be removed in an upcoming release.
        Parameters:
        key - document key. Can be null
        content - document content. Must not be null
        Returns:
        created OracleDocument, with media type "application/json"
        Throws:
        OracleException - if the document cannot be created from the specified value.
        See Also:
        Java API for JSON Processing
      • createDocumentFromByteArray

        OracleDocument createDocumentFromByteArray​(String key,
                                                   byte[] content,
                                                   String mediaType)
                                            throws OracleException
        Creates a new document with the provided key, byte[] content, and content type.

        If the media type is "application/json" or null, the provided content must be JSON, as defined in RFC 4627. The supported encodings are UTF-8, and UTF16 (BE and LE).

        Parameters:
        key - document key. Can be null
        content - document content. Can be null
        mediaType - document media type. Can be null, in which case the media type defaults to "application/json". An implementation might not support any particular media type
        Returns:
        created OracleDocument
        Throws:
        OracleException - if the document cannot be created