|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.infinispan.schematic.internal.document.DocumentEditor
public class DocumentEditor
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.infinispan.schematic.document.Document |
---|
Document.Field, Document.ValueTransformer |
Field Summary | |
---|---|
protected DocumentValueFactory |
factory
|
Constructor Summary | |
---|---|
DocumentEditor(MutableDocument document)
Return the document that was edited. |
|
DocumentEditor(MutableDocument document,
DocumentValueFactory factory)
Return the document that was edited. |
Method Summary | |
---|---|
MutableDocument |
asMutableDocument()
|
DocumentEditor |
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. |
protected EditableArray |
createEditableArray(MutableArray array,
String fieldName,
DocumentValueFactory factory)
|
protected EditableDocument |
createEditableDocument(MutableDocument document,
String fieldName,
DocumentValueFactory factory)
|
protected Object |
doSetValue(String name,
Object value)
The method that does the actual setting for all of the set... |
protected Object |
doSetValueIfAbsent(String name,
Object value)
The method that does the actual setting for all of the set... |
protected EditableDocument |
editable(Document doc,
String fieldName)
|
protected EditableArray |
editable(List<?> array,
String fieldName)
|
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. |
EditableArray |
getArray(String name)
Get the existing 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. |
EditableDocument |
getDocument(String name)
Get the existing 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. |
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. |
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 |
Object |
put(String name,
Object value)
|
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 . |
int |
size()
Return the number of name-value pairs in this object. |
Map<String,? extends Object> |
toMap()
Returns a map representing this BSONObject. |
String |
toString()
|
Document |
unwrap()
Unwrap this editor to obtain the potentially wrapped document. |
static Array |
unwrap(Array array)
|
static Document |
unwrap(Document document)
|
static Object |
unwrap(Object value)
|
DocumentEditor |
with(Document.ValueTransformer transformer)
Obtain a clone of this document, but with the field values transformed using the supplied Document.ValueTransformer . |
DocumentEditor |
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. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final DocumentValueFactory factory
Constructor Detail |
---|
public DocumentEditor(MutableDocument document)
document
- the document to be editedpublic DocumentEditor(MutableDocument document, DocumentValueFactory factory)
document
- the document to be editedfactory
- the factory that should be used to create value objectsMethod Detail |
---|
public DocumentEditor clone()
Document
clone
in interface Document
clone
in class Object
public DocumentEditor with(Map<String,Object> changedFields)
Document
with
in interface Document
changedFields
- the fields that should be changed; may be null
public DocumentEditor with(Document.ValueTransformer transformer)
Document
Document.ValueTransformer
.
with
in interface Document
transformer
- the transformer that should be used to transform each field value; may not be null
public Document withVariablesReplaced(Properties properties)
Document
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 exceptNote 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.
withVariablesReplaced
in interface Document
properties
- the properties keyed by variable name
Document.withVariablesReplacedWithSystemProperties()
,
Document.with(ValueTransformer)
,
SchemaLibrary.convertValues(Document, String)
public Document withVariablesReplacedWithSystemProperties()
Document
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 exceptNote 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.
withVariablesReplacedWithSystemProperties
in interface Document
Document.withVariablesReplaced(Properties)
,
Document.with(ValueTransformer)
,
SchemaLibrary.convertValues(Document, String)
public Document unwrap()
EditableDocument
unwrap
in interface EditableDocument
public MutableDocument asMutableDocument()
public Object get(String name)
Document
get
in interface Document
name
- The name of the pair
public Boolean getBoolean(String name)
Document
getBoolean
in interface Document
name
- The name of the pair
public boolean getBoolean(String name, boolean defaultValue)
Document
getBoolean
in interface Document
name
- The name of the pairdefaultValue
- the default value to return if there is no such pair or if the value is not a boolean
defaultValue
if there is no such pair or if the value is not a
booleanpublic Object put(String name, Object value)
public void putAll(Document object)
EditableDocument
putAll
in interface EditableDocument
object
- the object containing the name/value pairs to be set on this objectpublic void putAll(Map<? extends String,? extends Object> map)
EditableDocument
putAll
in interface EditableDocument
map
- the map containing the name/value pairs to be set on this objectpublic Object remove(String name)
EditableDocument
remove
in interface EditableDocument
name
- The name of the field
public Integer getInteger(String name)
Document
getInteger
in interface Document
name
- The name of the pair
public int getInteger(String name, int defaultValue)
Document
getInteger
in interface Document
name
- The name of the pairdefaultValue
- the default value to return if there is no such pair or if the value is not a integer
defaultValue
if there is no such pair or if the value is not a
integerpublic Long getLong(String name)
Document
getLong
in interface Document
name
- The name of the pair
public long getLong(String name, long defaultValue)
Document
getLong
in interface Document
name
- The name of the pairdefaultValue
- the default value to return if there is no such pair or if the value is not a long value
defaultValue
if there is no such pair or if the value is not a long
valuepublic Double getDouble(String name)
Document
getDouble
in interface Document
name
- The name of the pair
public double getDouble(String name, double defaultValue)
Document
getDouble
in interface Document
name
- The name of the pairdefaultValue
- the default value to return if there is no such pair or if the value is not a double
defaultValue
if there is no such pair or if the value is not a
doublepublic Number getNumber(String name)
Document
getNumber
in interface Document
name
- The name of the pair
public Number getNumber(String name, Number defaultValue)
Document
getNumber
in interface Document
name
- The name of the pairdefaultValue
- the default value to return if there is no such pair or if the value is not a number
defaultValue
if there is no such pair or if the value is not a
numberpublic String getString(String name)
Document
Symbol
.
getString
in interface Document
name
- The name of the pair
public String getString(String name, String defaultValue)
Document
Symbol
.
getString
in interface Document
name
- The name of the pairdefaultValue
- the default value to return if there is no such pair or if the value is not a string
defaultValue
if there is no such pair or if the value is not a
stringpublic EditableArray getArray(String name)
EditableDocument
getArray
in interface Document
getArray
in interface EditableDocument
name
- The name of the pair
public EditableArray getOrCreateArray(String name)
EditableDocument
getOrCreateArray
in interface EditableDocument
name
- The name of the pair
public EditableDocument getDocument(String name)
EditableDocument
getDocument
in interface Document
getDocument
in interface EditableDocument
name
- The name of the pair
public EditableDocument getOrCreateDocument(String name)
EditableDocument
getOrCreateDocument
in interface EditableDocument
name
- The name of the pair
public boolean isNull(String name)
Document
this.get(name) instanceof Null;
isNull
in interface Document
name
- The name of the pair
true
if the field has been set to a Null
value, or false otherwiseDocument.isNullOrMissing(String)
public boolean isNullOrMissing(String name)
Document
Null.matches(this.get(name));
isNullOrMissing
in interface Document
name
- The name of the pair
true
if the field value for the name is null or if there is no such field.Document.isNull(String)
public MaxKey getMaxKey(String name)
Document
MaxKey
value in this document for the given field name.
getMaxKey
in interface Document
name
- The name of the pair
MaxKey
field value, if found, or null if there is no such pair or if the value is not a MaxKey
public MinKey getMinKey(String name)
Document
MinKey
value in this document for the given field name.
getMinKey
in interface Document
name
- The name of the pair
MinKey
field value, if found, or null if there is no such pair or if the value is not a MinKey
public Code getCode(String name)
Document
Code
value in this document for the given field name.
getCode
in interface Document
name
- The name of the pair
Code
field value, if found, or null if there is no such pair or if the value is not a Code
public CodeWithScope getCodeWithScope(String name)
Document
CodeWithScope
value in this document for the given field name.
getCodeWithScope
in interface Document
name
- The name of the pair
CodeWithScope
field value, if found, or null if there is no such pair or if the value is not a
CodeWithScope
public ObjectId getObjectId(String name)
Document
ObjectId
value in this document for the given field name.
getObjectId
in interface Document
name
- The name of the pair
ObjectId
field value, if found, or null if there is no such pair or if the value is not a
ObjectId
public Binary getBinary(String name)
Document
Binary
value in this document for the given field name.
getBinary
in interface Document
name
- The name of the pair
Binary
field value, if found, or null if there is no such pair or if the value is not a Binary
public Symbol getSymbol(String name)
Document
Symbol
value in this document for the given field name.
getSymbol
in interface Document
name
- The name of the pair
Symbol
field value, if found, or null if there is no such pair or if the value is not a Symbol
public Pattern getPattern(String name)
Document
Pattern
value in this document for the given field name.
getPattern
in interface Document
name
- The name of the pair
Pattern
field value, if found, or null if there is no such pair or if the value is not a
Pattern
public UUID getUuid(String name)
Document
UUID
value in this document for the given field name.
getUuid
in interface Document
name
- The name of the pair
UUID
field value, if found, or null if there is no such pair or if the value is not a UUID
public UUID getUuid(String name, UUID defaultValue)
Document
UUID
value in this document for the given field name.
getUuid
in interface Document
name
- The name of the pairdefaultValue
- the default value to return if there is no such pair or if the value is not a string
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)public int getType(String name)
Document
Bson.Type
constant that describes the type of value for the given field name.
getType
in interface Document
name
- The name of the pair
Bson.Type
constant describing the value, or -1 if there is no field with the supplied namepublic Map<String,? extends Object> toMap()
Document
toMap
in interface Document
public Iterable<Document.Field> fields()
Document
Document.Field
s in this object.
fields
in interface Document
public boolean containsField(String name)
Document
containsField
in interface Document
name
- The name of the pair for which to check
public boolean containsAll(Document document)
Document
containsAll
in interface Document
document
- The document with the fields that should be in this document
public Set<String> keySet()
Document
keySet
in interface Document
public int size()
Document
size
in interface Document
public boolean isEmpty()
Document
isEmpty
in interface Document
public void removeAll()
EditableDocument
removeAll
in interface EditableDocument
public EditableDocument set(String name, Object value)
EditableDocument
set
in interface EditableDocument
name
- The name of the fieldvalue
- the new value for the field
public EditableDocument setBoolean(String name, boolean value)
EditableDocument
setBoolean
in interface EditableDocument
name
- The name of the fieldvalue
- the new value for the field
public EditableDocument setNumber(String name, int value)
EditableDocument
setNumber
in interface EditableDocument
name
- The name of the fieldvalue
- the new value for the field
public EditableDocument setNumber(String name, long value)
EditableDocument
setNumber
in interface EditableDocument
name
- The name of the fieldvalue
- the new value for the field
public EditableDocument setNumber(String name, float value)
EditableDocument
setNumber
in interface EditableDocument
name
- The name of the fieldvalue
- the new value for the field
public EditableDocument setNumber(String name, double value)
EditableDocument
setNumber
in interface EditableDocument
name
- The name of the fieldvalue
- the new value for the field
public EditableDocument setString(String name, String value)
EditableDocument
setString
in interface EditableDocument
name
- The name of the fieldvalue
- the new value for the field
public EditableDocument setSymbol(String name, String value)
EditableDocument
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.
setSymbol
in interface EditableDocument
name
- The name of the fieldvalue
- the new value for the field
EditableDocument.setString(String, String)
public EditableDocument setDocument(String name)
EditableDocument
setDocument
in interface EditableDocument
name
- The name of the field
public EditableDocument setDocument(String name, Document document)
EditableDocument
setDocument
in interface EditableDocument
name
- The name of the fielddocument
- the document
document
.public EditableArray setArray(String name)
EditableDocument
setArray
in interface EditableDocument
name
- The name of the field
public EditableArray setArray(String name, Array array)
EditableDocument
setArray
in interface EditableDocument
name
- The name of the fieldarray
- the array
array
.public EditableArray setArray(String name, Object... values)
EditableDocument
setArray
in interface EditableDocument
name
- The name of the fieldvalues
- the (valid) values for the array
array
.public EditableDocument setDate(String name, Date value)
EditableDocument
setDate
in interface EditableDocument
name
- The name of the fieldvalue
- the new value for the field
public EditableDocument setDate(String name, String isoDate) throws ParseException
EditableDocument
yyyy-MM-ddTHH:mm:ss
" where "T
" is a literal
characteryyyy-MM-ddTHH:mm:ssZ
" where "T
" and "
Z
" are literal charactersyyyy-MM-ddTHH:mm:ssGMT+00:00
" where "
T
", and "GMT
" are literal characters
setDate
in interface EditableDocument
name
- The name of the fieldisoDate
- the new value for the field
ParseException
- if the supplied value could not be parsed into a valid datepublic EditableDocument setTimestamp(String name, int timeInSeconds, int increment)
EditableDocument
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.
setTimestamp
in interface EditableDocument
name
- The name of the fieldtimeInSeconds
- the time in seconds for the new Timestampincrement
- the time increment for the new Timestamp
EditableDocument.setDate(String, Date)
public EditableDocument setObjectId(String name, String hex)
EditableDocument
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" }
setObjectId
in interface EditableDocument
name
- The name of the fieldhex
- the hexadecimal binary value for the ObjectId
EditableDocument.setObjectId(String, byte[])
,
EditableDocument.setObjectId(String, int, int, int, int)
public EditableDocument setObjectId(String name, byte[] bytes)
EditableDocument
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" }
setObjectId
in interface EditableDocument
name
- The name of the fieldbytes
- the 12-byte value for the ObjectId
EditableDocument.setObjectId(String, String)
,
EditableDocument.setObjectId(String, int, int, int, int)
public EditableDocument setObjectId(String name, int time, int machine, int process, int inc)
EditableDocument
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" }
setObjectId
in interface EditableDocument
name
- The name of the fieldtime
- 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 idprocess
- the 2 bytes of the process id (or thread id) of the process generating the object idinc
- an ever incrementing value, or a random number if a counter can't be used in the language/runtime
EditableDocument.setObjectId(String, String)
,
EditableDocument.setObjectId(String, byte[])
public EditableDocument setRegularExpression(String name, String pattern)
EditableDocument
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.
setRegularExpression
in interface EditableDocument
name
- The name of the fieldpattern
- the regular expression pattern string
EditableDocument.setRegularExpression(String, String, int)
public EditableDocument setRegularExpression(String name, String pattern, int flags)
EditableDocument
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.
setRegularExpression
in interface EditableDocument
name
- The name of the fieldpattern
- the regular expression pattern stringflags
- 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
EditableDocument.setRegularExpression(String, String)
public EditableDocument setNull(String name)
EditableDocument
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.
setNull
in interface EditableDocument
name
- The name of the field
Document.isNull(String)
,
Document.isNullOrMissing(String)
public EditableDocument setBinary(String name, byte type, byte[] data)
EditableDocument
{ "$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.
setBinary
in interface EditableDocument
name
- The name of the fieldtype
- one of the BSON type
constants denoting the type of the Binary
valuedata
- the bytes for the Binary
value
public EditableDocument setUuid(String name, UUID uuid)
EditableDocument
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.
setUuid
in interface EditableDocument
name
- The name of the fielduuid
- the UUID value
public EditableDocument setCode(String name, String code, boolean includeScope)
EditableDocument
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.
setCode
in interface EditableDocument
name
- The name of the fieldcode
- the codeincludeScope
- true if the code should include a scope (and if this method should return an EditableDocument
for this scope document), or false otherwise
includeScope
is true
, then the EditableDocument
for the scope; otherwise, this
document to allow for chaining methodsEditableDocument.setCode(String, String, Document)
public EditableDocument setCode(String name, String code, Document scope)
EditableDocument
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.
setCode
in interface EditableDocument
name
- The name of the fieldcode
- the codescope
- the scope in which the JavaScript code should be evaulated, or null if there is no scope
EditableDocument
for the scope, or null if the scope
reference is nullEditableDocument.setCode(String, String, boolean)
protected Object doSetValue(String name, Object value)
set...
methods. This method may be overridden by
subclasses when additional work needs to be performed during the set operations.
name
- the name of the field being setvalue
- the new value
protected Object doSetValueIfAbsent(String name, Object value)
set...
methods. This method may be overridden by
subclasses when additional work needs to be performed during the set operations.
name
- the name of the field being setvalue
- the new value
protected EditableDocument editable(Document doc, String fieldName)
protected EditableArray editable(List<?> array, String fieldName)
protected EditableDocument createEditableDocument(MutableDocument document, String fieldName, DocumentValueFactory factory)
protected EditableArray createEditableArray(MutableArray array, String fieldName, DocumentValueFactory factory)
public static Array unwrap(Array array)
public static Document unwrap(Document document)
public static Object unwrap(Object value)
public String toString()
toString
in class Object
|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |