Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0002306: Add a trim() column transform
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/transform/TrimColumnTransform.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.jumpmind.symmetric.io.data.transform; | ||
|
||
import java.util.Map; | ||
|
||
import org.jumpmind.db.platform.IDatabasePlatform; | ||
import org.jumpmind.extension.IBuiltInExtensionPoint; | ||
import org.jumpmind.symmetric.io.data.DataContext; | ||
|
||
public class TrimColumnTransform implements ISingleNewAndOldValueColumnTransform, IBuiltInExtensionPoint { | ||
|
||
public static final String NAME = "trim"; | ||
|
||
public String getName() { | ||
return NAME; | ||
} | ||
|
||
public boolean isExtractColumnTransform() { | ||
return true; | ||
} | ||
|
||
public boolean isLoadColumnTransform() { | ||
return true; | ||
} | ||
|
||
public NewAndOldValue transform(IDatabasePlatform platform, DataContext context, | ||
TransformColumn column, TransformedData data, Map<String, String> sourceValues, String newValue, String oldValue) | ||
throws IgnoreColumnException, IgnoreRowException { | ||
if (newValue != null) { | ||
newValue = newValue.trim(); | ||
} | ||
if (oldValue != null) { | ||
oldValue = oldValue.trim(); | ||
} | ||
return new NewAndOldValue(newValue, oldValue); | ||
} | ||
|
||
} |