|
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.BasicArray
@SerializeWith(value=DocumentExternalizer.class) public class BasicArray
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.
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.Field s 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()
|
|
|
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 |
---|
public BasicArray()
public BasicArray(int initialCapacity)
public BasicArray(List<Object> values)
public BasicArray(Object... values)
Method Detail |
---|
public Object get(String name)
Document
get
in interface Document
name
- The name of the pair
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 Map<String,?> toMap()
Document
toMap
in interface Document
public Iterable<Document.Field> fields()
Document
Document.Field
s in this object.
fields
in interface Document
public int size()
Document
size
in interface Collection<Object>
size
in interface List<Object>
size
in interface Document
public boolean contains(Object o)
contains
in interface Collection<Object>
contains
in interface List<Object>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<Object>
containsAll
in interface List<Object>
public Object get(int index)
get
in interface List<Object>
public int hashCode()
hashCode
in interface Collection<Object>
hashCode
in interface List<Object>
hashCode
in class Object
public boolean equals(Object obj)
equals
in interface Collection<Object>
equals
in interface List<Object>
equals
in class Object
public String toString()
toString
in class Object
public int indexOf(Object o)
indexOf
in interface List<Object>
public boolean isEmpty()
Document
isEmpty
in interface Collection<Object>
isEmpty
in interface List<Object>
isEmpty
in interface Document
public int lastIndexOf(Object o)
lastIndexOf
in interface List<Object>
public List<Object> subList(int fromIndex, int toIndex)
subList
in interface List<Object>
public Object[] toArray()
toArray
in interface Collection<Object>
toArray
in interface List<Object>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<Object>
toArray
in interface List<Object>
public Iterator<Object> iterator()
iterator
in interface Iterable<Object>
iterator
in interface Collection<Object>
iterator
in interface List<Object>
public Iterable<Array.Entry> getEntries()
Array
getEntries
in interface Array
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 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 List<?> getArray(String name)
Document
getArray
in interface Document
name
- The name of the pair
public Document getDocument(String name)
Document
getDocument
in interface Document
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 ListIterator<Object> listIterator()
listIterator
in interface List<Object>
public ListIterator<Object> listIterator(int index)
listIterator
in interface List<Object>
public void add(int index, Object element)
add
in interface List<Object>
public boolean add(Object e)
add
in interface Collection<Object>
add
in interface List<Object>
public boolean addAll(Collection<? extends Object> c)
addAll
in interface Collection<Object>
addAll
in interface List<Object>
public boolean addAll(int index, Collection<? extends Object> c)
addAll
in interface List<Object>
public void clear()
clear
in interface Collection<Object>
clear
in interface List<Object>
public Object remove(int index)
remove
in interface List<Object>
public boolean remove(Object o)
remove
in interface Collection<Object>
remove
in interface List<Object>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<Object>
removeAll
in interface List<Object>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<Object>
retainAll
in interface List<Object>
public Object set(int index, Object element)
set
in interface List<Object>
protected final int indexFrom(String name)
protected final boolean isValidIndex(int index)
protected Object unwrap(Object value)
public boolean addValueIfAbsent(Object value)
MutableArray
addValueIfAbsent
in interface MutableArray
value
- the value to be added
public int addValue(Object value)
MutableArray
addValue
in interface MutableArray
value
- the value to be added
public void addValue(int index, Object value)
MutableArray
addValue
in interface MutableArray
index
- the indexvalue
- the value to be addedpublic Object setValue(int index, Object value)
MutableArray
setValue
in interface MutableArray
index
- the indexvalue
- the value to be added
public boolean removeValue(Object value)
MutableArray
removeValue
in interface MutableArray
value
- the value to be removed
public Object removeValue(int index)
MutableArray
removeValue
in interface MutableArray
index
- the index of the value to be removed
public boolean addAllValues(Collection<?> values)
MutableArray
addAllValues
in interface MutableArray
values
- the values to be added
public boolean addAllValues(int index, Collection<?> values)
MutableArray
addAllValues
in interface MutableArray
index
- the index at which the values are to be insertedvalues
- the values to be added
public List<Array.Entry> removeAllValues(Collection<?> valuesToBeRemoved)
MutableArray
removeAllValues
in interface MutableArray
valuesToBeRemoved
- the values to be removed
public List<Array.Entry> retainAllValues(Collection<?> valuesToBeRetained)
MutableArray
retainAllValues
in interface MutableArray
valuesToBeRetained
- the values to be kept, while all others are removed
public Object remove(String name)
MutableDocument
remove
in interface MutableDocument
name
- The name of the pair to remove
public void removeAll()
MutableArray
removeAll
in interface MutableArray
removeAll
in interface MutableDocument
public Object put(String name, Object value)
MutableDocument
put
in interface MutableDocument
name
- The name; may not be nullvalue
- The value; may be null
protected final Object put(int index, Object value)
public void putAll(Document object)
MutableDocument
putAll
in interface MutableDocument
object
- the object containing the name/value pairs to be set on this objectpublic void putAll(Map<? extends String,? extends Object> map)
MutableDocument
putAll
in interface MutableDocument
map
- the map containing the name/value pairs to be set on this objectpublic Array clone()
Array
clone
in interface Array
clone
in interface Document
clone
in class Object
public Array with(Map<String,Object> changedFields)
Document
with
in interface Document
changedFields
- the fields that should be changed; may be null
public Array 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 Array 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 Array 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)
|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |