Search in sources :

Example 11 with AtlasActionProcessor

use of io.atlasmap.spi.AtlasActionProcessor in project atlasmap by atlasmap.

the class StringComplexFieldActions method replaceAll.

/**
 * Replaces all hits with the regular expression specified as a parameter.
 * @param replaceAll action model
 * @param input source
 * @return processed
 */
@AtlasActionProcessor
public static String replaceAll(ReplaceAll replaceAll, String input) {
    if (replaceAll == null || replaceAll.getMatch() == null || replaceAll.getMatch().isEmpty()) {
        throw new IllegalArgumentException("ReplaceAll action must be specified with a non-empty old string");
    }
    String match = replaceAll.getMatch();
    String newString = replaceAll.getNewString();
    return input == null ? null : input.replaceAll(match, newString == null ? "" : newString);
}
Also used : SubString(io.atlasmap.v2.SubString) AtlasActionProcessor(io.atlasmap.spi.AtlasActionProcessor)

Aggregations

AtlasActionProcessor (io.atlasmap.spi.AtlasActionProcessor)11 SubString (io.atlasmap.v2.SubString)4 ActionProcessor (io.atlasmap.spi.ActionProcessor)2 AtlasConversionException (io.atlasmap.api.AtlasConversionException)1 AtlasException (io.atlasmap.api.AtlasException)1 Expression (io.atlasmap.expression.Expression)1 ExpressionException (io.atlasmap.expression.ExpressionException)1 AtlasFieldAction (io.atlasmap.spi.AtlasFieldAction)1 Action (io.atlasmap.v2.Action)1 ActionDetail (io.atlasmap.v2.ActionDetail)1 AreaUnitType (io.atlasmap.v2.AreaUnitType)1 AtlasModelFactory.unwrapField (io.atlasmap.v2.AtlasModelFactory.unwrapField)1 AtlasModelFactory.wrapWithField (io.atlasmap.v2.AtlasModelFactory.wrapWithField)1 CollectionType (io.atlasmap.v2.CollectionType)1 CustomAction (io.atlasmap.v2.CustomAction)1 DistanceUnitType (io.atlasmap.v2.DistanceUnitType)1 Field (io.atlasmap.v2.Field)1 FieldType (io.atlasmap.v2.FieldType)1 MassUnitType (io.atlasmap.v2.MassUnitType)1 VolumeUnitType (io.atlasmap.v2.VolumeUnitType)1