Class ReplaceAttributeTransformation
- java.lang.Object
-
- com.unboundid.ldap.sdk.transformations.ReplaceAttributeTransformation
-
- All Implemented Interfaces:
EntryTransformation
,LDIFReaderEntryTranslator
,LDIFWriterEntryTranslator
@ThreadSafety(level=COMPLETELY_THREADSAFE) public final class ReplaceAttributeTransformation extends java.lang.Object implements EntryTransformation
This class provides an implementation of an entry transformation that can be used to replace existing attributes in entries with a default set of values. The default attributes will not be added to entries that do not have existing values for the target attributes.
-
-
Constructor Summary
Constructors Constructor Description ReplaceAttributeTransformation(Schema schema, Attribute... attributes)
Creates a new replace attribute transformation that will replace existing copies of the specified attributes with the provided versions.ReplaceAttributeTransformation(Schema schema, java.lang.String attributeName, java.lang.String... newValues)
Creates a new replace attribute transformation that will replace existing values of the specified attribute with the provided set of default values.ReplaceAttributeTransformation(Schema schema, java.lang.String attributeName, java.util.Collection<java.lang.String> newValues)
Creates a new replace attribute transformation that will replace existing values of the specified attribute with the provided set of default values.ReplaceAttributeTransformation(Schema schema, java.util.Collection<Attribute> attributes)
Creates a new replace attribute transformation that will replace existing copies of the specified attributes with the provided versions.
-
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
-
ReplaceAttributeTransformation
public ReplaceAttributeTransformation(@Nullable Schema schema, @NotNull java.lang.String attributeName, @NotNull java.lang.String... newValues)
Creates a new replace attribute transformation that will replace existing values of the specified attribute with the provided set of default values.- Parameters:
schema
- The schema to use to identify alternate names that may be used to reference the attributes to replace. It may benull
to use a default standard schema.attributeName
- The name of the attribute for which to replace existing values. It must not benull
.newValues
- The new values to use in place of the existing values for the specified attribute.
-
ReplaceAttributeTransformation
public ReplaceAttributeTransformation(@Nullable Schema schema, @NotNull java.lang.String attributeName, @NotNull java.util.Collection<java.lang.String> newValues)
Creates a new replace attribute transformation that will replace existing values of the specified attribute with the provided set of default values.- Parameters:
schema
- The schema to use to identify alternate names that may be used to reference the attributes to replace. It may benull
to use a default standard schema.attributeName
- The name of the attribute for which to replace existing values. It must not benull
.newValues
- The new values to use in place of the existing values for the specified attribute.
-
ReplaceAttributeTransformation
public ReplaceAttributeTransformation(@Nullable Schema schema, @NotNull Attribute... attributes)
Creates a new replace attribute transformation that will replace existing copies of the specified attributes with the provided versions.- Parameters:
schema
- The schema to use to identify alternate names that may be used to reference the attributes to replace. It may benull
to use a default standard schema.attributes
- The attributes to be used in place of existing attributes of the same type. It must not benull
or empty.
-
ReplaceAttributeTransformation
public ReplaceAttributeTransformation(@Nullable Schema schema, @NotNull java.util.Collection<Attribute> attributes)
Creates a new replace attribute transformation that will replace existing copies of the specified attributes with the provided versions.- Parameters:
schema
- The schema to use to identify alternate names that may be used to reference the attributes to replace. It may benull
to use a default standard schema.attributes
- The attributes to be used in place of existing attributes of the same type. It must not benull
or empty.
-
-
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.
-
-