Class ReplaceWithCounterTransformation
- java.lang.Object
-
- com.unboundid.ldap.sdk.transformations.ReplaceWithCounterTransformation
-
- All Implemented Interfaces:
EntryTransformation
,LDIFReaderEntryTranslator
,LDIFWriterEntryTranslator
@ThreadSafety(level=COMPLETELY_THREADSAFE) public final class ReplaceWithCounterTransformation extends java.lang.Object implements EntryTransformation
This class provides an implementation of an entry transformation that will replace the existing set of values for a given attribute with a value that contains a numeric counter (optionally along with additional static text) that increments for each entry that contains the target attribute. The resulting attribute will only have a single value, even if it originally had multiple values.
-
-
Constructor Summary
Constructors Constructor Description ReplaceWithCounterTransformation(Schema schema, java.lang.String attributeName, long initialValue, long incrementAmount, java.lang.String beforeText, java.lang.String afterText, boolean replaceInRDN)
Creates a new replace with counter transformation using 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
-
ReplaceWithCounterTransformation
public ReplaceWithCounterTransformation(Schema schema, java.lang.String attributeName, long initialValue, long incrementAmount, java.lang.String beforeText, java.lang.String afterText, boolean replaceInRDN)
Creates a new replace with counter transformation using the provided information.- Parameters:
schema
- The schema to use to identify alternate names for the target attribute. This may benull
if a default standard schema should be used.attributeName
- The name of the attribute that should be replaced with the generated value.initialValue
- The initial value to use for the counter.incrementAmount
- The amount by which the counter should be incremented for each entry containing the target attribute.beforeText
- An optional string that should appear before the counter in generated values. It may benull
if no before text should be used.afterText
- An optional string that should appear after the counter in generated values. It may benull
if no after text should be used.replaceInRDN
- Indicates whether to update the DN of the target entry if its RDN includes the target attribute.
-
-
Method Detail
-
transformEntry
public Entry transformEntry(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
public Entry translate(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
public Entry translateEntryToWrite(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.
-
-