http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/MinusEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/MinusEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/MinusEvaluator.java deleted file mode 100644 index 0665979..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/MinusEvaluator.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class MinusEvaluator extends NumberEvaluator { - - private final NumberEvaluator subject; - private final NumberEvaluator minusValue; - - public MinusEvaluator(final NumberEvaluator subject, final NumberEvaluator minusValue) { - this.subject = subject; - this.minusValue = minusValue; - } - - @Override - public QueryResult<Long> evaluate(final Map<String, String> attributes) { - final Long subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new NumberQueryResult(null); - } - - final Long minus = minusValue.evaluate(attributes).getValue(); - if (minus == null) { - return new NumberQueryResult(null); - } - - final long result = subjectValue - minus; - return new NumberQueryResult(result); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ModEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ModEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ModEvaluator.java deleted file mode 100644 index 6b7b838..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ModEvaluator.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class ModEvaluator extends NumberEvaluator { - - private final NumberEvaluator subject; - private final NumberEvaluator modValue; - - public ModEvaluator(final NumberEvaluator subject, final NumberEvaluator modValue) { - this.subject = subject; - this.modValue = modValue; - } - - @Override - public QueryResult<Long> evaluate(final Map<String, String> attributes) { - final Long subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new NumberQueryResult(null); - } - - final Long mod = modValue.evaluate(attributes).getValue(); - if (mod == null) { - return new NumberQueryResult(null); - } - - final long result = subjectValue % mod; - return new NumberQueryResult(result); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/MultiplyEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/MultiplyEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/MultiplyEvaluator.java deleted file mode 100644 index a3b03ed..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/MultiplyEvaluator.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class MultiplyEvaluator extends NumberEvaluator { - - private final NumberEvaluator subject; - private final NumberEvaluator multiplyValue; - - public MultiplyEvaluator(final NumberEvaluator subject, final NumberEvaluator multiplyValue) { - this.subject = subject; - this.multiplyValue = multiplyValue; - } - - @Override - public QueryResult<Long> evaluate(final Map<String, String> attributes) { - final Long subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new NumberQueryResult(null); - } - - final Long multiply = multiplyValue.evaluate(attributes).getValue(); - if (multiply == null) { - return new NumberQueryResult(null); - } - - final long result = subjectValue * multiply; - return new NumberQueryResult(result); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NotEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NotEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NotEvaluator.java deleted file mode 100644 index 327e620..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NotEvaluator.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.BooleanEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.BooleanQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class NotEvaluator extends BooleanEvaluator { - - private final BooleanEvaluator subjectEvaluator; - - public NotEvaluator(final BooleanEvaluator subjectEvaluator) { - this.subjectEvaluator = subjectEvaluator; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - final QueryResult<Boolean> subjectValue = subjectEvaluator.evaluate(attributes); - if (subjectValue == null) { - return new BooleanQueryResult(null); - } - - return new BooleanQueryResult(!subjectValue.getValue()); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subjectEvaluator; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NotNullEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NotNullEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NotNullEvaluator.java deleted file mode 100644 index 126fbfa..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NotNullEvaluator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.BooleanEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.BooleanQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class NotNullEvaluator extends BooleanEvaluator { - - private final Evaluator<?> subject; - - public NotNullEvaluator(final Evaluator<?> subject) { - this.subject = subject; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - final Object subjectValue = subject.evaluate(attributes).getValue(); - return new BooleanQueryResult(subjectValue != null); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NowEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NowEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NowEvaluator.java deleted file mode 100644 index bfde6b0..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NowEvaluator.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Date; -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.DateEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.DateQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class NowEvaluator extends DateEvaluator { - - @Override - public QueryResult<Date> evaluate(final Map<String, String> attributes) { - return new DateQueryResult(new Date()); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return null; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NumberToDateEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NumberToDateEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NumberToDateEvaluator.java deleted file mode 100644 index 672d855..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NumberToDateEvaluator.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Date; -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.DateEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.DateQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class NumberToDateEvaluator extends DateEvaluator { - - private final NumberEvaluator subject; - - public NumberToDateEvaluator(final NumberEvaluator subject) { - this.subject = subject; - } - - @Override - public QueryResult<Date> evaluate(final Map<String, String> attributes) { - final QueryResult<Long> result = subject.evaluate(attributes); - final Long value = result.getValue(); - if (value == null) { - return null; - } - - return new DateQueryResult(new Date(value)); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/OneUpSequenceEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/OneUpSequenceEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/OneUpSequenceEvaluator.java deleted file mode 100644 index 11d3fa9..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/OneUpSequenceEvaluator.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicLong; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class OneUpSequenceEvaluator extends NumberEvaluator { - - private static final AtomicLong value = new AtomicLong(0L); - - @Override - public QueryResult<Long> evaluate(final Map<String, String> attributes) { - return new NumberQueryResult(value.getAndIncrement()); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return null; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/OrEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/OrEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/OrEvaluator.java deleted file mode 100644 index ab3a16c..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/OrEvaluator.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.BooleanEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.BooleanQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class OrEvaluator extends BooleanEvaluator { - - private final BooleanEvaluator subjectEvaluator; - private final BooleanEvaluator rhsEvaluator; - - public OrEvaluator(final BooleanEvaluator subjectEvaluator, final BooleanEvaluator rhsEvaluator) { - this.subjectEvaluator = subjectEvaluator; - this.rhsEvaluator = rhsEvaluator; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - final QueryResult<Boolean> subjectValue = subjectEvaluator.evaluate(attributes); - if (subjectValue == null) { - return new BooleanQueryResult(null); - } - - if (Boolean.TRUE.equals(subjectValue.getValue())) { - return new BooleanQueryResult(true); - } - - final QueryResult<Boolean> rhsValue = rhsEvaluator.evaluate(attributes); - if (rhsValue == null) { - return new BooleanQueryResult(false); - } - - return new BooleanQueryResult(rhsValue.getValue()); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subjectEvaluator; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/PlusEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/PlusEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/PlusEvaluator.java deleted file mode 100644 index dff693d..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/PlusEvaluator.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class PlusEvaluator extends NumberEvaluator { - - private final NumberEvaluator subject; - private final NumberEvaluator plusValue; - - public PlusEvaluator(final NumberEvaluator subject, final NumberEvaluator plusValue) { - this.subject = subject; - this.plusValue = plusValue; - } - - @Override - public QueryResult<Long> evaluate(final Map<String, String> attributes) { - final Long subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new NumberQueryResult(null); - } - - final Long plus = plusValue.evaluate(attributes).getValue(); - if (plus == null) { - return new NumberQueryResult(null); - } - - final long result = subjectValue + plus; - return new NumberQueryResult(result); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/PrependEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/PrependEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/PrependEvaluator.java deleted file mode 100644 index 5b66b8f..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/PrependEvaluator.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class PrependEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator prependEvaluator; - - public PrependEvaluator(final StringEvaluator subject, final StringEvaluator prepend) { - this.subject = subject; - this.prependEvaluator = prepend; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - final String prependValue = prependEvaluator.evaluate(attributes).getValue(); - - final String result = (prependValue == null ? "" : prependValue) + (subjectValue == null ? "" : subjectValue); - return new StringQueryResult(result); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceAllEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceAllEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceAllEvaluator.java deleted file mode 100644 index 19ed63e..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceAllEvaluator.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class ReplaceAllEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator search; - private final StringEvaluator replacement; - - public ReplaceAllEvaluator(final StringEvaluator subject, final StringEvaluator search, final StringEvaluator replacement) { - this.subject = subject; - this.search = search; - this.replacement = replacement; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new StringQueryResult(null); - } - final String searchValue = search.evaluate(attributes).getValue(); - final String replacementValue = replacement.evaluate(attributes).getValue(); - - return new StringQueryResult(subjectValue.replaceAll(searchValue, replacementValue)); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceEmptyEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceEmptyEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceEmptyEvaluator.java deleted file mode 100644 index e5c40d2..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceEmptyEvaluator.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; - -public class ReplaceEmptyEvaluator extends StringEvaluator { - private final StringEvaluator subjectEvaluator; - private final StringEvaluator replacementEvaluator; - - public ReplaceEmptyEvaluator(final StringEvaluator subjectEvaluator, final StringEvaluator replacementEvaluator) { - this.subjectEvaluator = subjectEvaluator; - this.replacementEvaluator = replacementEvaluator; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final QueryResult<String> subjectResult = subjectEvaluator.evaluate(attributes); - final String subjectValue = subjectResult.getValue(); - final boolean isEmpty = subjectValue == null || subjectValue.toString().trim().isEmpty(); - if ( isEmpty ) { - return replacementEvaluator.evaluate(attributes); - } else { - return subjectResult; - } - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subjectEvaluator; - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceEvaluator.java deleted file mode 100644 index d6a7c5b..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceEvaluator.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class ReplaceEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator search; - private final StringEvaluator replacement; - - public ReplaceEvaluator(final StringEvaluator subject, final StringEvaluator search, final StringEvaluator replacement) { - this.subject = subject; - this.search = search; - this.replacement = replacement; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new StringQueryResult(null); - } - final String searchValue = search.evaluate(attributes).getValue(); - final String replacementValue = replacement.evaluate(attributes).getValue(); - - return new StringQueryResult(subjectValue.replace(searchValue, replacementValue)); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceNullEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceNullEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceNullEvaluator.java deleted file mode 100644 index 91333b7..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ReplaceNullEvaluator.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class ReplaceNullEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator resultEvaluator; - - public ReplaceNullEvaluator(final StringEvaluator subject, final StringEvaluator resultEvaluator) { - this.subject = subject; - this.resultEvaluator = resultEvaluator; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - return new StringQueryResult(subjectValue == null ? resultEvaluator.evaluate(attributes).getValue() : subjectValue); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/StartsWithEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/StartsWithEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/StartsWithEvaluator.java deleted file mode 100644 index c6a7eb7..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/StartsWithEvaluator.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.BooleanEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.BooleanQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; - -public class StartsWithEvaluator extends BooleanEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator search; - - public StartsWithEvaluator(final StringEvaluator subject, final StringEvaluator search) { - this.subject = subject; - this.search = search; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new BooleanQueryResult(false); - } - - final String searchString = search.evaluate(attributes).getValue(); - return new BooleanQueryResult(searchString == null ? false : subjectValue.startsWith(searchString)); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/StringToDateEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/StringToDateEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/StringToDateEvaluator.java deleted file mode 100644 index 1575d75..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/StringToDateEvaluator.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.DateEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.DateQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.exception.IllegalAttributeException; - -public class StringToDateEvaluator extends DateEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator format; - - public StringToDateEvaluator(final StringEvaluator subject, final StringEvaluator format) { - this.subject = subject; - this.format = format; - } - - @Override - public QueryResult<Date> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - final String formatValue = format.evaluate(attributes).getValue(); - if (subjectValue == null || formatValue == null) { - return new DateQueryResult(null); - } - - try { - return new DateQueryResult(new SimpleDateFormat(formatValue, Locale.US).parse(subjectValue)); - } catch (final ParseException e) { - throw new IllegalAttributeException("Cannot parse attribute value as a date; date format: " - + formatValue + "; attribute value: " + subjectValue); - } catch (final IllegalArgumentException e) { - throw new IllegalAttributeException("Invalid date format: " + formatValue); - } - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringAfterEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringAfterEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringAfterEvaluator.java deleted file mode 100644 index a8b7357..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringAfterEvaluator.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class SubstringAfterEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator afterEvaluator; - - public SubstringAfterEvaluator(final StringEvaluator subject, final StringEvaluator afterEvaluator) { - this.subject = subject; - this.afterEvaluator = afterEvaluator; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new StringQueryResult(""); - } - final String afterValue = afterEvaluator.evaluate(attributes).getValue(); - if (afterValue == null || afterValue.length() == 0) { - return new StringQueryResult(subjectValue); - } - - final int index = subjectValue.indexOf(afterValue); - if (index < 0) { - return new StringQueryResult(subjectValue); - } - return new StringQueryResult(subjectValue.substring(index + afterValue.length())); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringAfterLastEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringAfterLastEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringAfterLastEvaluator.java deleted file mode 100644 index 3dac40e..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringAfterLastEvaluator.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class SubstringAfterLastEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator afterEvaluator; - - public SubstringAfterLastEvaluator(final StringEvaluator subject, final StringEvaluator afterEvaluator) { - this.subject = subject; - this.afterEvaluator = afterEvaluator; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new StringQueryResult(""); - } - final String afterValue = afterEvaluator.evaluate(attributes).getValue(); - final int index = subjectValue.lastIndexOf(afterValue); - if (index < 0 || index >= subjectValue.length()) { - return new StringQueryResult(subjectValue); - } - return new StringQueryResult(subjectValue.substring(index + afterValue.length())); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringBeforeEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringBeforeEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringBeforeEvaluator.java deleted file mode 100644 index 92b136c..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringBeforeEvaluator.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class SubstringBeforeEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator beforeEvaluator; - - public SubstringBeforeEvaluator(final StringEvaluator subject, final StringEvaluator beforeEvaluator) { - this.subject = subject; - this.beforeEvaluator = beforeEvaluator; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new StringQueryResult(""); - } - final String beforeValue = beforeEvaluator.evaluate(attributes).getValue(); - if (beforeValue == null || beforeValue.length() == 0) { - return new StringQueryResult(subjectValue); - } - final int index = subjectValue.indexOf(beforeValue); - if (index < 0) { - return new StringQueryResult(subjectValue); - } - return new StringQueryResult(subjectValue.substring(0, index)); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringBeforeLastEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringBeforeLastEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringBeforeLastEvaluator.java deleted file mode 100644 index 818a3dc..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringBeforeLastEvaluator.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class SubstringBeforeLastEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator beforeEvaluator; - - public SubstringBeforeLastEvaluator(final StringEvaluator subject, final StringEvaluator beforeEvaluator) { - this.subject = subject; - this.beforeEvaluator = beforeEvaluator; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new StringQueryResult(""); - } - final String beforeValue = beforeEvaluator.evaluate(attributes).getValue(); - final int index = subjectValue.lastIndexOf(beforeValue); - if (index < 0) { - return new StringQueryResult(subjectValue); - } - return new StringQueryResult(subjectValue.substring(0, index)); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringEvaluator.java deleted file mode 100644 index da11c45..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/SubstringEvaluator.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class SubstringEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - private final NumberEvaluator startIndex; - private final NumberEvaluator endIndex; - - public SubstringEvaluator(final StringEvaluator subject, final NumberEvaluator startIndex, final NumberEvaluator endIndex) { - this.subject = subject; - this.startIndex = startIndex; - this.endIndex = endIndex; - } - - public SubstringEvaluator(final StringEvaluator subject, final NumberEvaluator startIndex) { - this.subject = subject; - this.startIndex = startIndex; - this.endIndex = null; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new StringQueryResult(""); - } - final int startIndexValue = startIndex.evaluate(attributes).getValue().intValue(); - if (endIndex == null) { - return new StringQueryResult(subjectValue.substring(startIndexValue)); - } else { - final int endIndexValue = endIndex.evaluate(attributes).getValue().intValue(); - return new StringQueryResult(subjectValue.substring(startIndexValue, endIndexValue)); - } - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToLowerEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToLowerEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToLowerEvaluator.java deleted file mode 100644 index 7de01eb..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToLowerEvaluator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class ToLowerEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - - public ToLowerEvaluator(final StringEvaluator subject) { - this.subject = subject; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - return new StringQueryResult((subjectValue == null) ? null : subjectValue.toLowerCase()); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToNumberEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToNumberEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToNumberEvaluator.java deleted file mode 100644 index 1d4664a..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToNumberEvaluator.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; - -public class ToNumberEvaluator extends NumberEvaluator { - - private final StringEvaluator subject; - - public ToNumberEvaluator(final StringEvaluator subject) { - this.subject = subject; - } - - @Override - public QueryResult<Long> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - return new NumberQueryResult((subjectValue == null || subjectValue.trim().isEmpty()) ? null : Long.valueOf(subjectValue)); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToRadixEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToRadixEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToRadixEvaluator.java deleted file mode 100644 index aab094d..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToRadixEvaluator.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Arrays; -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class ToRadixEvaluator extends StringEvaluator { - - private final NumberEvaluator numberEvaluator; - private final NumberEvaluator radixEvaluator; - private final NumberEvaluator minimumWidthEvaluator; - - public ToRadixEvaluator(final NumberEvaluator subject, final NumberEvaluator radixEvaluator) { - this(subject, radixEvaluator, null); - } - - public ToRadixEvaluator(final NumberEvaluator subject, final NumberEvaluator radixEvaluator, final NumberEvaluator minimumWidthEvaluator) { - this.numberEvaluator = subject; - this.radixEvaluator = radixEvaluator; - this.minimumWidthEvaluator = minimumWidthEvaluator; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final Long result = numberEvaluator.evaluate(attributes).getValue(); - if (result == null) { - return new StringQueryResult(null); - } - - final Long radix = radixEvaluator.evaluate(attributes).getValue(); - if (radix == null) { - return new StringQueryResult(null); - } - - String stringValue = Long.toString(result.longValue(), radix.intValue()); - if (minimumWidthEvaluator != null) { - final Long minimumWidth = minimumWidthEvaluator.evaluate(attributes).getValue(); - if (minimumWidth != null) { - final int paddingWidth = minimumWidth.intValue() - stringValue.length(); - if (paddingWidth > 0) { - final char[] padChars = new char[paddingWidth]; - Arrays.fill(padChars, '0'); - stringValue = String.valueOf(padChars) + stringValue; - } - } - } - - return new StringQueryResult(stringValue); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return numberEvaluator; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToStringEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToStringEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToStringEvaluator.java deleted file mode 100644 index 2f7fbe3..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToStringEvaluator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class ToStringEvaluator extends StringEvaluator { - - private final Evaluator<?> subject; - - public ToStringEvaluator(final Evaluator<?> subject) { - this.subject = subject; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final Object result = subject.evaluate(attributes).getValue(); - return new StringQueryResult(result == null ? null : result.toString()); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToUpperEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToUpperEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToUpperEvaluator.java deleted file mode 100644 index 29bc61d..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ToUpperEvaluator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class ToUpperEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - - public ToUpperEvaluator(final StringEvaluator subject) { - this.subject = subject; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - return new StringQueryResult((subjectValue == null) ? null : subjectValue.toUpperCase()); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/TrimEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/TrimEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/TrimEvaluator.java deleted file mode 100644 index b9926d7..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/TrimEvaluator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class TrimEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - - public TrimEvaluator(final StringEvaluator subject) { - this.subject = subject; - } - - @Override - public QueryResult<String> evaluate(Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - return new StringQueryResult(subjectValue == null ? null : subjectValue.trim()); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/UrlDecodeEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/UrlDecodeEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/UrlDecodeEvaluator.java deleted file mode 100644 index 6c3ba14..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/UrlDecodeEvaluator.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class UrlDecodeEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - - public UrlDecodeEvaluator(final StringEvaluator subject) { - this.subject = subject; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new StringQueryResult(null); - } - - try { - return new StringQueryResult(URLDecoder.decode(subjectValue, "UTF-8")); - } catch (UnsupportedEncodingException e) { - return null; // won't happen. It's UTF-8 - } - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/UrlEncodeEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/UrlEncodeEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/UrlEncodeEvaluator.java deleted file mode 100644 index d1e2caa..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/UrlEncodeEvaluator.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.attribute.expression.language.evaluation.functions; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; - -public class UrlEncodeEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - - public UrlEncodeEvaluator(final StringEvaluator subject) { - this.subject = subject; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new StringQueryResult(null); - } - - try { - return new StringQueryResult(URLEncoder.encode(subjectValue, "UTF-8")); - } catch (UnsupportedEncodingException e) { - return null; // won't happen. It's UTF-8 - } - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -}