use of io.atlasmap.spi.AtlasActionProcessor in project atlasmap by atlasmap.
the class StringComplexFieldActions method split.
/**
* Splits the String with the specified delimiter.
* @param split action model
* @param input source
* @return splitted
*/
@AtlasActionProcessor(sourceType = FieldType.ANY)
public static String[] split(Split split, String input) {
if (split == null || split.getDelimiter() == null) {
throw new IllegalArgumentException("Split must be specified with a delimiter");
}
String quotedDelimiter = Pattern.quote(split.getDelimiter());
boolean collapseRepeatingDelimiter = split.getCollapseRepeatingDelimiters() == null ? false : split.getCollapseRepeatingDelimiters();
if (collapseRepeatingDelimiter) {
quotedDelimiter = "(" + quotedDelimiter + ")+";
}
return input == null ? null : input.toString().split(quotedDelimiter);
}
use of io.atlasmap.spi.AtlasActionProcessor in project atlasmap by atlasmap.
the class StringComplexFieldActions method concatenate.
/**
* Concatenates a list of String.
* @param concat action model
* @param inputs a list of source String
* @return processed
*/
@AtlasActionProcessor(sourceType = FieldType.ANY)
public static String concatenate(Concatenate concat, List<String> inputs) {
if (concat == null) {
throw new IllegalArgumentException("Concatenate must be specified with a delimiter");
}
if (inputs == null) {
return null;
}
String delim = concat.getDelimiter() == null ? "" : concat.getDelimiter();
boolean delimitingEmptyValues = concat.getDelimitingEmptyValues() == null ? false : concat.getDelimitingEmptyValues();
boolean isFirst = true;
StringBuilder builder = new StringBuilder();
for (String entry : inputs) {
if (!isFirst && ((entry != null && !entry.isEmpty()) || delimitingEmptyValues)) {
builder.append(delim);
}
if (entry != null) {
builder.append(entry);
}
isFirst = false;
}
return builder.toString();
}
use of io.atlasmap.spi.AtlasActionProcessor in project atlasmap by atlasmap.
the class NumberFieldActions method convertAreaUnit.
/**
* Converts area unit.
* @param convertAreaUnit action model
* @param input source
* @return converted
*/
@AtlasActionProcessor
public static Number convertAreaUnit(ConvertAreaUnit convertAreaUnit, Number input) {
if (input == null) {
return 0;
}
if (convertAreaUnit == null || convertAreaUnit.getFromUnit() == null || convertAreaUnit.getToUnit() == null) {
throw new IllegalArgumentException("ConvertAreaUnit must be specified with fromUnit and toUnit");
}
AreaUnitType fromUnit = convertAreaUnit.getFromUnit();
AreaUnitType toUnit = convertAreaUnit.getToUnit();
double rate = areaConvertionTable.get(fromUnit).get(toUnit);
return doMultiply(input, rate);
}
use of io.atlasmap.spi.AtlasActionProcessor in project atlasmap by atlasmap.
the class NumberFieldActions method convertDistanceUnit.
/**
* Converts distance unit.
* @param convertDistanceUnit action model
* @param input source
* @return converted
*/
@AtlasActionProcessor
public static Number convertDistanceUnit(ConvertDistanceUnit convertDistanceUnit, Number input) {
if (input == null) {
return 0;
}
if (convertDistanceUnit == null || convertDistanceUnit.getFromUnit() == null || convertDistanceUnit.getToUnit() == null) {
throw new IllegalArgumentException("ConvertDistanceUnit must be specified with fromUnit and toUnit");
}
DistanceUnitType fromUnit = convertDistanceUnit.getFromUnit();
DistanceUnitType toUnit = convertDistanceUnit.getToUnit();
double rate = distanceConvertionTable.get(fromUnit).get(toUnit);
return doMultiply(input, rate);
}
use of io.atlasmap.spi.AtlasActionProcessor in project atlasmap by atlasmap.
the class NumberFieldActions method convertVolumeUnit.
/**
* Converts volume unit.
* @param convertVolumeUnit action model
* @param input source
* @return converted
*/
@AtlasActionProcessor
public static Number convertVolumeUnit(ConvertVolumeUnit convertVolumeUnit, Number input) {
if (input == null) {
return 0;
}
if (convertVolumeUnit == null || convertVolumeUnit.getFromUnit() == null || convertVolumeUnit.getToUnit() == null) {
throw new IllegalArgumentException("ConvertVolumeUnit must be specified with fromUnit and toUnit");
}
VolumeUnitType fromUnit = convertVolumeUnit.getFromUnit();
VolumeUnitType toUnit = convertVolumeUnit.getToUnit();
double rate = volumeConvertionTable.get(fromUnit).get(toUnit);
return doMultiply(input, rate);
}
Aggregations