@ThreadSafe private abstract static class FieldSelector.Path extends Object
| Modifier and Type | Field and Description |
|---|---|
(package private) String |
field |
(package private) String[] |
fieldNodes |
(package private) Pattern |
namespacePattern |
| Modifier | Constructor and Description |
|---|---|
private |
Path(Pattern namespacePattern,
String[] fieldNodes) |
| Modifier and Type | Method and Description |
|---|---|
private <T> List<T> |
add(List<T> list,
T element) |
(package private) String |
checkFieldExists(org.bson.Document doc,
String field) |
private String[] |
excludeNumericItems(String[] items)
Excludes numeric items from the given array.
|
(package private) abstract FieldSelector.FieldNameAndValue |
generateNewFieldName(String[] fieldNodes,
Object value)
Generates a new field name for the given value.
|
boolean |
matches(String namespace)
Whether this path applies to the given collection namespace or not.
|
void |
modify(org.bson.Document doc,
org.bson.Document setDoc,
org.bson.Document unsetDoc)
Applies the transformation represented by this path, i.e.
|
(package private) abstract void |
modifyField(org.bson.Document doc,
String field)
Modifies the field in the document used for read, insert and full update operations.
|
private void |
modifyFields(org.bson.Document doc,
String[] nodes,
int beginIndex)
Modifies fields in the document by the given path nodes start with the begin index.
|
private void |
modifyFields(Object value,
String[] fieldNodes,
int length) |
private void |
modifyFieldsWithDotNotation(org.bson.Document doc)
Modifies fields that use the dot notation, like
'a.b' or 'a.0.b'. |
(package private) abstract void |
modifyFieldWithDotNotation(org.bson.Document doc,
String field)
Immediately modifies the field that uses the dot notation like
'a.b' in the document used for set and
unset update operations. |
private boolean |
startsWith(String[] begin,
String[] source)
Returns
true if the source array starts with the specified array. |
String |
toString() |
final Pattern namespacePattern
final String[] fieldNodes
final String field
public boolean matches(String namespace)
namespace - namespace to matchtrue if this path applies to the given collection namespacepublic void modify(org.bson.Document doc,
org.bson.Document setDoc,
org.bson.Document unsetDoc)
doc - the original document; never nullsetDoc - the value of $set field; may be nullunsetDoc - the value of $unset field; may be nullprivate void modifyFields(org.bson.Document doc,
String[] nodes,
int beginIndex)
Note that the path doesn't support modification of fields inside arrays of arrays.
doc - the document to modify fieldsnodes - the path nodesbeginIndex - the begin indexprivate void modifyFieldsWithDotNotation(org.bson.Document doc)
'a.b' or 'a.0.b'.
First, we try to modify field that exactly matches the current path. Then, if the field isn't found, we try to find fields that start with the current path or fields that are part of the current path.
doc - the document to modify fieldsprivate String[] excludeNumericItems(String[] items)
If the array has consecutive numeric items, like 'a.0.0.b', then the numeric items aren't excluded.
It is necessary because the modification of fields inside arrays of arrays isn't supported.
items - the array to exclude numeric itemsprivate boolean startsWith(String[] begin, String[] source)
true if the source array starts with the specified array.begin - the array from which the source array beginssource - the source array to checktrue if the source array starts with the specified arrayabstract void modifyField(org.bson.Document doc,
String field)
doc - the document to modify fieldfield - the modified fieldabstract void modifyFieldWithDotNotation(org.bson.Document doc,
String field)
'a.b' in the document used for set and
unset update operations.doc - the document to modify fieldfield - the modified fieldabstract FieldSelector.FieldNameAndValue generateNewFieldName(String[] fieldNodes, Object value)
fieldNodes - the field nodesvalue - the field valueCopyright © 2019 JBoss by Red Hat. All rights reserved.