Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Beta3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.infinispan.schematic.document
Interface EditableDocument

All Superinterfaces:
  Document, Serializable

All Known Subinterfaces:
  EditableArray, Editor

All Known Implementing Classes:
  ArrayEditor, DocumentEditor, ObservableArrayEditor, ObservableDocumentEditor, Schematic.EditorImpl

    public interface EditableDocument

extends Document

Nested Class Summary

Nested classes/interfaces inherited from interface org.infinispan.schematic.document.Document
`Document.Field, Document.ValueTransformer`

Method Summary
`EditableArray` | `getArray(String name)` Get the existing array value in this document for the given field name.
`EditableDocument` | `getDocument(String name)` Get the existing document value in this document for the given field name.
`EditableArray` | `getOrCreateArray(String name)` Get the existing array value in this document for the given field name, or create a new array if there is no existing array at this field.
`EditableDocument` | `getOrCreateDocument(String name)` Get the existing document value in this document for the given field name, or create a new document if there is no existing document at this field.
`void` | `putAll(Document object)` Sets on this object all name/value pairs from the supplied object.
`void` | `putAll(Map<? extends String,? extends Object> map)` Sets on this object all key/value pairs from the supplied map.
`Object` | `remove(String name)` Remove the field with the supplied name, and return the value.
`void` | `removeAll()` Remove all fields from this document.
`EditableDocument` | `set(String name, Object value)` Set the value for the field with the given name to the supplied value.
`EditableArray` | `setArray(String name)` Set the value for the field with the given name to be a new, empty array.
`EditableArray` | `setArray(String name, Array array)` Set the value for the field with the given name to be the supplied array.
`EditableArray` | `setArray(String name, Object... values)` Set the value for the field with the given name to be the supplied array.
`EditableDocument` | `setBinary(String name, byte type, byte[] data)` Set the value for the field with the given name to be a binary value.
`EditableDocument` | `setBoolean(String name, boolean value)` Set the value for the field with the given name to the supplied boolean value.
`EditableDocument` | `setCode(String name, String code, boolean includeScope)` Set the value for the field with the given name to be a `Code` or `CodeWithScope`.
`EditableDocument` | `setCode(String name, String code, Document scope)` Set the value for the field with the given name to be a `Code` or `CodeWithScope`.
`EditableDocument` | `setDate(String name, Date value)` Set the value for the field with the given name to the supplied date value.
`EditableDocument` | `setDate(String name, String isoDate)` Set the value for the field with the given name to the date value parsed from the ISO-8601 date representation.
`EditableDocument` | `setDocument(String name)` Set the value for the field with the given name to be a new, empty Document.
`EditableDocument` | `setDocument(String name, Document document)` Set the value for the field with the given name to be the supplied Document.
`EditableDocument` | `setNull(String name)` Set the value for the field with the given name to be a null value.
`EditableDocument` | `setNumber(String name, double value)` Set the value for the field with the given name to the supplied double value.
`EditableDocument` | `setNumber(String name, float value)` Set the value for the field with the given name to the supplied float value.
`EditableDocument` | `setNumber(String name, int value)` Set the value for the field with the given name to the supplied integer value.
`EditableDocument` | `setNumber(String name, long value)` Set the value for the field with the given name to the supplied long value.
`EditableDocument` | `setObjectId(String name, byte[] bytes)` Set the value for the field with the given name to an `ObjectId` created from the supplied 12-byte binary value.
`EditableDocument` | `setObjectId(String name, int time, int machine, int process, int inc)` Set the value for the field with the given name to an `ObjectId` created from the supplied hexadecimal binary value.
`EditableDocument` | `setObjectId(String name, String hex)` Set the value for the field with the given name to an `ObjectId` created from the supplied hexadecimal binary value.
`EditableDocument` | `setRegularExpression(String name, String pattern)` Set the value for the field with the given name to the supplied regular expression.
`EditableDocument` | `setRegularExpression(String name, String pattern, int flags)` Set the value for the field with the given name to the supplied regular expression.
`EditableDocument` | `setString(String name, String value)` Set the value for the field with the given name to the supplied string value.
`EditableDocument` | `setSymbol(String name, String value)` Set the value for the field with the given name to a `Symbol` created from the supplied string value.
`EditableDocument` | `setTimestamp(String name, int timeInSeconds, int increment)` Set the value for the field with the given name to a `Timestamp` with the supplied time in seconds and increment.
`EditableDocument` | `setUuid(String name, UUID uuid)` Set the value for the field with the given name to be a `UUID`.
`Document` | `unwrap()` Unwrap this editor to obtain the potentially wrapped document.

Methods inherited from interface org.infinispan.schematic.document.Document
`clone, containsAll, containsField, fields, get, getBinary, getBoolean, getBoolean, getCode, getCodeWithScope, getDouble, getDouble, getInteger, getInteger, getLong, getLong, getMaxKey, getMinKey, getNumber, getNumber, getObjectId, getPattern, getString, getString, getSymbol, getType, getUuid, getUuid, isEmpty, isNull, isNullOrMissing, keySet, size, toMap, with, with, withVariablesReplaced, withVariablesReplacedWithSystemProperties`

Method Detail

### unwrap

    Document unwrap()

  Unwrap this editor to obtain the potentially wrapped document.

  Returns:
    the wrapped document, or this object; never null

### remove

    Object remove(String name)

  Remove the field with the supplied name, and return the value.

  Parameters:
    `name` - The name of the field
  Returns:
    the value that was removed, or null if there was no such value

### removeAll

    void removeAll()

  Remove all fields from this document.

### putAll

    void putAll(Document object)

  Sets on this object all name/value pairs from the supplied object. If the supplied object is null, this method does nothing.

  Parameters:
    `object` - the object containing the name/value pairs to be set on this object

### putAll

    void putAll(Map<? extends String,? extends Object> map)

  Sets on this object all key/value pairs from the supplied map. If the supplied map is null, this method does nothing.

  Parameters:
    `map` - the map containing the name/value pairs to be set on this object

### set

    EditableDocument set(String name,
                         Object value)

  Set the value for the field with the given name to the supplied value.

  Parameters:
    `name` - The name of the field
    `value` - the new value for the field
  Returns:
    This document, to allow for chaining methods

### setBoolean

    EditableDocument setBoolean(String name,
                                boolean value)

  Set the value for the field with the given name to the supplied boolean value.

  Parameters:
    `name` - The name of the field
    `value` - the new value for the field
  Returns:
    This document, to allow for chaining methods

### setNumber

    EditableDocument setNumber(String name,
                               int value)

  Set the value for the field with the given name to the supplied integer value.

  Parameters:
    `name` - The name of the field
    `value` - the new value for the field
  Returns:
    This document, to allow for chaining methods

### setNumber

    EditableDocument setNumber(String name,
                               long value)

  Set the value for the field with the given name to the supplied long value.

  Parameters:
    `name` - The name of the field
    `value` - the new value for the field
  Returns:
    This document, to allow for chaining methods

### setNumber

    EditableDocument setNumber(String name,
                               float value)

  Set the value for the field with the given name to the supplied float value.

  Parameters:
    `name` - The name of the field
    `value` - the new value for the field
  Returns:
    This document, to allow for chaining methods

### setNumber

    EditableDocument setNumber(String name,
                               double value)

  Set the value for the field with the given name to the supplied double value.

  Parameters:
    `name` - The name of the field
    `value` - the new value for the field
  Returns:
    This document, to allow for chaining methods

### setString

    EditableDocument setString(String name,
                               String value)

  Set the value for the field with the given name to the supplied string value.

  Parameters:
    `name` - The name of the field
    `value` - the new value for the field
  Returns:
    This document, to allow for chaining methods

### setSymbol

    EditableDocument setSymbol(String name,
                               String value)

  Set the value for the field with the given name to a `Symbol` created from the supplied string value. Symbols are defined in the BSON specification as being similar to a string but which exists for those languages that have a specific symbol type. Symbols are serialized to JSON as a normal string.

  Parameters:
    `name` - The name of the field
    `value` - the new value for the field
  Returns:
    This document, to allow for chaining methods
  See Also:
    `setString(String, String)`

### setDocument

    EditableDocument setDocument(String name)

  Set the value for the field with the given name to be a new, empty Document.

  Parameters:
    `name` - The name of the field
  Returns:
    The editable document that was just created; never null

### setDocument

    EditableDocument setDocument(String name,
                                 Document document)

  Set the value for the field with the given name to be the supplied Document.

  Parameters:
    `name` - The name of the field
    `document` - the document
  Returns:
    The editable document that was just set as the value for the named field; never null and may or may not be the same instance as the supplied `document`.

### getDocument

    EditableDocument getDocument(String name)

  Get the existing document value in this document for the given field name.

  Specified by:
    `getDocument` in interface `Document`
  Parameters:
    `name` - The name of the pair
  Returns:
    The editable document field value, if found, or null if there is no such pair or if the value is not a document

### getOrCreateDocument

    EditableDocument getOrCreateDocument(String name)

  Get the existing document value in this document for the given field name, or create a new document if there is no existing document at this field.

  Parameters:
    `name` - The name of the pair
  Returns:
    The editable document field value; never null

### setArray

    EditableArray setArray(String name)

  Set the value for the field with the given name to be a new, empty array.

  Parameters:
    `name` - The name of the field
  Returns:
    The editable array that was just created; never null

### setArray

    EditableArray setArray(String name,
                           Array array)

  Set the value for the field with the given name to be the supplied array.

  Parameters:
    `name` - The name of the field
    `array` - the array
  Returns:
    The editable array that was just set as the value for the named field; never null and may or may not be the same instance as the supplied `array`.

### setArray

    EditableArray setArray(String name,
                           Object... values)

  Set the value for the field with the given name to be the supplied array.

  Parameters:
    `name` - The name of the field
    `values` - the (valid) values for the array
  Returns:
    The editable array that was just set as the value for the named field; never null and may or may not be the same instance as the supplied `array`.

### getArray

    EditableArray getArray(String name)

  Get the existing array value in this document for the given field name.

  Specified by:
    `getArray` in interface `Document`
  Parameters:
    `name` - The name of the pair
  Returns:
    The editable array field value (as a list), if found, or null if there is no such pair or if the value is not an array

### getOrCreateArray

    EditableArray getOrCreateArray(String name)

  Get the existing array value in this document for the given field name, or create a new array if there is no existing array at this field.

  Parameters:
    `name` - The name of the pair
  Returns:
    The editable array field value; never null

### setDate

    EditableDocument setDate(String name,
                             Date value)

  Set the value for the field with the given name to the supplied date value.

  Parameters:
    `name` - The name of the field
    `value` - the new value for the field
  Returns:
    This document, to allow for chaining methods

### setDate

    EditableDocument setDate(String name,
                             String isoDate)
                             throws ParseException

  Set the value for the field with the given name to the date value parsed from the ISO-8601 date representation. Specifically, the date string must match one of these patterns:
  - "`yyyy-MM-ddTHH:mm:ss`" where "`T`" is a literal character
  - "`yyyy-MM-ddTHH:mm:ssZ`" where "`T`" and " `Z`" are literal characters
  - "`yyyy-MM-ddTHH:mm:ssGMT+00:00`" where " `T`", and "`GMT`" are literal characters

  Parameters:
    `name` - The name of the field
    `isoDate` - the new value for the field
  Returns:
    This document, to allow for chaining methods
  Throws:
    `ParseException` - if the supplied value could not be parsed into a valid date

### setTimestamp

    EditableDocument setTimestamp(String name,
                                  int timeInSeconds,
                                  int increment)

  Set the value for the field with the given name to a `Timestamp` with the supplied time in seconds and increment. Note that `Date` values are recommended for most purposes, as they are better suited to most applications' representations of time instants.

  Parameters:
    `name` - The name of the field
    `timeInSeconds` - the time in seconds for the new Timestamp
    `increment` - the time increment for the new Timestamp
  Returns:
    This document, to allow for chaining methods
  See Also:
    `setDate(String, Date)`

### setObjectId

    EditableDocument setObjectId(String name,
                                 String hex)

  Set the value for the field with the given name to an `ObjectId` created from the supplied hexadecimal binary value. Object IDs are defined by the BSON specification as 12-byte binary values designed to have a reasonably high probability of being unique when allocated. Since there is no explicit way to represent these in a JSON document, each ObjectId value is serialized in a JSON document as a nested document of the form:

       { "$oid" : "12bytesOfIdInBase16" }

  When nested documents of this form are read by this library's `JSON reader`, nested documents of this form will be converted to an ObjectId value.

  For example, an ObjectId with time value of "1310745823", machine value of "1", process value of "2", and increment value of "3" would be written as

       { "$oid" : "4e2064df0000010002000003" }

  Parameters:
    `name` - The name of the field
    `hex` - the hexadecimal binary value for the ObjectId
  Returns:
    This document, to allow for chaining methods
  See Also:
    `setObjectId(String, byte[])`, `setObjectId(String, int, int, int, int)`

### setObjectId

    EditableDocument setObjectId(String name,
                                 byte[] bytes)

  Set the value for the field with the given name to an `ObjectId` created from the supplied 12-byte binary value. Object IDs are defined by the BSON specification as 12-byte binary values designed to have a reasonably high probability of being unique when allocated. Since there is no explicit way to represent these in a JSON document, each ObjectId value is serialized in a JSON document as a nested document of the form:

       { "$oid" : "12bytesOfIdInBase16" }

  When nested documents of this form are read by this library's `JSON reader`, nested documents of this form will be converted to an ObjectId value.

  For example, an ObjectId with time value of "1310745823", machine value of "1", process value of "2", and increment value of "3" would be written as

       { "$oid" : "4e2064df0000010002000003" }

  Parameters:
    `name` - The name of the field
    `bytes` - the 12-byte value for the ObjectId
  Returns:
    This document, to allow for chaining methods
  See Also:
    `setObjectId(String, String)`, `setObjectId(String, int, int, int, int)`

### setObjectId

    EditableDocument setObjectId(String name,
                                 int time,
                                 int machine,
                                 int process,
                                 int inc)

  Set the value for the field with the given name to an `ObjectId` created from the supplied hexadecimal binary value. Object IDs are defined by the BSON specification as 12-byte binary values designed to have a reasonably high probability of being unique when allocated. Since there is no explicit way to represent these in a JSON document, each ObjectId value is serialized in a JSON document as a nested document of the form:

       { "$oid" : "12bytesOfIdInBase16" }

  When nested documents of this form are read by this library's `JSON reader`, nested documents of this form will be converted to an ObjectId value.

  For example, an ObjectId with time value of "1310745823", machine value of "1", process value of "2", and increment value of "3" would be written as

       { "$oid" : "4e2064df0000010002000003" }

  Parameters:
    `name` - The name of the field
    `time` - the Unix-style timestamp, which is a signed integer representing the number of seconds before or after January 1st 1970 (UTC)
    `machine` - the first three bytes of the (md5) hash of the machine host name, or of the mac/network address, or the virtual machine id
    `process` - the 2 bytes of the process id (or thread id) of the process generating the object id
    `inc` - an ever incrementing value, or a random number if a counter can't be used in the language/runtime
  Returns:
    This document, to allow for chaining methods
  See Also:
    `setObjectId(String, String)`, `setObjectId(String, byte[])`

### setRegularExpression

    EditableDocument setRegularExpression(String name,
                                          String pattern)

  Set the value for the field with the given name to the supplied regular expression. Regular expression values are represented in memory using `Pattern` instances, and are stored natively in BSON as regular expressions. However, when serialized to JSON, regular expressions are written as nested documents of the form:

       { "$regex" : "pattern" }

  where "pattern" is the regular expression pattern.

  When nested documents of this form are read by this library's `JSON reader`, nested documents of this form will be converted to a regular expression value.

  Parameters:
    `name` - The name of the field
    `pattern` - the regular expression pattern string
  Returns:
    This document, to allow for chaining methods
  See Also:
    `setRegularExpression(String, String, int)`

### setRegularExpression

    EditableDocument setRegularExpression(String name,
                                          String pattern,
                                          int flags)

  Set the value for the field with the given name to the supplied regular expression. Regular expression values are represented in memory using `Pattern` instances, and are stored natively in BSON as regular expressions. However, when serialized to JSON, regular expressions are written as nested documents of the form:

       { "$regex" : "pattern", "$options" : "flags" }

  where "pattern" is the regular expression pattern, and "flags" is a string representation of the regular expression options.

  When nested documents of this form are read by this library's `JSON reader`, nested documents of this form will be converted to a regular expression value.

  Parameters:
    `name` - The name of the field
    `pattern` - the regular expression pattern string
    `flags` - the bitwise-anded `Pattern` options: `Pattern.CANON_EQ`, `Pattern.CASE_INSENSITIVE`, `Pattern.CASE_INSENSITIVE`, `Pattern.COMMENTS`, `Pattern.DOTALL`, `Pattern.LITERAL`, `Pattern.MULTILINE`, `Pattern.UNICODE_CASE`, and `Pattern.UNIX_LINES`
  Returns:
    This document, to allow for chaining methods
  See Also:
    `setRegularExpression(String, String)`

### setNull

    EditableDocument setNull(String name)

  Set the value for the field with the given name to be a null value. Both JSON and BSON formats support null values, and `Null` is used for the value in the in-memory representation. The `Document.isNull(String)` methods can be used to determine if a field has been set to null, or `Document.isNullOrMissing(String)` if the field has not be set or if it has been set to null.

  Parameters:
    `name` - The name of the field
  Returns:
    This document, to allow for chaining methods
  See Also:
    `Document.isNull(String)`, `Document.isNullOrMissing(String)`

### setBinary

    EditableDocument setBinary(String name,
                               byte type,
                               byte[] data)

  Set the value for the field with the given name to be a binary value. JSON does not formally support binary values, and so such values will be encoded using a nested document of the form:

       { "$type" : typeAsInt, "$base64" : "bytesInBase64" }

  where "typeAsInt" is the integer representation of the `BSON type`, and "bytesInBase64" is the Base64 encoding of the actual Binary `bytes`.

  When nested documents of this form are read by this library's `JSON reader`, nested documents of this form will be converted to Binary value.

  Parameters:
    `name` - The name of the field
    `type` - one of the `BSON type` constants denoting the type of the `Binary` value
    `data` - the bytes for the `Binary` value
  Returns:
    This document, to allow for chaining methods

### setUuid

    EditableDocument setUuid(String name,
                             UUID uuid)

  Set the value for the field with the given name to be a `UUID`. JSON does not formally support binary values, and so such values will be encoded using a nested document of the form:

       { "$uuid" : "string-form-of-uuid" }

  where "string-form-of-uuid" is the UUID's `string representation`

  When nested documents of this form are read by this library's `JSON reader`, nested documents of this form will be converted to UUID value.

  Parameters:
    `name` - The name of the field
    `uuid` - the UUID value
  Returns:
    This document, to allow for chaining methods

### setCode

    EditableDocument setCode(String name,
                             String code,
                             boolean includeScope)

  Set the value for the field with the given name to be a `Code` or `CodeWithScope`. JSON does not formally support such values, and so when written to JSON they will be encoded using a nested document of the form:

       { "$code" : "code" }

  or, if there is a scope document

       { "$code" : "code", "$scope" : scope document }

  where "code" is the `Code`'s `JavaScript code` and scopeDocument is the nested document representing the `scope` in which the JavaScript code should be evaluated.

  When nested documents of this form are read by this library's `JSON reader`, nested documents of this form will be converted to `Code` or `CodeWithScope` value.

  Note that when `includeScope` is `true`, the returned `EditableDocument` can be used to populate the scope document.

  Parameters:
    `name` - The name of the field
    `code` - the code
    `includeScope` - true if the code should include a scope (and if this method should return an `EditableDocument` for this scope document), or false otherwise
  Returns:
    if `includeScope` is `true`, then the `EditableDocument` for the scope; otherwise, this document to allow for chaining methods
  See Also:
    `setCode(String, String, Document)`

### setCode

    EditableDocument setCode(String name,
                             String code,
                             Document scope)

  Set the value for the field with the given name to be a `Code` or `CodeWithScope`. JSON does not formally support such values, and so when written to JSON they will be encoded using a nested document of the form:

       { "$code" : "code" }

  or, if there is a scope document

       { "$code" : "code", "$scope" : scope document }

  where "code" is the `Code`'s `JavaScript code` and scopeDocument is the nested document representing the `scope` in which the JavaScript code should be evaluated.

  When nested documents of this form are read by this library's `JSON reader`, nested documents of this form will be converted to `Code` or `CodeWithScope` value.

  Parameters:
    `name` - The name of the field
    `code` - the code
    `scope` - the scope in which the JavaScript code should be evaulated, or null if there is no scope
  Returns:
    the `EditableDocument` for the scope, or null if the `scope` reference is null
  See Also:
    `setCode(String, String, boolean)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Beta3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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