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/UuidEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/UuidEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/UuidEvaluator.java deleted file mode 100644 index faa8f0a..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/UuidEvaluator.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.Map; -import java.util.UUID; - -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 UuidEvaluator extends StringEvaluator { - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - return new StringQueryResult(UUID.randomUUID().toString()); - } - - @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/literals/BooleanLiteralEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/literals/BooleanLiteralEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/literals/BooleanLiteralEvaluator.java deleted file mode 100644 index a085423..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/literals/BooleanLiteralEvaluator.java +++ /dev/null @@ -1,44 +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.literals; - -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 BooleanLiteralEvaluator extends BooleanEvaluator { - - private final boolean value; - - public BooleanLiteralEvaluator(final boolean value) { - this.value = value; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - return new BooleanQueryResult(value); - } - - @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/literals/NumberLiteralEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/literals/NumberLiteralEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/literals/NumberLiteralEvaluator.java deleted file mode 100644 index d7569e0..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/literals/NumberLiteralEvaluator.java +++ /dev/null @@ -1,44 +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.literals; - -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 NumberLiteralEvaluator extends NumberEvaluator { - - private final long literal; - - public NumberLiteralEvaluator(final String value) { - this.literal = Long.parseLong(value); - } - - @Override - public QueryResult<Long> evaluate(final Map<String, String> attributes) { - return new NumberQueryResult(literal); - } - - @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/literals/StringLiteralEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/literals/StringLiteralEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/literals/StringLiteralEvaluator.java deleted file mode 100644 index d739ac7..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/literals/StringLiteralEvaluator.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.literals; - -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 StringLiteralEvaluator extends StringEvaluator { - - private final String value; - - public StringLiteralEvaluator(final String value) { - // need to escape characters after backslashes - final StringBuilder sb = new StringBuilder(); - boolean lastCharIsBackslash = false; - for (int i = 0; i < value.length(); i++) { - final char c = value.charAt(i); - - if (lastCharIsBackslash) { - switch (c) { - case 'n': - sb.append("\n"); - break; - case 'r': - sb.append("\r"); - break; - case '\\': - sb.append("\\"); - break; - case 't': - sb.append("\\t"); - break; - default: - sb.append("\\").append(c); - break; - } - - lastCharIsBackslash = false; - } else if (c == '\\') { - lastCharIsBackslash = true; - } else { - sb.append(c); - } - } - - this.value = sb.toString(); - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - return new StringQueryResult(value); - } - - @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/reduce/CountEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/CountEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/CountEvaluator.java deleted file mode 100644 index f2af268..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/CountEvaluator.java +++ /dev/null @@ -1,56 +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.reduce; - -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.expression.AttributeExpression.ResultType; - -public class CountEvaluator extends NumberEvaluator implements ReduceEvaluator<Long> { - - private final Evaluator<?> subjectEvaluator; - private long count = 0L; - - public CountEvaluator(final Evaluator<?> subjectEvaluator) { - 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(count); - } - - if ( result.getResultType() == ResultType.BOOLEAN && ((Boolean) result.getValue()).equals(Boolean.FALSE) ) { - return new NumberQueryResult(count); - } - - count++; - return new NumberQueryResult(count); - } - - @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/reduce/JoinEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/JoinEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/JoinEvaluator.java deleted file mode 100644 index eefdada..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/JoinEvaluator.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.reduce; - -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 JoinEvaluator extends StringEvaluator implements ReduceEvaluator<String> { - private final StringEvaluator subjectEvaluator; - private final StringEvaluator delimiterEvaluator; - - private final StringBuilder sb = new StringBuilder(); - private int evalCount = 0; - - public JoinEvaluator(final StringEvaluator subject, final StringEvaluator delimiter) { - this.subjectEvaluator = subject; - this.delimiterEvaluator = delimiter; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - String subject = subjectEvaluator.evaluate(attributes).getValue(); - if ( subject == null ) { - subject = ""; - } - - final String delimiter = delimiterEvaluator.evaluate(attributes).getValue(); - if ( evalCount > 0 ) { - sb.append(delimiter); - } - sb.append(subject); - - evalCount++; - return new StringQueryResult( sb.toString() ); - } - - @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/reduce/ReduceEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/ReduceEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/ReduceEvaluator.java deleted file mode 100644 index 12197c0..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/reduce/ReduceEvaluator.java +++ /dev/null @@ -1,23 +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.reduce; - -import org.apache.nifi.attribute.expression.language.evaluation.Evaluator; - -public interface ReduceEvaluator<T> extends Evaluator<T> { - -} 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/selection/AllAttributesEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/AllAttributesEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/AllAttributesEvaluator.java deleted file mode 100644 index d9dd4d3..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/AllAttributesEvaluator.java +++ /dev/null @@ -1,68 +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.selection; - -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 AllAttributesEvaluator extends BooleanEvaluator { - - private final BooleanEvaluator booleanEvaluator; - private final MultiAttributeEvaluator multiAttributeEvaluator; - - public AllAttributesEvaluator(final BooleanEvaluator booleanEvaluator, final MultiAttributeEvaluator multiAttributeEvaluator) { - this.booleanEvaluator = booleanEvaluator; - this.multiAttributeEvaluator = multiAttributeEvaluator; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - QueryResult<Boolean> attributeValueQuery = booleanEvaluator.evaluate(attributes); - Boolean result = attributeValueQuery.getValue(); - if (result == null) { - return new BooleanQueryResult(false); - } - - if (!result) { - return new BooleanQueryResult(false); - } - - while (multiAttributeEvaluator.getEvaluationsRemaining() > 0) { - attributeValueQuery = booleanEvaluator.evaluate(attributes); - result = attributeValueQuery.getValue(); - if (result != null && !result) { - return attributeValueQuery; - } - } - - return new BooleanQueryResult(true); - } - - @Override - public int getEvaluationsRemaining() { - return 0; - } - - @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/selection/AnyAttributeEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/AnyAttributeEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/AnyAttributeEvaluator.java deleted file mode 100644 index 9192958..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/AnyAttributeEvaluator.java +++ /dev/null @@ -1,68 +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.selection; - -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 AnyAttributeEvaluator extends BooleanEvaluator { - - private final BooleanEvaluator booleanEvaluator; - private final MultiAttributeEvaluator multiAttributeEvaluator; - - public AnyAttributeEvaluator(final BooleanEvaluator booleanEvaluator, final MultiAttributeEvaluator multiAttributeEvaluator) { - this.booleanEvaluator = booleanEvaluator; - this.multiAttributeEvaluator = multiAttributeEvaluator; - } - - @Override - public QueryResult<Boolean> evaluate(final Map<String, String> attributes) { - QueryResult<Boolean> attributeValueQuery = booleanEvaluator.evaluate(attributes); - Boolean result = attributeValueQuery.getValue(); - if (result == null) { - return new BooleanQueryResult(false); - } - - if (result) { - return new BooleanQueryResult(true); - } - - while (multiAttributeEvaluator.getEvaluationsRemaining() > 0) { - attributeValueQuery = booleanEvaluator.evaluate(attributes); - result = attributeValueQuery.getValue(); - if (result != null && result) { - return attributeValueQuery; - } - } - - return new BooleanQueryResult(false); - } - - @Override - public int getEvaluationsRemaining() { - return 0; - } - - @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/selection/AnyMatchingAttributeEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/AnyMatchingAttributeEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/AnyMatchingAttributeEvaluator.java deleted file mode 100644 index 8c07278..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/AnyMatchingAttributeEvaluator.java +++ /dev/null @@ -1,21 +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.selection; - -public class AnyMatchingAttributeEvaluator { - -} 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/selection/DelineatedAttributeEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/DelineatedAttributeEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/DelineatedAttributeEvaluator.java deleted file mode 100644 index 209c86f..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/DelineatedAttributeEvaluator.java +++ /dev/null @@ -1,83 +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.selection; - -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 DelineatedAttributeEvaluator extends MultiAttributeEvaluator { - - private final StringEvaluator subjectEvaluator; - private final StringEvaluator delimiterEvaluator; - private final int evaluationType; - private String[] delineatedValues; - private int evaluationCount = 0; - private int evaluationsLeft = 1; - - public DelineatedAttributeEvaluator(final StringEvaluator subjectEvaluator, final StringEvaluator delimiterEvaluator, final int evaluationType) { - this.subjectEvaluator = subjectEvaluator; - this.delimiterEvaluator = delimiterEvaluator; - this.evaluationType = evaluationType; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - if (delineatedValues == null) { - final QueryResult<String> subjectValue = subjectEvaluator.evaluate(attributes); - if (subjectValue.getValue() == null) { - evaluationsLeft = 0; - return new StringQueryResult(null); - } - - final QueryResult<String> delimiterValue = delimiterEvaluator.evaluate(attributes); - if (subjectValue.getValue() == null) { - evaluationsLeft = 0; - return new StringQueryResult(null); - } - - delineatedValues = subjectValue.getValue().split(delimiterValue.getValue()); - } - - if (evaluationCount > delineatedValues.length) { - evaluationsLeft = 0; - return new StringQueryResult(null); - } - - evaluationsLeft = delineatedValues.length - evaluationCount - 1; - - return new StringQueryResult(delineatedValues[evaluationCount++]); - } - - @Override - public int getEvaluationsRemaining() { - return evaluationsLeft; - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return null; - } - - @Override - public int getEvaluationType() { - return evaluationType; - } -} 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/selection/MappingEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MappingEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MappingEvaluator.java deleted file mode 100644 index d872b6e..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MappingEvaluator.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.selection; - -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.reduce.ReduceEvaluator; -import org.apache.nifi.expression.AttributeExpression.ResultType; - -public class MappingEvaluator<T> implements Evaluator<T> { - private final ReduceEvaluator<T> mappingEvaluator; - private final MultiAttributeEvaluator multiAttributeEvaluator; - - public MappingEvaluator(final ReduceEvaluator<T> mappingEvaluator, final MultiAttributeEvaluator multiAttributeEval) { - this.mappingEvaluator = mappingEvaluator; - this.multiAttributeEvaluator = multiAttributeEval; - } - - @Override - public QueryResult<T> evaluate(final Map<String, String> attributes) { - QueryResult<T> result = mappingEvaluator.evaluate(attributes); - - while ( multiAttributeEvaluator.getEvaluationsRemaining() > 0 ) { - result = mappingEvaluator.evaluate(attributes); - } - - return result; - } - - @Override - public ResultType getResultType() { - return mappingEvaluator.getResultType(); - } - - @Override - public int getEvaluationsRemaining() { - return 0; - } - - @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/selection/MultiAttributeEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiAttributeEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiAttributeEvaluator.java deleted file mode 100644 index f80ed97..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiAttributeEvaluator.java +++ /dev/null @@ -1,24 +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.selection; - -import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator; - -public abstract class MultiAttributeEvaluator extends StringEvaluator { - - public abstract int getEvaluationType(); -} 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/selection/MultiMatchAttributeEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiMatchAttributeEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiMatchAttributeEvaluator.java deleted file mode 100644 index 9a441ce..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiMatchAttributeEvaluator.java +++ /dev/null @@ -1,82 +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.selection; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; - -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; - -public class MultiMatchAttributeEvaluator extends MultiAttributeEvaluator { - - private final List<Pattern> attributePatterns; - private final int evaluationType; - private final List<String> attributeNames = new ArrayList<>(); - private int evaluationCount = 0; - - public MultiMatchAttributeEvaluator(final List<String> attributeRegexes, final int evaluationType) { - this.attributePatterns = new ArrayList<>(); - for (final String regex : attributeRegexes) { - attributePatterns.add(Pattern.compile(regex)); - } - - this.evaluationType = evaluationType; - } - - /** - * Can be called only after the first call to evaluate - * - * @return - */ - @Override - public int getEvaluationsRemaining() { - return attributeNames.size() - evaluationCount; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - if (evaluationCount == 0) { - for (final Pattern pattern : attributePatterns) { - for (final String attrName : attributes.keySet()) { - if (pattern.matcher(attrName).matches()) { - attributeNames.add(attrName); - } - } - } - } - - if (evaluationCount >= attributeNames.size()) { - return new StringQueryResult(null); - } - - return new StringQueryResult(attributes.get(attributeNames.get(evaluationCount++))); - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return null; - } - - @Override - public int getEvaluationType() { - return evaluationType; - } -} 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/selection/MultiNamedAttributeEvaluator.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiNamedAttributeEvaluator.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiNamedAttributeEvaluator.java deleted file mode 100644 index 6dabc0a..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/selection/MultiNamedAttributeEvaluator.java +++ /dev/null @@ -1,64 +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.selection; - -import java.util.ArrayList; -import java.util.List; -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.StringQueryResult; - -public class MultiNamedAttributeEvaluator extends MultiAttributeEvaluator { - - private final List<String> attributeNames; - private final int evaluationType; - private int evaluationCount = 0; - private List<String> matchingAttributeNames = null; - - public MultiNamedAttributeEvaluator(final List<String> attributeNames, final int evaluationType) { - this.attributeNames = attributeNames; - this.evaluationType = evaluationType; - } - - @Override - public QueryResult<String> evaluate(final Map<String, String> attributes) { - matchingAttributeNames = new ArrayList<>(attributeNames); - - if (matchingAttributeNames.size() <= evaluationCount) { - return new StringQueryResult(null); - } - - return new StringQueryResult(attributes.get(matchingAttributeNames.get(evaluationCount++))); - } - - @Override - public int getEvaluationsRemaining() { - return matchingAttributeNames.size() - evaluationCount; - } - - @Override - public Evaluator<?> getSubjectEvaluator() { - return null; - } - - @Override - public int getEvaluationType() { - return evaluationType; - } -} 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/exception/AttributeExpressionLanguageException.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/AttributeExpressionLanguageException.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/AttributeExpressionLanguageException.java deleted file mode 100644 index 47d42cb..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/AttributeExpressionLanguageException.java +++ /dev/null @@ -1,34 +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.exception; - -public class AttributeExpressionLanguageException extends RuntimeException { - - private static final long serialVersionUID = -5637284498692447901L; - - public AttributeExpressionLanguageException(final String explanation) { - super(explanation); - } - - public AttributeExpressionLanguageException(final String explanation, final Throwable t) { - super(explanation, t); - } - - public AttributeExpressionLanguageException(final Throwable t) { - super(t); - } -} 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/exception/AttributeExpressionLanguageParsingException.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/AttributeExpressionLanguageParsingException.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/AttributeExpressionLanguageParsingException.java deleted file mode 100644 index f8531cb..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/AttributeExpressionLanguageParsingException.java +++ /dev/null @@ -1,34 +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.exception; - -public class AttributeExpressionLanguageParsingException extends AttributeExpressionLanguageException { - - private static final long serialVersionUID = 7422163230677064726L; - - public AttributeExpressionLanguageParsingException(final String explanation) { - super(explanation); - } - - public AttributeExpressionLanguageParsingException(final String explanation, final Throwable t) { - super(explanation, t); - } - - public AttributeExpressionLanguageParsingException(final Throwable t) { - super(t); - } -} 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/exception/IllegalAttributeException.java ---------------------------------------------------------------------- diff --git a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/IllegalAttributeException.java b/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/IllegalAttributeException.java deleted file mode 100644 index f6f32ca..0000000 --- a/nifi/commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/exception/IllegalAttributeException.java +++ /dev/null @@ -1,29 +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.exception; - -public class IllegalAttributeException extends RuntimeException { - private static final long serialVersionUID = 12348721897342L; - - public IllegalAttributeException() { - super(); - } - - public IllegalAttributeException(final String explanation) { - super(explanation); - } -}