ModeShape Distribution 3.0.0.Beta4

org.infinispan.schematic.internal.document
Class BasicArray

java.lang.Object
  extended by org.infinispan.schematic.internal.document.BasicArray
All Implemented Interfaces:
Serializable, Iterable<Object>, Collection<Object>, List<Object>, Array, Document, MutableArray, MutableDocument

@SerializeWith(value=DocumentExternalizer.class)
public class BasicArray
extends Object
implements MutableArray

A ordered array of values for use as a value within a BSON Object. Instances of this type are designed to be unmodifiable from a client's perspective, since clients always modify the instances using an editor. There are several internal* methods that do modify the contents, but these may not be used by client applications.

Since BSON and JSON documents can be simple arrays of values, this class implements the Document interface, where the object's names are expected to be string values of integer indexes. This class also implements List interface, but only supports the read methods.

See Also:
Serialized Form

Nested Class Summary
static class BasicArray.BasicEntry
           
protected static class BasicArray.IndexEntry
           
protected static class BasicArray.UnmodifiableListIterator
           
 
Nested classes/interfaces inherited from interface org.infinispan.schematic.document.Array
Array.Entry
 
Nested classes/interfaces inherited from interface org.infinispan.schematic.document.Document
Document.Field, Document.ValueTransformer
 
Constructor Summary
BasicArray()
           
BasicArray(int initialCapacity)
           
BasicArray(List<Object> values)
           
BasicArray(Object... values)
           
 
Method Summary
 void add(int index, Object element)
           
 boolean add(Object e)
           
 boolean addAll(Collection<? extends Object> c)
           
 boolean addAll(int index, Collection<? extends Object> c)
           
 boolean addAllValues(Collection<?> values)
          Modifiable method that adds the supplied values at the end of this array.
 boolean addAllValues(int index, Collection<?> values)
          Modifiable method that adds the supplied values at the supplied index, shifting any existing values to the next higher index value.
 void addValue(int index, Object value)
          Modifiable method that adds the supplied value at the supplied index, shifting any existing values to the next higher index value.
 int addValue(Object value)
          Modifiable method that adds the supplied value.
 boolean addValueIfAbsent(Object value)
          Modifiable method that adds the supplied value if not already in the array.
 void clear()
           
 Array clone()
          Obtain a clone of this array.
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 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.
 boolean equals(Object obj)
           
 Iterable<Document.Field> fields()
          Obtain an iterator over the Document.Fields in this object.
 Object get(int index)
           
 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.
 Iterable<Array.Entry> getEntries()
          Get the entries in this array.
 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.
 int hashCode()
           
protected  int indexFrom(String name)
           
 int indexOf(Object o)
           
 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.
protected  boolean isValidIndex(int index)
           
 Iterator<Object> iterator()
           
 Set<String> keySet()
          Returns this object's fields' names
 int lastIndexOf(Object o)
           
 ListIterator<Object> listIterator()
           
 ListIterator<Object> listIterator(int index)
           
protected  Object put(int index, Object value)
           
 Object put(String name, Object value)
          Sets a name/value pair in this object.
 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(int index)
           
 boolean remove(Object o)
           
 Object remove(String name)
          Removes from this object the name/value pair with the given name.
 void removeAll()
          Modifiable method that removes all of the values from this array.
 boolean removeAll(Collection<?> c)
           
 List<Array.Entry> removeAllValues(Collection<?> valuesToBeRemoved)
          Modifiable method that removes all of the supplied values from this array.
 Object removeValue(int index)
          Modifiable method that removes the value at the supplied index.
 boolean removeValue(Object value)
          Modifiable method that removes the supplied value.
 boolean retainAll(Collection<?> c)
           
 List<Array.Entry> retainAllValues(Collection<?> valuesToBeRetained)
          Modifiable method that removes all of the values in this array except the supplied values.
 Object set(int index, Object element)
           
 Object setValue(int index, Object value)
          Modifiable method that sets the supplied value at the given index.
 int size()
          Return the number of name-value pairs in this object.
 List<Object> subList(int fromIndex, int toIndex)
           
 Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 Map<String,?> toMap()
          Returns a map representing this BSONObject.
 String toString()
           
protected  Object unwrap(Object value)
           
 Array with(Document.ValueTransformer transformer)
          Obtain a clone of this document, but with the field values transformed using the supplied Document.ValueTransformer.
 Array with(Map<String,Object> changedFields)
          Obtain a clone of this document, but with the supplied fields replaced.
 Array 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.
 Array 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
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicArray

public BasicArray()

BasicArray

public BasicArray(int initialCapacity)

BasicArray

public BasicArray(List<Object> values)

BasicArray

public BasicArray(Object... values)
Method Detail

get

public Object get(String name)
Description copied from interface: Document
Gets the value in this document for the given field name.

Specified by:
get in interface Document
Parameters:
name - The name of the pair
Returns:
The field value, if found, or null otherwise

containsField

public boolean containsField(String name)
Description copied from interface: Document
Checks if this object contains a field with the given name.

Specified by:
containsField in interface Document
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

public boolean containsAll(Document document)
Description copied from interface: Document
Checks if this object contains all of the fields in the supplied document.

Specified by:
containsAll in interface 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

public Set<String> keySet()
Description copied from interface: Document
Returns this object's fields' names

Specified by:
keySet in interface Document
Returns:
The names of the fields in this object

toMap

public Map<String,?> toMap()
Description copied from interface: Document
Returns a map representing this BSONObject.

Specified by:
toMap in interface Document
Returns:
the map

fields

public Iterable<Document.Field> fields()
Description copied from interface: Document
Obtain an iterator over the Document.Fields in this object.

Specified by:
fields in interface Document
Returns:
a field iterator; never null

size

public int size()
Description copied from interface: Document
Return the number of name-value pairs in this object.

Specified by:
size in interface Collection<Object>
Specified by:
size in interface List<Object>
Specified by:
size in interface Document
Returns:
the number of name-value pairs; never negative

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<Object>
Specified by:
contains in interface List<Object>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<Object>
Specified by:
containsAll in interface List<Object>

get

public Object get(int index)
Specified by:
get in interface List<Object>

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<Object>
Specified by:
hashCode in interface List<Object>
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Specified by:
equals in interface Collection<Object>
Specified by:
equals in interface List<Object>
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List<Object>

isEmpty

public boolean isEmpty()
Description copied from interface: Document
Return whether this document contains no fields and is therefore empty.

Specified by:
isEmpty in interface Collection<Object>
Specified by:
isEmpty in interface List<Object>
Specified by:
isEmpty in interface Document
Returns:
true if there are no fields in this document, or false if there is at least one.

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List<Object>

subList

public List<Object> subList(int fromIndex,
                            int toIndex)
Specified by:
subList in interface List<Object>

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<Object>
Specified by:
toArray in interface List<Object>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface Collection<Object>
Specified by:
toArray in interface List<Object>

iterator

public Iterator<Object> iterator()
Specified by:
iterator in interface Iterable<Object>
Specified by:
iterator in interface Collection<Object>
Specified by:
iterator in interface List<Object>

getEntries

public Iterable<Array.Entry> getEntries()
Description copied from interface: Array
Get the entries in this array.

Specified by:
getEntries in interface Array
Returns:
an iterable containing the array's entries; never null

getBoolean

public Boolean getBoolean(String name)
Description copied from interface: Document
Get the boolean value in this document for the given field name.

Specified by:
getBoolean in interface Document
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

public boolean getBoolean(String name,
                          boolean defaultValue)
Description copied from interface: Document
Get the boolean value in this document for the given field name.

Specified by:
getBoolean in interface Document
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

public Integer getInteger(String name)
Description copied from interface: Document
Get the integer value in this document for the given field name.

Specified by:
getInteger in interface Document
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

public int getInteger(String name,
                      int defaultValue)
Description copied from interface: Document
Get the integer value in this document for the given field name.

Specified by:
getInteger in interface Document
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

public Long getLong(String name)
Description copied from interface: Document
Get the integer value in this document for the given field name.

Specified by:
getLong in interface Document
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

public long getLong(String name,
                    long defaultValue)
Description copied from interface: Document
Get the long value in this document for the given field name.

Specified by:
getLong in interface Document
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

public Double getDouble(String name)
Description copied from interface: Document
Get the double value in this document for the given field name.

Specified by:
getDouble in interface Document
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

public double getDouble(String name,
                        double defaultValue)
Description copied from interface: Document
Get the double value in this document for the given field name.

Specified by:
getDouble in interface Document
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

public Number getNumber(String name)
Description copied from interface: Document
Get the number value in this document for the given field name.

Specified by:
getNumber in interface Document
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

public Number getNumber(String name,
                        Number defaultValue)
Description copied from interface: Document
Get the number value in this document for the given field name.

Specified by:
getNumber in interface Document
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

public String getString(String name)
Description copied from interface: Document
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.

Specified by:
getString in interface Document
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

public String getString(String name,
                        String defaultValue)
Description copied from interface: Document
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.

Specified by:
getString in interface Document
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

public List<?> getArray(String name)
Description copied from interface: Document
Get the 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 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

public Document getDocument(String name)
Description copied from interface: Document
Get the 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 document field value, if found, or null if there is no such pair or if the value is not a document

isNull

public boolean isNull(String name)
Description copied from interface: Document
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;
 

Specified by:
isNull in interface Document
Parameters:
name - The name of the pair
Returns:
true if the field has been set to a Null value, or false otherwise
See Also:
Document.isNullOrMissing(String)

isNullOrMissing

public boolean isNullOrMissing(String name)
Description copied from interface: Document
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));
 

Specified by:
isNullOrMissing in interface Document
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:
Document.isNull(String)

getMaxKey

public MaxKey getMaxKey(String name)
Description copied from interface: Document
Get the MaxKey value in this document for the given field name.

Specified by:
getMaxKey in interface Document
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

public MinKey getMinKey(String name)
Description copied from interface: Document
Get the MinKey value in this document for the given field name.

Specified by:
getMinKey in interface Document
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

public Code getCode(String name)
Description copied from interface: Document
Get the Code value in this document for the given field name.

Specified by:
getCode in interface Document
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

public CodeWithScope getCodeWithScope(String name)
Description copied from interface: Document
Get the CodeWithScope value in this document for the given field name.

Specified by:
getCodeWithScope in interface Document
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

public ObjectId getObjectId(String name)
Description copied from interface: Document
Get the ObjectId value in this document for the given field name.

Specified by:
getObjectId in interface Document
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

public Binary getBinary(String name)
Description copied from interface: Document
Get the Binary value in this document for the given field name.

Specified by:
getBinary in interface Document
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

public Symbol getSymbol(String name)
Description copied from interface: Document
Get the Symbol value in this document for the given field name.

Specified by:
getSymbol in interface Document
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

public Pattern getPattern(String name)
Description copied from interface: Document
Get the Pattern value in this document for the given field name.

Specified by:
getPattern in interface Document
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

public UUID getUuid(String name)
Description copied from interface: Document
Get the UUID value in this document for the given field name.

Specified by:
getUuid in interface Document
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

public UUID getUuid(String name,
                    UUID defaultValue)
Description copied from interface: Document
Get the UUID value in this document for the given field name.

Specified by:
getUuid in interface Document
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

public int getType(String name)
Description copied from interface: Document
Get the Bson.Type constant that describes the type of value for the given field name.

Specified by:
getType in interface Document
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

listIterator

public ListIterator<Object> listIterator()
Specified by:
listIterator in interface List<Object>

listIterator

public ListIterator<Object> listIterator(int index)
Specified by:
listIterator in interface List<Object>

add

public void add(int index,
                Object element)
Specified by:
add in interface List<Object>

add

public boolean add(Object e)
Specified by:
add in interface Collection<Object>
Specified by:
add in interface List<Object>

addAll

public boolean addAll(Collection<? extends Object> c)
Specified by:
addAll in interface Collection<Object>
Specified by:
addAll in interface List<Object>

addAll

public boolean addAll(int index,
                      Collection<? extends Object> c)
Specified by:
addAll in interface List<Object>

clear

public void clear()
Specified by:
clear in interface Collection<Object>
Specified by:
clear in interface List<Object>

remove

public Object remove(int index)
Specified by:
remove in interface List<Object>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<Object>
Specified by:
remove in interface List<Object>

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<Object>
Specified by:
removeAll in interface List<Object>

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<Object>
Specified by:
retainAll in interface List<Object>

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List<Object>

indexFrom

protected final int indexFrom(String name)

isValidIndex

protected final boolean isValidIndex(int index)

unwrap

protected Object unwrap(Object value)

addValueIfAbsent

public boolean addValueIfAbsent(Object value)
Description copied from interface: MutableArray
Modifiable method that adds the supplied value if not already in the array. This method should not be called by client code.

Specified by:
addValueIfAbsent in interface MutableArray
Parameters:
value - the value to be added
Returns:
true if the value was added, or false if the value was already in the array.

addValue

public int addValue(Object value)
Description copied from interface: MutableArray
Modifiable method that adds the supplied value. This method should not be called by client code.

Specified by:
addValue in interface MutableArray
Parameters:
value - the value to be added
Returns:
the index at which the value was added, or -1 if the value could not be added

addValue

public void addValue(int index,
                     Object value)
Description copied from interface: MutableArray
Modifiable method that adds the supplied value at the supplied index, shifting any existing values to the next higher index value. This method should not be called by client code.

Specified by:
addValue in interface MutableArray
Parameters:
index - the index
value - the value to be added

setValue

public Object setValue(int index,
                       Object value)
Description copied from interface: MutableArray
Modifiable method that sets the supplied value at the given index. This method should not be called by client code.

Specified by:
setValue in interface MutableArray
Parameters:
index - the index
value - the value to be added
Returns:
true if the value was added, or false if it could not be added

removeValue

public boolean removeValue(Object value)
Description copied from interface: MutableArray
Modifiable method that removes the supplied value. This method should not be called by client code.

Specified by:
removeValue in interface MutableArray
Parameters:
value - the value to be removed
Returns:
true if the value was removed, or false if the value was not in the array

removeValue

public Object removeValue(int index)
Description copied from interface: MutableArray
Modifiable method that removes the value at the supplied index. This method should not be called by client code.

Specified by:
removeValue in interface MutableArray
Parameters:
index - the index of the value to be removed
Returns:
the value that was at the index

addAllValues

public boolean addAllValues(Collection<?> values)
Description copied from interface: MutableArray
Modifiable method that adds the supplied values at the end of this array. This method should not be called by client code.

Specified by:
addAllValues in interface MutableArray
Parameters:
values - the values to be added
Returns:
true if this array changed as a result of the operation

addAllValues

public boolean addAllValues(int index,
                            Collection<?> values)
Description copied from interface: MutableArray
Modifiable method that adds the supplied values at the supplied index, shifting any existing values to the next higher index value. This method should not be called by client code.

Specified by:
addAllValues in interface MutableArray
Parameters:
index - the index at which the values are to be inserted
values - the values to be added
Returns:
true if this array changed as a result of the operation

removeAllValues

public List<Array.Entry> removeAllValues(Collection<?> valuesToBeRemoved)
Description copied from interface: MutableArray
Modifiable method that removes all of the supplied values from this array. This method should not be called by client code.

Specified by:
removeAllValues in interface MutableArray
Parameters:
valuesToBeRemoved - the values to be removed
Returns:
the entries that were removed; never null but possibly empty if this array was not modified by this operation

retainAllValues

public List<Array.Entry> retainAllValues(Collection<?> valuesToBeRetained)
Description copied from interface: MutableArray
Modifiable method that removes all of the values in this array except the supplied values. This method should not be called by client code.

Specified by:
retainAllValues in interface MutableArray
Parameters:
valuesToBeRetained - the values to be kept, while all others are removed
Returns:
the entries that were removed; never null but possibly empty if this array was not modified by this operation

remove

public Object remove(String name)
Description copied from interface: MutableDocument
Removes from this object the name/value pair with the given name.

Specified by:
remove in interface MutableDocument
Parameters:
name - The name of the pair to remove
Returns:
The value removed from this object, or null this object does not contain a pair with the supplied name

removeAll

public void removeAll()
Description copied from interface: MutableArray
Modifiable method that removes all of the values from this array. This method should not be called by client code.

Specified by:
removeAll in interface MutableArray
Specified by:
removeAll in interface MutableDocument

put

public Object put(String name,
                  Object value)
Description copied from interface: MutableDocument
Sets a name/value pair in this object.

Specified by:
put in interface MutableDocument
Parameters:
name - The name; may not be null
value - The value; may be null
Returns:
the previous value

put

protected final Object put(int index,
                           Object value)

putAll

public void putAll(Document object)
Description copied from interface: MutableDocument
Sets on this object all name/value pairs from the supplied object. If the supplied object is null, this method does nothing.

Specified by:
putAll in interface MutableDocument
Parameters:
object - the object containing the name/value pairs to be set on this object

putAll

public void putAll(Map<? extends String,? extends Object> map)
Description copied from interface: MutableDocument
Sets on this object all key/value pairs from the supplied map. If the supplied map is null, this method does nothing.

Specified by:
putAll in interface MutableDocument
Parameters:
map - the map containing the name/value pairs to be set on this object

clone

public Array clone()
Description copied from interface: Array
Obtain a clone of this array.

Specified by:
clone in interface Array
Specified by:
clone in interface Document
Overrides:
clone in class Object
Returns:
the clone of this array; never null

with

public Array with(Map<String,Object> changedFields)
Description copied from interface: Document
Obtain a clone of this document, but with the supplied fields replaced.

Specified by:
with in interface Document
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

public Array with(Document.ValueTransformer transformer)
Description copied from interface: Document
Obtain a clone of this document, but with the field values transformed using the supplied Document.ValueTransformer.

Specified by:
with in interface Document
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

public Array withVariablesReplaced(Properties properties)
Description copied from interface: Document
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.

Specified by:
withVariablesReplaced in interface Document
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:
Document.withVariablesReplacedWithSystemProperties(), Document.with(ValueTransformer), SchemaLibrary.convertValues(Document, String)

withVariablesReplacedWithSystemProperties

public Array withVariablesReplacedWithSystemProperties()
Description copied from interface: Document
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.

Specified by:
withVariablesReplacedWithSystemProperties in interface Document
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:
Document.withVariablesReplaced(Properties), Document.with(ValueTransformer), SchemaLibrary.convertValues(Document, String)

ModeShape Distribution 3.0.0.Beta4

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