Package io.debezium.connector.mongodb
Class FieldSelector.Path
java.lang.Object
io.debezium.connector.mongodb.FieldSelector.Path
- Direct Known Subclasses:
FieldSelector.RemovePath,FieldSelector.RenamePath
- Enclosing class:
- FieldSelector
Represents a field that should be excluded from or renamed in MongoDB documents.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate <T> List<T>(package private) StringcheckFieldExists(Map<String, Object> doc, String field) private String[]excludeNumericItems(String[] items) Excludes numeric items from the given array.(package private) abstract StringgenerateNewFieldName(String fieldName) Generates a new field name.(package private) abstract FieldSelector.FieldNameAndValuegenerateNewFieldName(String[] fieldNodes, Object value) Generates a new field name for the given value.booleanWhether this path applies to the given collection namespace or not.booleanmatchesPath(String other) Verifies whether a parameter representing path is the same or belongs under this path.voidApplies the transformation represented by this path, i.e.(package private) abstract voidmodifyField(Map<String, Object> doc, String field) Modifies the field in the document used for read, insert and full update operations.private voidmodifyFields(Object value, String[] fieldNodes, int length) private voidmodifyFields(Map<String, Object> doc, String[] nodes, int beginIndex) Modifies fields in the document by the given path nodes start with the begin index.private voidModifies fields that use the dot notation, like'a.b'or'a.0.b'.(package private) abstract voidmodifyFieldWithDotNotation(Map<String, Object> 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 booleanstartsWith(String[] begin, String[] source) Returnstrueif the source array starts with the specified array.toString()
-
Field Details
-
namespacePattern
-
fieldNodes
-
field
-
-
Constructor Details
-
Path
-
-
Method Details
-
matches
Whether this path applies to the given collection namespace or not.- Parameters:
namespace- namespace to match- Returns:
trueif this path applies to the given collection namespace
-
modify
Applies the transformation represented by this path, i.e. removes or renames the represented field.- Parameters:
doc- the original document; nevernullsetDoc- the value of$setfield; may benullunsetDoc- the value of$unsetfield; may benull
-
modifyFields
Modifies fields in the document by the given path nodes start with the begin index.Note that the path doesn't support modification of fields inside arrays of arrays.
- Parameters:
doc- the document to modify fieldsnodes- the path nodesbeginIndex- the begin index
-
modifyFieldsWithDotNotation
Modifies fields that use the dot notation, like'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.
- Parameters:
doc- the document to modify fields
-
modifyFields
-
excludeNumericItems
Excludes numeric items from the given array.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.- Parameters:
items- the array to exclude numeric items- Returns:
- filtered items
-
startsWith
Returnstrueif the source array starts with the specified array.- Parameters:
begin- the array from which the source array beginssource- the source array to check- Returns:
trueif the source array starts with the specified array
-
add
-
checkFieldExists
-
modifyField
Modifies the field in the document used for read, insert and full update operations.- Parameters:
doc- the document to modify fieldfield- the modified field
-
modifyFieldWithDotNotation
Immediately modifies the field that uses the dot notation like'a.b'in the document used for set and unset update operations.- Parameters:
doc- the document to modify fieldfield- the modified field
-
generateNewFieldName
Generates a new field name for the given value.- Parameters:
fieldNodes- the field nodesvalue- the field value- Returns:
- a new field name for the given value
-
generateNewFieldName
Generates a new field name.- Parameters:
fieldName- the original field name- Returns:
- a new field name
-
matchesPath
Verifies whether a parameter representing path is the same or belongs under this path.- Parameters:
other- - the string representing the other path- Returns:
- - true if this path is the same or parent of the path passed
-
toString
-