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/cast/BooleanCastEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/cast/BooleanCastEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/cast/BooleanCastEvaluator.java deleted file mode 100644 index a88b72b..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/cast/BooleanCastEvaluator.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.cast; - -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 BooleanCastEvaluator extends BooleanEvaluator { - - private final StringEvaluator subjectEvaluator; - - public BooleanCastEvaluator(final StringEvaluator subjectEvaluator) { - this.subjectEvaluator = subjectEvaluator; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - final QueryResult<String> result = subjectEvaluator.evaluate(attributes); - if (result.getValue() == null) { - return new BooleanQueryResult(null); - } - - return new BooleanQueryResult(Boolean.valueOf(result.getValue().trim())); - } - - @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/cast/DateCastEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/cast/DateCastEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/cast/DateCastEvaluator.java deleted file mode 100644 index 96e74ef..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/cast/DateCastEvaluator.java +++ /dev/null @@ -1,117 +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.cast; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -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.StringQueryResult; -import org.apache.nifi.attribute.expression.language.exception.AttributeExpressionLanguageException; -import org.apache.nifi.attribute.expression.language.exception.AttributeExpressionLanguageParsingException; -import org.apache.nifi.expression.AttributeExpression.ResultType; - -public class DateCastEvaluator extends DateEvaluator { - - public static final String DATE_TO_STRING_FORMAT = "EEE MMM dd HH:mm:ss zzz yyyy"; - public static final Pattern DATE_TO_STRING_PATTERN = Pattern.compile("(?:[a-zA-Z]{3} ){2}\\d{2} \\d{2}\\:\\d{2}\\:\\d{2} (?:.*?) \\d{4}"); - - public static final String ALTERNATE_FORMAT_WITHOUT_MILLIS = "yyyy/MM/dd HH:mm:ss"; - public static final String ALTERNATE_FORMAT_WITH_MILLIS = "yyyy/MM/dd HH:mm:ss.SSS"; - public static final Pattern ALTERNATE_PATTERN = Pattern.compile("\\d{4}/\\d{2}/\\d{2} \\d{2}\\:\\d{2}\\:\\d{2}(\\.\\d{3})?"); - - public static final Pattern NUMBER_PATTERN = Pattern.compile("\\d+"); - - private final Evaluator<?> subjectEvaluator; - - public DateCastEvaluator(final Evaluator<?> subjectEvaluator) { - if (subjectEvaluator.getResultType() == ResultType.BOOLEAN) { - throw new AttributeExpressionLanguageParsingException("Cannot implicitly convert Data Type " + subjectEvaluator.getResultType() + " to " + ResultType.DATE); - } - - this.subjectEvaluator = subjectEvaluator; - } - - @Override - public QueryResult<Date> evaluate(final Map<String, String> attributes) { - final QueryResult<?> result = subjectEvaluator.evaluate(attributes); - if (result.getValue() == null) { - return new DateQueryResult(null); - } - - switch (result.getResultType()) { - case DATE: - return (DateQueryResult) result; - case STRING: - final String value = ((StringQueryResult) result).getValue().trim(); - if (DATE_TO_STRING_PATTERN.matcher(value).matches()) { - final SimpleDateFormat sdf = new SimpleDateFormat(DATE_TO_STRING_FORMAT, Locale.US); - - try { - final Date date = sdf.parse(value); - return new DateQueryResult(date); - } catch (final ParseException pe) { - final String details = "Format: '" + DATE_TO_STRING_FORMAT + "' Value: '" + value + "'"; - throw new AttributeExpressionLanguageException("Could not parse date using " + details, pe); - } - } else if (NUMBER_PATTERN.matcher(value).matches()) { - return new DateQueryResult(new Date(Long.valueOf(value))); - } else { - final Matcher altMatcher = ALTERNATE_PATTERN.matcher(value); - if (altMatcher.matches()) { - final String millisValue = altMatcher.group(1); - - final String format; - if (millisValue == null) { - format = ALTERNATE_FORMAT_WITHOUT_MILLIS; - } else { - format = ALTERNATE_FORMAT_WITH_MILLIS; - } - - final SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US); - - try { - final Date date = sdf.parse(value); - return new DateQueryResult(date); - } catch (final ParseException pe) { - throw new AttributeExpressionLanguageException("Could not parse input as date", pe); - } - } else { - throw new AttributeExpressionLanguageException("Could not implicitly convert input to DATE: " + value); - } - } - case NUMBER: - return new DateQueryResult(new Date((Long) result.getValue())); - default: - return new DateQueryResult(null); - } - } - - @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/cast/NumberCastEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/cast/NumberCastEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/cast/NumberCastEvaluator.java deleted file mode 100644 index 0447d48..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/cast/NumberCastEvaluator.java +++ /dev/null @@ -1,72 +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.cast; - -import java.util.Map; -import java.util.regex.Pattern; - -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.NumberQueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; -import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult; -import org.apache.nifi.attribute.expression.language.exception.AttributeExpressionLanguageParsingException; -import org.apache.nifi.expression.AttributeExpression.ResultType; - -public class NumberCastEvaluator extends NumberEvaluator { - - private final Evaluator<?> subjectEvaluator; - private static final Pattern NUMBER_PATTERN = Pattern.compile("-?\\d+"); - - public NumberCastEvaluator(final Evaluator<?> subjectEvaluator) { - if (subjectEvaluator.getResultType() == ResultType.BOOLEAN) { - throw new AttributeExpressionLanguageParsingException("Cannot implicitly convert Data Type " + subjectEvaluator.getResultType() + " to " + ResultType.NUMBER); - } - this.subjectEvaluator = subjectEvaluator; - } - - @Override - public QueryResult<Long> evaluate(final Map<String, String> attributes) { - final QueryResult<?> result = subjectEvaluator.evaluate(attributes); - if (result.getValue() == null) { - return new NumberQueryResult(null); - } - - switch (result.getResultType()) { - case NUMBER: - return (NumberQueryResult) result; - case STRING: - final String trimmed = ((StringQueryResult) result).getValue().trim(); - if (NUMBER_PATTERN.matcher(trimmed).matches()) { - return new NumberQueryResult(Long.valueOf(trimmed)); - } else { - return new NumberQueryResult(null); - } - case DATE: - return new NumberQueryResult(((DateQueryResult) result).getValue().getTime()); - default: - return new NumberQueryResult(null); - } - } - - @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/cast/StringCastEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/cast/StringCastEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/cast/StringCastEvaluator.java deleted file mode 100644 index 1a3732a..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/cast/StringCastEvaluator.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.cast; - -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 StringCastEvaluator extends StringEvaluator { - - private final Evaluator<?> subjectEvaluator; - - public StringCastEvaluator(final Evaluator<?> subjectEvaluator) { - this.subjectEvaluator = subjectEvaluator; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final QueryResult<?> result = subjectEvaluator.evaluate(attributes); - if (result.getValue() == null) { - return new StringQueryResult(null); - } - - return new StringQueryResult(String.valueOf(result.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/AndEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/AndEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/AndEvaluator.java deleted file mode 100644 index 9ed8f06..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/AndEvaluator.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 AndEvaluator extends BooleanEvaluator { - - private final BooleanEvaluator subjectEvaluator; - private final BooleanEvaluator rhsEvaluator; - - public AndEvaluator(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.FALSE.equals(subjectValue.getValue())) { - return new BooleanQueryResult(false); - } - - 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/AppendEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/AppendEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/AppendEvaluator.java deleted file mode 100644 index bd5e81a..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/AppendEvaluator.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 AppendEvaluator extends StringEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator appendEvaluator; - - public AppendEvaluator(final StringEvaluator subject, final StringEvaluator append) { - this.subject = subject; - this.appendEvaluator = append; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - final String appendValue = appendEvaluator.evaluate(attributes).getValue(); - - final String result = (subjectValue == null ? "" : subjectValue) - + (appendValue == null ? "" : appendValue); - 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/AttributeEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/AttributeEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/AttributeEvaluator.java deleted file mode 100644 index 1b4b74e..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/AttributeEvaluator.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 AttributeEvaluator extends StringEvaluator { - - private final StringEvaluator nameEvaluator; - - public AttributeEvaluator(final StringEvaluator nameEvaluator) { - this.nameEvaluator = nameEvaluator; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final String nameValue = nameEvaluator.evaluate(attributes).getValue(); - final String attributeValue = attributes.get(nameValue); - return new StringQueryResult(attributeValue); - } - - @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/ContainsEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ContainsEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ContainsEvaluator.java deleted file mode 100644 index 99802f6..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/ContainsEvaluator.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 ContainsEvaluator extends BooleanEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator search; - - public ContainsEvaluator(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.contains(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/DateToNumberEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/DateToNumberEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/DateToNumberEvaluator.java deleted file mode 100644 index 0594c4a..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/DateToNumberEvaluator.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.Date; -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.evaluation.DateEvaluator; -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 DateToNumberEvaluator extends NumberEvaluator { - - private final DateEvaluator subjectEvaluator; - - public DateToNumberEvaluator(final DateEvaluator subjectEvaluator) { - this.subjectEvaluator = subjectEvaluator; - } - - @Override - public QueryResult<Long> evaluate(final Map<String, String> attributes) { - final QueryResult<Date> subjectResult = subjectEvaluator.evaluate(attributes); - if (subjectResult.getValue() == null) { - return new NumberQueryResult(null); - } - - return new NumberQueryResult(subjectResult.getValue().getTime()); - } - - @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/DivideEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/DivideEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/DivideEvaluator.java deleted file mode 100644 index c7583cb..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/DivideEvaluator.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 DivideEvaluator extends NumberEvaluator { - - private final NumberEvaluator subject; - private final NumberEvaluator divideValue; - - public DivideEvaluator(final NumberEvaluator subject, final NumberEvaluator divideValue) { - this.subject = subject; - this.divideValue = divideValue; - } - - @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 divide = divideValue.evaluate(attributes).getValue(); - if (divide == null) { - return new NumberQueryResult(null); - } - - final long result = subjectValue / divide; - 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/EndsWithEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/EndsWithEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/EndsWithEvaluator.java deleted file mode 100644 index c31c2b1..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/EndsWithEvaluator.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 EndsWithEvaluator extends BooleanEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator search; - - public EndsWithEvaluator(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.endsWith(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/EqualsEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/EqualsEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/EqualsEvaluator.java deleted file mode 100644 index ec67b0f..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/EqualsEvaluator.java +++ /dev/null @@ -1,89 +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.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.expression.AttributeExpression.ResultType; - -public class EqualsEvaluator extends BooleanEvaluator { - - private final Evaluator<?> subject; - private final Evaluator<?> compareTo; - - public EqualsEvaluator(final Evaluator<?> subject, final Evaluator<?> compareTo) { - this.subject = subject; - this.compareTo = compareTo; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - final Object a = subject.evaluate(attributes).getValue(); - if (a == null) { - return new BooleanQueryResult(false); - } - - final Object b = compareTo.evaluate(attributes).getValue(); - if (b == null) { - return new BooleanQueryResult(false); - } - - if (subject.getResultType() == compareTo.getResultType()) { - return new BooleanQueryResult(a.equals(b)); - } - - final String normalizedSubjectValue = normalizeValue(subject.getResultType(), a); - if (normalizedSubjectValue == null) { - return new BooleanQueryResult(false); - } - - final String normalizedCompareToValue = normalizeValue(compareTo.getResultType(), b); - if (normalizedCompareToValue == null) { - return new BooleanQueryResult(false); - } - - return new BooleanQueryResult(normalizedSubjectValue.equals(normalizedCompareToValue)); - } - - private String normalizeValue(final ResultType type, final Object value) { - if (value == null) { - return null; - } - - switch (type) { - case STRING: - return (String) value; - case DATE: - return String.valueOf(((Date) value).getTime()); - case BOOLEAN: - case NUMBER: - default: - return String.valueOf(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/EqualsIgnoreCaseEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/EqualsIgnoreCaseEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/EqualsIgnoreCaseEvaluator.java deleted file mode 100644 index 344395b..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/EqualsIgnoreCaseEvaluator.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 EqualsIgnoreCaseEvaluator extends BooleanEvaluator { - - private final Evaluator<?> subject; - private final Evaluator<?> compareTo; - - public EqualsIgnoreCaseEvaluator(final Evaluator<?> subject, final Evaluator<?> compareTo) { - this.subject = subject; - this.compareTo = compareTo; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - final Object a = subject.evaluate(attributes).getValue(); - if (a == null) { - return new BooleanQueryResult(false); - } - - final Object b = compareTo.evaluate(attributes).getValue(); - if (b == null) { - return new BooleanQueryResult(false); - } - - if (a instanceof String && b instanceof String) { - return new BooleanQueryResult(((String) a).equalsIgnoreCase((String) b)); - } - - return new BooleanQueryResult(a.equals(b)); - } - - @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/FindEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/FindEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/FindEvaluator.java deleted file mode 100644 index b377c4a..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/FindEvaluator.java +++ /dev/null @@ -1,72 +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.regex.Pattern; - -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; -import org.apache.nifi.attribute.expression.language.evaluation.literals.StringLiteralEvaluator; - -public class FindEvaluator extends BooleanEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator search; - - private final Pattern compiledPattern; - - public FindEvaluator(final StringEvaluator subject, final StringEvaluator search) { - this.subject = subject; - this.search = search; - - // if the search string is a literal, we don't need to evaluate it each time; we can just - // pre-compile it. Otherwise, it must be compiled every time. - if (search instanceof StringLiteralEvaluator) { - this.compiledPattern = Pattern.compile(search.evaluate(null).getValue()); - } else { - this.compiledPattern = null; - } - } - - @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 Pattern pattern; - if (compiledPattern == null) { - pattern = Pattern.compile(search.evaluate(attributes).getValue()); - } else { - pattern = compiledPattern; - } - - final boolean found = pattern.matcher(subjectValue).find(); - - return new BooleanQueryResult(found); - } - - @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/FormatEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/FormatEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/FormatEvaluator.java deleted file mode 100644 index 132b9e7..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/FormatEvaluator.java +++ /dev/null @@ -1,61 +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.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.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 FormatEvaluator extends StringEvaluator { - - private final DateEvaluator subject; - private final StringEvaluator format; - - public FormatEvaluator(final DateEvaluator subject, final StringEvaluator format) { - this.subject = subject; - this.format = format; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - final Date subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new StringQueryResult(null); - } - - final QueryResult<String> formatResult = format.evaluate(attributes); - final String format = formatResult.getValue(); - if (format == null) { - return null; - } - - return new StringQueryResult(new SimpleDateFormat(format, Locale.US).format(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/GreaterThanEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanEvaluator.java deleted file mode 100644 index 6c712bb..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanEvaluator.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.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class GreaterThanEvaluator extends BooleanEvaluator { - - private final NumberEvaluator subject; - private final NumberEvaluator comparison; - - public GreaterThanEvaluator(final NumberEvaluator subject, final NumberEvaluator comparison) { - this.subject = subject; - this.comparison = comparison; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - final Long subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new BooleanQueryResult(false); - } - - final Long comparisonValue = comparison.evaluate(attributes).getValue(); - if (comparisonValue == null) { - return new BooleanQueryResult(false); - } - - return new BooleanQueryResult(subjectValue > comparisonValue); - } - - ; - - - @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/GreaterThanOrEqualEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanOrEqualEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanOrEqualEvaluator.java deleted file mode 100644 index 98951f2..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/GreaterThanOrEqualEvaluator.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.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class GreaterThanOrEqualEvaluator extends BooleanEvaluator { - - private final NumberEvaluator subject; - private final NumberEvaluator comparison; - - public GreaterThanOrEqualEvaluator(final NumberEvaluator subject, final NumberEvaluator comparison) { - this.subject = subject; - this.comparison = comparison; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - final Long subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new BooleanQueryResult(false); - } - - final Long comparisonValue = comparison.evaluate(attributes).getValue(); - if (comparisonValue == null) { - return new BooleanQueryResult(false); - } - - return new BooleanQueryResult(subjectValue >= comparisonValue); - } - - ; - - - @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/HostnameEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/HostnameEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/HostnameEvaluator.java deleted file mode 100644 index c0b1134..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/HostnameEvaluator.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.net.InetAddress; -import java.net.UnknownHostException; -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 HostnameEvaluator extends StringEvaluator { - - private final StringQueryResult hostname; - - public HostnameEvaluator(final boolean preferFQDN) throws UnknownHostException { - String address; - - if (preferFQDN) { - try { - address = InetAddress.getLocalHost().getCanonicalHostName(); - } catch (final Exception e) { - address = InetAddress.getLocalHost().getHostName(); - } - } else { - address = InetAddress.getLocalHost().getHostName(); - } - - hostname = new StringQueryResult(address); - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - return hostname; - } - - @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/IPEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IPEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IPEvaluator.java deleted file mode 100644 index 21f9fe8..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IPEvaluator.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.net.InetAddress; -import java.net.UnknownHostException; -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 IPEvaluator extends StringEvaluator { - - private final StringQueryResult ipAddress; - - public IPEvaluator() throws UnknownHostException { - ipAddress = new StringQueryResult(InetAddress.getLocalHost().getHostAddress()); - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - return ipAddress; - } - - @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/IndexOfEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IndexOfEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IndexOfEvaluator.java deleted file mode 100644 index 80422cb..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IndexOfEvaluator.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.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 IndexOfEvaluator extends NumberEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator indexEvaluator; - - public IndexOfEvaluator(final StringEvaluator subject, final StringEvaluator indexEvaluator) { - this.subject = subject; - this.indexEvaluator = indexEvaluator; - } - - @Override - public QueryResult<Long> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new NumberQueryResult(-1L); - } - final String indexEvalValue = indexEvaluator.evaluate(attributes).getValue(); - - return new NumberQueryResult((long) subjectValue.indexOf(indexEvalValue)); - } - - @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/IsEmptyEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IsEmptyEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IsEmptyEvaluator.java deleted file mode 100644 index c5e3c21..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IsEmptyEvaluator.java +++ /dev/null @@ -1,43 +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 IsEmptyEvaluator extends BooleanEvaluator { - private final Evaluator<?> subjectEvaluator; - - public IsEmptyEvaluator(final Evaluator<?> subjectEvaluator) { - this.subjectEvaluator = subjectEvaluator; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - final Object subjectValue = subjectEvaluator.evaluate(attributes).getValue(); - return new BooleanQueryResult(subjectValue == null || subjectValue.toString().trim().isEmpty()); - } - - @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/IsNullEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IsNullEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IsNullEvaluator.java deleted file mode 100644 index a9d678c..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/IsNullEvaluator.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 IsNullEvaluator extends BooleanEvaluator { - - private final Evaluator<?> subject; - - public IsNullEvaluator(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/LastIndexOfEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LastIndexOfEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LastIndexOfEvaluator.java deleted file mode 100644 index 2b67093..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LastIndexOfEvaluator.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.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 LastIndexOfEvaluator extends NumberEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator indexEvaluator; - - public LastIndexOfEvaluator(final StringEvaluator subject, final StringEvaluator indexEvaluator) { - this.subject = subject; - this.indexEvaluator = indexEvaluator; - } - - @Override - public QueryResult<Long> evaluate(final Map<String, String> attributes) { - final String subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new NumberQueryResult(-1L); - } - final String indexEvalValue = indexEvaluator.evaluate(attributes).getValue(); - - return new NumberQueryResult((long) subjectValue.lastIndexOf(indexEvalValue)); - } - - @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/LengthEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LengthEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LengthEvaluator.java deleted file mode 100644 index dec1f8f..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LengthEvaluator.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 LengthEvaluator extends NumberEvaluator { - - private final StringEvaluator subject; - - public LengthEvaluator(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((long) ((subjectValue == null) ? 0 : subjectValue.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/LessThanEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanEvaluator.java deleted file mode 100644 index 9a58910..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanEvaluator.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.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class LessThanEvaluator extends BooleanEvaluator { - - private final NumberEvaluator subject; - private final NumberEvaluator comparison; - - public LessThanEvaluator(final NumberEvaluator subject, final NumberEvaluator comparison) { - this.subject = subject; - this.comparison = comparison; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - final Long subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new BooleanQueryResult(false); - } - - final Long comparisonValue = comparison.evaluate(attributes).getValue(); - if (comparisonValue == null) { - return new BooleanQueryResult(false); - } - - return new BooleanQueryResult(subjectValue < comparisonValue); - } - - ; - - - @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/LessThanOrEqualEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanOrEqualEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanOrEqualEvaluator.java deleted file mode 100644 index 10f3f6a..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/LessThanOrEqualEvaluator.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.NumberEvaluator; -import org.apache.nifi.attribute.expression.language.evaluation.QueryResult; - -public class LessThanOrEqualEvaluator extends BooleanEvaluator { - - private final NumberEvaluator subject; - private final NumberEvaluator comparison; - - public LessThanOrEqualEvaluator(final NumberEvaluator subject, final NumberEvaluator comparison) { - this.subject = subject; - this.comparison = comparison; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - final Long subjectValue = subject.evaluate(attributes).getValue(); - if (subjectValue == null) { - return new BooleanQueryResult(false); - } - - final Long comparisonValue = comparison.evaluate(attributes).getValue(); - if (comparisonValue == null) { - return new BooleanQueryResult(false); - } - - return new BooleanQueryResult(subjectValue <= comparisonValue); - } - - ; - - - @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/MatchesEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/MatchesEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/MatchesEvaluator.java deleted file mode 100644 index 1bb86a5..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/MatchesEvaluator.java +++ /dev/null @@ -1,71 +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.regex.Pattern; - -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; -import org.apache.nifi.attribute.expression.language.evaluation.literals.StringLiteralEvaluator; - -public class MatchesEvaluator extends BooleanEvaluator { - - private final StringEvaluator subject; - private final StringEvaluator search; - - private final Pattern compiledPattern; - - public MatchesEvaluator(final StringEvaluator subject, final StringEvaluator search) { - this.subject = subject; - this.search = search; - - // if the search string is a literal, we don't need to evaluate it each time; we can just - // pre-compile it. Otherwise, it must be compiled every time. - if (search instanceof StringLiteralEvaluator) { - this.compiledPattern = Pattern.compile(search.evaluate(null).getValue()); - } else { - this.compiledPattern = null; - } - } - - @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 Pattern pattern; - if (compiledPattern == null) { - pattern = Pattern.compile(search.evaluate(attributes).getValue()); - } else { - pattern = compiledPattern; - } - - final boolean matches = pattern.matcher(subjectValue).matches(); - return new BooleanQueryResult(matches); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return subject; - } - -}