Class AddAttributeTransformation
- java.lang.Object
-
- com.unboundid.ldap.sdk.transformations.AddAttributeTransformation
-
- All Implemented Interfaces:
EntryTransformation
,LDIFReaderEntryTranslator
,LDIFWriterEntryTranslator
@ThreadSafety(level=COMPLETELY_THREADSAFE) public final class AddAttributeTransformation extends java.lang.Object implements EntryTransformation
This class provides an implementation of an entry transformation that will add a specified attribute with a given set of values to any entry that does not already contain that attribute and matches a specified set of criteria.
-
-
Constructor Summary
Constructors Constructor Description AddAttributeTransformation(Schema schema, DN baseDN, SearchScope scope, Filter filter, Attribute attributeToAdd, boolean onlyIfMissing)
Creates a new add attribute transformation with the provided information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Entry
transformEntry(Entry e)
Applies an appropriate transformation to the provided entry.Entry
translate(Entry original, long firstLineNumber)
Applies some special transformation or filtering to the original Entry.Entry
translateEntryToWrite(Entry original)
Applies some special transformation or filtering to the original Entry.
-
-
-
Constructor Detail
-
AddAttributeTransformation
public AddAttributeTransformation(@Nullable Schema schema, @Nullable DN baseDN, @Nullable SearchScope scope, @Nullable Filter filter, @NotNull Attribute attributeToAdd, boolean onlyIfMissing)
Creates a new add attribute transformation with the provided information.- Parameters:
schema
- The schema to use in processing. It may benull
if a default standard schema should be used.baseDN
- The base DN to use to identify which entries to update. If this isnull
, it will be assumed to be the null DN.scope
- The scope to use to identify which entries to update. If this isnull
, it will be assumed to beSearchScope.SUB
.filter
- An optional filter to use to identify which entries to update. If this isnull
, then a default LDAP true filter (which will match any entry) will be used.attributeToAdd
- The attribute to add to entries that match the criteria and do not already contain any values for the specified attribute. It must not benull
.onlyIfMissing
- Indicates whether the attribute should only be added to entries that do not already contain it. If this isfalse
and an entry that matches the base, scope, and filter criteria and already has one or more values for the target attribute will be updated to include the new values in addition to the existing values.
-
-
Method Detail
-
transformEntry
@Nullable public Entry transformEntry(@NotNull Entry e)
Applies an appropriate transformation to the provided entry.- Specified by:
transformEntry
in interfaceEntryTransformation
- Parameters:
e
- The entry to transform.- Returns:
- A copy of the entry with any appropriate transformation applied,
the original entry if no transformations were necessary, or
null
if the entry should be suppressed.
-
translate
@Nullable public Entry translate(@NotNull Entry original, long firstLineNumber)
Applies some special transformation or filtering to the original Entry.- Specified by:
translate
in interfaceLDIFReaderEntryTranslator
- Parameters:
original
- The original Entry that was read and parsed from the input file.firstLineNumber
- The first line number of the LDIF record corresponding to the read Entry. This is most useful when throwing an LDIFException.- Returns:
- The Entry that should be returned in the call to
LDIFReader.readEntry()
. This can be the original parameter Entry, a newly constructed Entry, ornull
to signal that the provided Entry should be skipped.
-
translateEntryToWrite
@Nullable public Entry translateEntryToWrite(@NotNull Entry original)
Applies some special transformation or filtering to the original Entry.- Specified by:
translateEntryToWrite
in interfaceLDIFWriterEntryTranslator
- Parameters:
original
- The original Entry that was to be written.- Returns:
- The Entry that should be written. This can be the original
parameter Entry, a newly-constructed Entry, or
null
to signal that this Entry should not be written. Note, however, that if the original entry provided as a parameter is altered, then the change will be visible to anything that references that entry. If you are not sure about whether changes to the original entry are acceptable, it is recommended that you use theduplicate()
method to create a copy of the original and make the necessary changes to that duplicate.
-
-