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 Document

All Superinterfaces:
  Serializable

All Known Subinterfaces:
  Array, EditableArray, EditableDocument, Editor, MutableArray, MutableDocument

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

    public interface Document

extends Serializable

Primary read-only interface for an in-memory representation of JSON/BSON objects.

Since:
  5.1

Nested Class Summary
`static interface` | `Document.Field`
`static interface` | `Document.ValueTransformer` A component that can transform field values, via `with(ValueTransformer)`.

Method Summary
`Document` | `clone()` Obtain a clone of this document.
`boolean` | `containsAll(Document document)` Checks if this object contains all of the fields in the supplied document.
`boolean` | `containsField(String name)` Checks if this object contains a field with the given name.
`Iterable<Document.Field>` | `fields()` Obtain an iterator over the `Document.Field`s in this object.
`Object` | `get(String name)` Gets the value in this document for the given field name.
`List<?>` | `getArray(String name)` Get the array value in this document for the given field name.
`Binary` | `getBinary(String name)` Get the `Binary` value in this document for the given field name.
`Boolean` | `getBoolean(String name)` Get the boolean value in this document for the given field name.
`boolean` | `getBoolean(String name, boolean defaultValue)` Get the boolean value in this document for the given field name.
`Code` | `getCode(String name)` Get the `Code` value in this document for the given field name.
`CodeWithScope` | `getCodeWithScope(String name)` Get the `CodeWithScope` value in this document for the given field name.
`Document` | `getDocument(String name)` Get the document value in this document for the given field name.
`Double` | `getDouble(String name)` Get the double value in this document for the given field name.
`double` | `getDouble(String name, double defaultValue)` Get the double value in this document for the given field name.
`Integer` | `getInteger(String name)` Get the integer value in this document for the given field name.
`int` | `getInteger(String name, int defaultValue)` Get the integer value in this document for the given field name.
`Long` | `getLong(String name)` Get the integer value in this document for the given field name.
`long` | `getLong(String name, long defaultValue)` Get the long value in this document for the given field name.
`MaxKey` | `getMaxKey(String name)` Get the `MaxKey` value in this document for the given field name.
`MinKey` | `getMinKey(String name)` Get the `MinKey` value in this document for the given field name.
`Number` | `getNumber(String name)` Get the number value in this document for the given field name.
`Number` | `getNumber(String name, Number defaultValue)` Get the number value in this document for the given field name.
`ObjectId` | `getObjectId(String name)` Get the `ObjectId` value in this document for the given field name.
`Pattern` | `getPattern(String name)` Get the `Pattern` value in this document for the given field name.
`String` | `getString(String name)` Get the string value in this document for the given field name.
`String` | `getString(String name, String defaultValue)` Get the string value in this document for the given field name.
`Symbol` | `getSymbol(String name)` Get the `Symbol` value in this document for the given field name.
`int` | `getType(String name)` Get the `Bson.Type` constant that describes the type of value for the given field name.
`UUID` | `getUuid(String name)` Get the `UUID` value in this document for the given field name.
`UUID` | `getUuid(String name, UUID defaultValue)` Get the `UUID` value in this document for the given field name.
`boolean` | `isEmpty()` Return whether this document contains no fields and is therefore empty.
`boolean` | `isNull(String name)` Determine whether this object has a pair with the given the name and the value is null.
`boolean` | `isNullOrMissing(String name)` Determine whether this object has a pair with the given the name and the value is null, or if this object has no field with the given name.
`Set<String>` | `keySet()` Returns this object's fields' names
`int` | `size()` Return the number of name-value pairs in this object.
`Map<String,? extends Object>` | `toMap()` Returns a map representing this BSONObject.
`Document` | `with(Document.ValueTransformer transformer)` Obtain a clone of this document, but with the field values transformed using the supplied `Document.ValueTransformer`.
`Document` | `with(Map<String,Object> changedFields)` Obtain a clone of this document, but with the supplied fields replaced.
`Document` | `withVariablesReplaced(Properties properties)` Obtain a clone of this document, but with all variables in string field values replaced with the referenced values from the supplied properties.
`Document` | `withVariablesReplacedWithSystemProperties()` Obtain a clone of this document, but with all variables in string field values replaced with the referenced values from the System properties.

Method Detail

### get

    Object get(String name)

  Gets the value in this document for the given field name.

  Parameters:
    `name` - The name of the pair
  Returns:
    The field value, if found, or null otherwise

### getBoolean

    Boolean getBoolean(String name)

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

  Parameters:
    `name` - The name of the pair
  Returns:
    The boolean field value, if found, or null if there is no such pair or if the value is not a boolean

### getBoolean

    boolean getBoolean(String name,
                       boolean defaultValue)

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

  Parameters:
    `name` - The name of the pair
    `defaultValue` - the default value to return if there is no such pair or if the value is not a boolean
  Returns:
    The boolean field value if found, or `defaultValue` if there is no such pair or if the value is not a boolean

### getInteger

    Integer getInteger(String name)

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

  Parameters:
    `name` - The name of the pair
  Returns:
    The integer field value, if found, or null if there is no such pair or if the value is not an integer

### getInteger

    int getInteger(String name,
                   int defaultValue)

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

  Parameters:
    `name` - The name of the pair
    `defaultValue` - the default value to return if there is no such pair or if the value is not a integer
  Returns:
    The integer field value if found, or `defaultValue` if there is no such pair or if the value is not a integer

### getLong

    Long getLong(String name)

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

  Parameters:
    `name` - The name of the pair
  Returns:
    The long field value, if found, or null if there is no such pair or if the value is not a long value

### getLong

    long getLong(String name,
                 long defaultValue)

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

  Parameters:
    `name` - The name of the pair
    `defaultValue` - the default value to return if there is no such pair or if the value is not a long value
  Returns:
    The long field value if found, or `defaultValue` if there is no such pair or if the value is not a long value

### getDouble

    Double getDouble(String name)

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

  Parameters:
    `name` - The name of the pair
  Returns:
    The double field value, if found, or null if there is no such pair or if the value is not a double

### getDouble

    double getDouble(String name,
                     double defaultValue)

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

  Parameters:
    `name` - The name of the pair
    `defaultValue` - the default value to return if there is no such pair or if the value is not a double
  Returns:
    The double field value if found, or `defaultValue` if there is no such pair or if the value is not a double

### getNumber

    Number getNumber(String name)

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

  Parameters:
    `name` - The name of the pair
  Returns:
    The double field value, if found, or null if there is no such pair or if the value is not a number

### getNumber

    Number getNumber(String name,
                     Number defaultValue)

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

  Parameters:
    `name` - The name of the pair
    `defaultValue` - the default value to return if there is no such pair or if the value is not a number
  Returns:
    The number field value if found, or `defaultValue` if there is no such pair or if the value is not a number

### getString

    String getString(String name)

  Get the string value in this document for the given field name. This method will return the string even if the actual value is a `Symbol`.

  Parameters:
    `name` - The name of the pair
  Returns:
    The string field value, if found, or null if there is no such pair or if the value is not a string

### getString

    String getString(String name,
                     String defaultValue)

  Get the string value in this document for the given field name. This method will return the string even if the actual value is a `Symbol`.

  Parameters:
    `name` - The name of the pair
    `defaultValue` - the default value to return if there is no such pair or if the value is not a string
  Returns:
    The string field value if found, or `defaultValue` if there is no such pair or if the value is not a string

### getArray

    List<?> getArray(String name)

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

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

### getDocument

    Document getDocument(String name)

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

  Parameters:
    `name` - The name of the pair
  Returns:
    The document field value, if found, or null if there is no such pair or if the value is not a document

### isNull

    boolean isNull(String name)

  Determine whether this object has a pair with the given the name and the value is null. This is equivalent to calling:

       this.get(name) instanceof Null;

  Parameters:
    `name` - The name of the pair
  Returns:
    `true` if the field has been set to a `Null` value, or false otherwise
  See Also:
    `isNullOrMissing(String)`

### isNullOrMissing

    boolean isNullOrMissing(String name)

  Determine whether this object has a pair with the given the name and the value is null, or if this object has no field with the given name. This is equivalent to calling:

       Null.matches(this.get(name));

  Parameters:
    `name` - The name of the pair
  Returns:
    `true` if the field value for the name is null or if there is no such field.
  See Also:
    `isNull(String)`

### getMaxKey

    MaxKey getMaxKey(String name)

  Get the `MaxKey` value in this document for the given field name.

  Parameters:
    `name` - The name of the pair
  Returns:
    The `MaxKey` field value, if found, or null if there is no such pair or if the value is not a `MaxKey`

### getMinKey

    MinKey getMinKey(String name)

  Get the `MinKey` value in this document for the given field name.

  Parameters:
    `name` - The name of the pair
  Returns:
    The `MinKey` field value, if found, or null if there is no such pair or if the value is not a `MinKey`

### getCode

    Code getCode(String name)

  Get the `Code` value in this document for the given field name.

  Parameters:
    `name` - The name of the pair
  Returns:
    The `Code` field value, if found, or null if there is no such pair or if the value is not a `Code`

### getCodeWithScope

    CodeWithScope getCodeWithScope(String name)

  Get the `CodeWithScope` value in this document for the given field name.

  Parameters:
    `name` - The name of the pair
  Returns:
    The `CodeWithScope` field value, if found, or null if there is no such pair or if the value is not a `CodeWithScope`

### getObjectId

    ObjectId getObjectId(String name)

  Get the `ObjectId` value in this document for the given field name.

  Parameters:
    `name` - The name of the pair
  Returns:
    The `ObjectId` field value, if found, or null if there is no such pair or if the value is not a `ObjectId`

### getBinary

    Binary getBinary(String name)

  Get the `Binary` value in this document for the given field name.

  Parameters:
    `name` - The name of the pair
  Returns:
    The `Binary` field value, if found, or null if there is no such pair or if the value is not a `Binary`

### getSymbol

    Symbol getSymbol(String name)

  Get the `Symbol` value in this document for the given field name.

  Parameters:
    `name` - The name of the pair
  Returns:
    The `Symbol` field value, if found, or null if there is no such pair or if the value is not a `Symbol`

### getPattern

    Pattern getPattern(String name)

  Get the `Pattern` value in this document for the given field name.

  Parameters:
    `name` - The name of the pair
  Returns:
    The `Pattern` field value, if found, or null if there is no such pair or if the value is not a `Pattern`

### getUuid

    UUID getUuid(String name)

  Get the `UUID` value in this document for the given field name.

  Parameters:
    `name` - The name of the pair
  Returns:
    The `UUID` field value, if found, or null if there is no such pair or if the value is not a `UUID`

### getUuid

    UUID getUuid(String name,
                 UUID defaultValue)

  Get the `UUID` value in this document for the given field name.

  Parameters:
    `name` - The name of the pair
    `defaultValue` - the default value to return if there is no such pair or if the value is not a string
  Returns:
    The `UUID` field value if found, or `defaultValue` if there is no such pair or if the value is not a UUID (or a string that is convertable from a UUID)

### getType

    int getType(String name)

  Get the `Bson.Type` constant that describes the type of value for the given field name.

  Parameters:
    `name` - The name of the pair
  Returns:
    the `Bson.Type` constant describing the value, or -1 if there is no field with the supplied name

### toMap

    Map<String,? extends Object> toMap()

  Returns a map representing this BSONObject.

  Returns:
    the map

### fields

    Iterable<Document.Field> fields()

  Obtain an iterator over the `Document.Field`s in this object.

  Returns:
    a field iterator; never null

### containsField

    boolean containsField(String name)

  Checks if this object contains a field with the given name.

  Parameters:
    `name` - The name of the pair for which to check
  Returns:
    true if this document contains a field with the supplied name, or false otherwise

### containsAll

    boolean containsAll(Document document)

  Checks if this object contains all of the fields in the supplied document.

  Parameters:
    `document` - The document with the fields that should be in this document
  Returns:
    true if this document contains all of the fields in the supplied document, or false otherwise

### keySet

    Set<String> keySet()

  Returns this object's fields' names

  Returns:
    The names of the fields in this object

### size

    int size()

  Return the number of name-value pairs in this object.

  Returns:
    the number of name-value pairs; never negative

### isEmpty

    boolean isEmpty()

  Return whether this document contains no fields and is therefore empty.

  Returns:
    true if there are no fields in this document, or false if there is at least one.

### clone

    Document clone()

  Obtain a clone of this document.

  Returns:
    the clone of this document; never null

### with

    Document with(Map<String,Object> changedFields)

  Obtain a clone of this document, but with the supplied fields replaced.

  Parameters:
    `changedFields` - the fields that should be changed; may be null
  Returns:
    the clone of this document with the change fields, or this document if there are no changes

### with

    Document with(Document.ValueTransformer transformer)

  Obtain a clone of this document, but with the field values transformed using the supplied `Document.ValueTransformer`.

  Parameters:
    `transformer` - the transformer that should be used to transform each field value; may not be null
  Returns:
    the clone of this document with transformed fields, or this document if the transformer changed none of the values

### withVariablesReplaced

    Document withVariablesReplaced(Properties properties)

  Obtain a clone of this document, but with all variables in string field values replaced with the referenced values from the supplied properties.

  Variables may appear anywhere within a string value, and multiple variables can be used within the same value. Variables take the form:

          variable := '${' variableNames [ ':' defaultValue ] '}'

          variableNames := variableName [ ',' variableNames ]

          variableName := /* any characters except ',' and ':' and '}'

          defaultValue := /* any characters except

  Note that variableName is the name used to look up the `Properties` property. Notice that the syntax supports multiple variables. The logic will process the variables from let to right, until an existing System property is found. And at that point, it will stop and will not attempt to find values for the other variables.

  Parameters:
    `properties` - the properties keyed by variable name
  Returns:
    the clone of this document with variables in fields string values replaced with values from the properties object, or this document if no variables were found
  See Also:
    `withVariablesReplacedWithSystemProperties()`, `with(ValueTransformer)`, `SchemaLibrary.convertValues(Document, String)`

### withVariablesReplacedWithSystemProperties

    Document withVariablesReplacedWithSystemProperties()

  Obtain a clone of this document, but with all variables in string field values replaced with the referenced values from the System properties.

  Variables may appear anywhere within a string value, and multiple variables can be used within the same value. Variables take the form:

          variable := '${' variableNames [ ':' defaultValue ] '}'

          variableNames := variableName [ ',' variableNames ]

          variableName := /* any characters except ',' and ':' and '}'

          defaultValue := /* any characters except

  Note that variableName is the name used to look up a System property via `System.getProperty(String)`. Notice that the syntax supports multiple variables. The logic will process the variables from let to right, until an existing System property is found. And at that point, it will stop and will not attempt to find values for the other variables.

  Because only string values can contain variables, the resulting values are left as strings. This may not be valid according to the document's JSON Schema, so see `SchemaLibrary.convertValues(Document, String)` to convert the string values after variable substitution into the expected non-string types.

  Returns:
    the clone of this document with variables in fields string values replaced with values from the System properties, or this document if no variables were found
  See Also:
    `withVariablesReplaced(Properties)`, `with(ValueTransformer)`, `SchemaLibrary.convertValues(Document, String)`

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.