You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2015/04/21 08:18:54 UTC
[08/12] incubator-nifi git commit: NIFI-271 checkpoint push because
there are so many changes. Long way to go but got through dto library
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/FieldEvaluator.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/FieldEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/FieldEvaluator.java
index 869c2d0..bc8046e 100644
--- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/FieldEvaluator.java
+++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/FieldEvaluator.java
@@ -28,40 +28,41 @@ import org.apache.nifi.hl7.query.evaluator.IntegerEvaluator;
@SuppressWarnings("rawtypes")
public class FieldEvaluator implements Evaluator<List> {
- private final SegmentEvaluator segmentEvaluator;
- private final IntegerEvaluator indexEvaluator;
-
- public FieldEvaluator(final SegmentEvaluator segmentEvaluator, final IntegerEvaluator indexEvaluator) {
- this.segmentEvaluator = segmentEvaluator;
- this.indexEvaluator = indexEvaluator;
- }
-
- public List<HL7Field> evaluate(final Map<String, Object> objectMap) {
- final List<HL7Segment> segments = segmentEvaluator.evaluate(objectMap);
- if ( segments == null ) {
- return Collections.emptyList();
- }
-
- final Integer index = indexEvaluator.evaluate(objectMap);
- if ( index == null ) {
- return Collections.emptyList();
- }
-
- final List<HL7Field> fields = new ArrayList<>();
- for ( final HL7Segment segment : segments ) {
- final List<HL7Field> segmentFields = segment.getFields();
- if ( segmentFields.size() <= index ) {
- continue;
- }
-
- fields.add(segmentFields.get(index));
- }
-
- return fields;
- }
- public Class<? extends List> getType() {
- return List.class;
- }
+ private final SegmentEvaluator segmentEvaluator;
+ private final IntegerEvaluator indexEvaluator;
+
+ public FieldEvaluator(final SegmentEvaluator segmentEvaluator, final IntegerEvaluator indexEvaluator) {
+ this.segmentEvaluator = segmentEvaluator;
+ this.indexEvaluator = indexEvaluator;
+ }
+
+ public List<HL7Field> evaluate(final Map<String, Object> objectMap) {
+ final List<HL7Segment> segments = segmentEvaluator.evaluate(objectMap);
+ if (segments == null) {
+ return Collections.emptyList();
+ }
+
+ final Integer index = indexEvaluator.evaluate(objectMap);
+ if (index == null) {
+ return Collections.emptyList();
+ }
+
+ final List<HL7Field> fields = new ArrayList<>();
+ for (final HL7Segment segment : segments) {
+ final List<HL7Field> segmentFields = segment.getFields();
+ if (segmentFields.size() <= index) {
+ continue;
+ }
+
+ fields.add(segmentFields.get(index));
+ }
+
+ return fields;
+ }
+
+ public Class<? extends List> getType() {
+ return List.class;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/MessageEvaluator.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/MessageEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/MessageEvaluator.java
index 5e08961..f430b50 100644
--- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/MessageEvaluator.java
+++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/MessageEvaluator.java
@@ -23,12 +23,12 @@ import org.apache.nifi.hl7.query.evaluator.Evaluator;
public class MessageEvaluator implements Evaluator<HL7Message> {
- public HL7Message evaluate(final Map<String, Object> objectMap) {
- return (HL7Message) objectMap.get(Evaluator.MESSAGE_KEY);
- }
+ public HL7Message evaluate(final Map<String, Object> objectMap) {
+ return (HL7Message) objectMap.get(Evaluator.MESSAGE_KEY);
+ }
- public Class<? extends HL7Message> getType() {
- return HL7Message.class;
- }
+ public Class<? extends HL7Message> getType() {
+ return HL7Message.class;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/SegmentEvaluator.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/SegmentEvaluator.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/SegmentEvaluator.java
index 1b9782d..9840461 100644
--- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/SegmentEvaluator.java
+++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/evaluator/message/SegmentEvaluator.java
@@ -27,25 +27,26 @@ import org.apache.nifi.hl7.query.evaluator.StringEvaluator;
@SuppressWarnings("rawtypes")
public class SegmentEvaluator implements Evaluator<List> {
- private final StringEvaluator segmentTypeEvaluator;
-
- public SegmentEvaluator(final StringEvaluator segmentTypeEvaluator) {
- this.segmentTypeEvaluator = segmentTypeEvaluator;
- }
-
- public List<HL7Segment> evaluate(final Map<String, Object> objectMap) {
- final String segmentType = segmentTypeEvaluator.evaluate(objectMap);
- if ( segmentType == null ) {
- return Collections.emptyList();
- }
-
- final HL7Message message = (HL7Message) objectMap.get(Evaluator.MESSAGE_KEY);
- final List<HL7Segment> segments = message.getSegments(segmentType);
- return (segments == null) ? Collections.<HL7Segment>emptyList() : segments;
- }
-
- public Class<? extends List> getType() {
- return List.class;
- }
+
+ private final StringEvaluator segmentTypeEvaluator;
+
+ public SegmentEvaluator(final StringEvaluator segmentTypeEvaluator) {
+ this.segmentTypeEvaluator = segmentTypeEvaluator;
+ }
+
+ public List<HL7Segment> evaluate(final Map<String, Object> objectMap) {
+ final String segmentType = segmentTypeEvaluator.evaluate(objectMap);
+ if (segmentType == null) {
+ return Collections.emptyList();
+ }
+
+ final HL7Message message = (HL7Message) objectMap.get(Evaluator.MESSAGE_KEY);
+ final List<HL7Segment> segments = message.getSegments(segmentType);
+ return (segments == null) ? Collections.<HL7Segment>emptyList() : segments;
+ }
+
+ public Class<? extends List> getType() {
+ return List.class;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/exception/HL7QueryParsingException.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/exception/HL7QueryParsingException.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/exception/HL7QueryParsingException.java
index 998f3bc..e27dd58 100644
--- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/exception/HL7QueryParsingException.java
+++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/exception/HL7QueryParsingException.java
@@ -17,21 +17,22 @@
package org.apache.nifi.hl7.query.exception;
public class HL7QueryParsingException extends RuntimeException {
- private static final long serialVersionUID = 1L;
- public HL7QueryParsingException() {
- super();
- }
-
- public HL7QueryParsingException(final Throwable cause) {
- super(cause);
- }
-
- public HL7QueryParsingException(final String message) {
- super(message);
- }
-
- public HL7QueryParsingException(final String message, final Throwable cause) {
- super(message, cause);
- }
+ private static final long serialVersionUID = 1L;
+
+ public HL7QueryParsingException() {
+ super();
+ }
+
+ public HL7QueryParsingException(final Throwable cause) {
+ super(cause);
+ }
+
+ public HL7QueryParsingException(final String message) {
+ super(message);
+ }
+
+ public HL7QueryParsingException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/MissedResult.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/MissedResult.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/MissedResult.java
index a6b36c8..1043ab6 100644
--- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/MissedResult.java
+++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/MissedResult.java
@@ -24,33 +24,34 @@ import org.apache.nifi.hl7.query.ResultHit;
import org.apache.nifi.hl7.query.Selection;
public class MissedResult implements QueryResult {
- private final List<Selection> selections;
-
- public MissedResult(final List<Selection> selections) {
- this.selections = selections;
- }
-
- @Override
- public List<String> getLabels() {
- final List<String> labels = new ArrayList<>();
- for ( final Selection selection : selections ) {
- labels.add(selection.getName());
- }
- return labels;
- }
-
- @Override
- public boolean isMatch() {
- return false;
- }
-
- @Override
- public ResultHit nextHit() {
- return null;
- }
-
- @Override
- public int getHitCount() {
- return 0;
- }
+
+ private final List<Selection> selections;
+
+ public MissedResult(final List<Selection> selections) {
+ this.selections = selections;
+ }
+
+ @Override
+ public List<String> getLabels() {
+ final List<String> labels = new ArrayList<>();
+ for (final Selection selection : selections) {
+ labels.add(selection.getName());
+ }
+ return labels;
+ }
+
+ @Override
+ public boolean isMatch() {
+ return false;
+ }
+
+ @Override
+ public ResultHit nextHit() {
+ return null;
+ }
+
+ @Override
+ public int getHitCount() {
+ return 0;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardQueryResult.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardQueryResult.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardQueryResult.java
index fbc16ca..bcba697 100644
--- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardQueryResult.java
+++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardQueryResult.java
@@ -27,43 +27,44 @@ import org.apache.nifi.hl7.query.ResultHit;
import org.apache.nifi.hl7.query.Selection;
public class StandardQueryResult implements QueryResult {
- private final List<Selection> selections;
- private final Set<Map<String, Object>> hits;
- private final Iterator<Map<String, Object>> hitIterator;
-
- public StandardQueryResult(final List<Selection> selections, final Set<Map<String, Object>> hits) {
- this.selections = selections;
- this.hits = hits;
-
- hitIterator = hits.iterator();
- }
-
- @Override
- public boolean isMatch() {
- return !hits.isEmpty();
- }
- @Override
- public List<String> getLabels() {
- final List<String> labels = new ArrayList<>();
- for ( final Selection selection : selections ) {
- labels.add(selection.getName());
- }
- return labels;
- }
+ private final List<Selection> selections;
+ private final Set<Map<String, Object>> hits;
+ private final Iterator<Map<String, Object>> hitIterator;
+
+ public StandardQueryResult(final List<Selection> selections, final Set<Map<String, Object>> hits) {
+ this.selections = selections;
+ this.hits = hits;
+
+ hitIterator = hits.iterator();
+ }
+
+ @Override
+ public boolean isMatch() {
+ return !hits.isEmpty();
+ }
+
+ @Override
+ public List<String> getLabels() {
+ final List<String> labels = new ArrayList<>();
+ for (final Selection selection : selections) {
+ labels.add(selection.getName());
+ }
+ return labels;
+ }
+
+ @Override
+ public int getHitCount() {
+ return hits.size();
+ }
+
+ @Override
+ public ResultHit nextHit() {
+ if (hitIterator.hasNext()) {
+ return new StandardResultHit(hitIterator.next());
+ } else {
+ return null;
+ }
+ }
- @Override
- public int getHitCount() {
- return hits.size();
- }
-
- @Override
- public ResultHit nextHit() {
- if ( hitIterator.hasNext() ) {
- return new StandardResultHit(hitIterator.next());
- } else {
- return null;
- }
- }
-
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardResultHit.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardResultHit.java b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardResultHit.java
index 944e998..7fe9205 100644
--- a/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardResultHit.java
+++ b/nifi/nifi-commons/nifi-hl7-query-language/src/main/java/org/apache/nifi/hl7/query/result/StandardResultHit.java
@@ -22,20 +22,21 @@ import java.util.Map;
import org.apache.nifi.hl7.query.ResultHit;
public class StandardResultHit implements ResultHit {
- private final Map<String, Object> values;
-
- public StandardResultHit(final Map<String, Object> values) {
- this.values = values;
- }
-
- @Override
- public Object getValue(final String label) {
- return values.get(label);
- }
-
- @Override
- public Map<String, Object> getSelectedValues() {
- return Collections.unmodifiableMap(values);
- }
+
+ private final Map<String, Object> values;
+
+ public StandardResultHit(final Map<String, Object> values) {
+ this.values = values;
+ }
+
+ @Override
+ public Object getValue(final String label) {
+ return values.get(label);
+ }
+
+ @Override
+ public Map<String, Object> getSelectedValues() {
+ return Collections.unmodifiableMap(values);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-hl7-query-language/src/test/java/org/apache/nifi/hl7/query/TestHL7Query.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-hl7-query-language/src/test/java/org/apache/nifi/hl7/query/TestHL7Query.java b/nifi/nifi-commons/nifi-hl7-query-language/src/test/java/org/apache/nifi/hl7/query/TestHL7Query.java
index 596440c..f78f82b 100644
--- a/nifi/nifi-commons/nifi-hl7-query-language/src/test/java/org/apache/nifi/hl7/query/TestHL7Query.java
+++ b/nifi/nifi-commons/nifi-hl7-query-language/src/test/java/org/apache/nifi/hl7/query/TestHL7Query.java
@@ -43,268 +43,264 @@ import ca.uhn.hl7v2.validation.impl.ValidationContextFactory;
@SuppressWarnings("resource")
public class TestHL7Query {
- @Test
- public void testAssignAliases() {
- final LinkedHashMap<String, List<Object>> possibleValueMap = new LinkedHashMap<>();
-
- final List<Object> valuesA = new ArrayList<>();
- valuesA.add("a");
- valuesA.add("b");
- valuesA.add("c");
-
- final List<Object> valuesB = new ArrayList<>();
- valuesB.add("d");
-
- final List<Object> valuesC = new ArrayList<>();
- valuesC.add("e");
- valuesC.add("f");
-
- final List<Object> valuesD = new ArrayList<>();
- valuesD.add("g");
- valuesD.add("h");
-
- possibleValueMap.put("A", valuesA);
- possibleValueMap.put("B", valuesB);
- possibleValueMap.put("C", valuesC);
- possibleValueMap.put("D", valuesD);
-
- for (int i=0; i < valuesA.size() * valuesB.size() * valuesC.size() * valuesD.size(); i++) {
- System.out.println(i + " : " + HL7Query.assignAliases(possibleValueMap, i));
- }
-
- verifyAssignments(HL7Query.assignAliases(possibleValueMap, 0), "a", "d", "e", "g");
- verifyAssignments(HL7Query.assignAliases(possibleValueMap, 1), "b", "d", "e", "g");
- verifyAssignments(HL7Query.assignAliases(possibleValueMap, 2), "c", "d", "e", "g");
- verifyAssignments(HL7Query.assignAliases(possibleValueMap, 3), "a", "d", "f", "g");
- verifyAssignments(HL7Query.assignAliases(possibleValueMap, 4), "b", "d", "f", "g");
- verifyAssignments(HL7Query.assignAliases(possibleValueMap, 5), "c", "d", "f", "g");
- verifyAssignments(HL7Query.assignAliases(possibleValueMap, 6), "a", "d", "e", "h");
- verifyAssignments(HL7Query.assignAliases(possibleValueMap, 7), "b", "d", "e", "h");
- verifyAssignments(HL7Query.assignAliases(possibleValueMap, 8), "c", "d", "e", "h");
- verifyAssignments(HL7Query.assignAliases(possibleValueMap, 9), "a", "d", "f", "h");
- verifyAssignments(HL7Query.assignAliases(possibleValueMap, 10), "b", "d", "f", "h");
- verifyAssignments(HL7Query.assignAliases(possibleValueMap, 11), "c", "d", "f", "h");
- }
-
- private void verifyAssignments(final Map<String, Object> map, final String a, final String b, final String c, final String d) {
- assertEquals(a, map.get("A"));
- assertEquals(b, map.get("B"));
- assertEquals(c, map.get("C"));
- assertEquals(d, map.get("D"));
- }
-
- @Test
- public void testSelectMessage() throws HL7Exception, IOException {
- final HL7Query query = HL7Query.compile("SELECT MESSAGE");
- final HL7Message msg = createMessage(new File("src/test/resources/hypoglycemia"));
- final QueryResult result = query.evaluate(msg);
- assertTrue(result.isMatch());
- final List<String> labels = result.getLabels();
- assertEquals(1, labels.size());
- assertEquals("MESSAGE", labels.get(0));
-
- assertEquals(1, result.getHitCount());
- assertEquals(msg, result.nextHit().getValue("MESSAGE"));
- }
-
- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void testSelectField() throws HL7Exception, IOException {
- final HL7Query query = HL7Query.compile("SELECT PID.5");
- final HL7Message msg = createMessage(new File("src/test/resources/hypoglycemia"));
- final QueryResult result = query.evaluate(msg);
- assertTrue(result.isMatch());
- final List<String> labels = result.getLabels();
- assertEquals(1, labels.size());
- assertEquals(1, result.getHitCount());
-
- final Object names = result.nextHit().getValue("PID.5");
- assertTrue(names instanceof List);
- final List<Object> nameList = (List) names;
- assertEquals(1, nameList.size());
- final HL7Field nameField = (HL7Field) nameList.get(0);
- assertEquals("SMITH^JOHN", nameField.getValue());
- }
-
- @Test
- public void testSelectAbnormalTestResult() throws HL7Exception, IOException {
- final String query = "DECLARE result AS REQUIRED OBX SELECT result WHERE result.7 != 'N' AND result.1 = 1";
-
- final HL7Query hl7Query = HL7Query.compile(query);
- final QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
- }
-
-
- @Test
- public void testFieldEqualsString() throws HL7Exception, IOException {
- HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'L'");
- QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'H'");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertFalse( result.isMatch() );
- }
-
- @Test
- public void testLessThan() throws HL7Exception, IOException {
- HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 < 600");
- QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 < 59");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertFalse( result.isMatch() );
- }
-
- @Test
- public void testCompareTwoFields() throws HL7Exception, IOException {
- HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 < result.6.2");
- QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE NOT(result.4 > result.6.3)");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertFalse( result.isMatch() );
- }
-
- @Test
- public void testLessThanOrEqual() throws HL7Exception, IOException {
- HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 <= 59");
- QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 <= 600");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 <= 58");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertFalse( result.isMatch() );
- }
-
- @Test
- public void testGreaterThanOrEqual() throws HL7Exception, IOException {
- HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 >= 59");
- QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 >= 6");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 >= 580");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertFalse( result.isMatch() );
- }
-
- @Test
- public void testGreaterThan() throws HL7Exception, IOException {
- HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 > 58");
- QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 > 6");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 > 580");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertFalse( result.isMatch() );
- }
-
-
- @Test
- public void testDistinctValuesReturned() throws HL7Exception, IOException {
- HL7Query hl7Query = HL7Query.compile("DECLARE result1 AS REQUIRED OBX, result2 AS REQUIRED OBX SELECT MESSAGE WHERE result1.7 = 'L' OR result2.7 != 'H'");
- QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
- assertEquals(1, result.getHitCount());
- }
-
- @Test
- public void testAndWithParens() throws HL7Exception, IOException {
- HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'L' AND result.3.1 = 'GLU'");
- QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'L' AND result.3.1 = 'GLU'");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia")));
- assertFalse( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'H' AND result.3.1 = 'GLU'");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertFalse( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'H' AND result.3.1 = 'GLU'");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE (result.7 = 'H') AND (result.3.1 = 'GLU')");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE ((result.7 = 'H') AND (result.3.1 = 'GLU'))");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE (( ((result.7 = 'H')) AND ( ((result.3.1 = 'GLU')) )))");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia")));
- assertTrue( result.isMatch() );
-
- }
-
-
- @Test
- public void testIsNull() throws HL7Exception, IOException {
- HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.999 IS NULL");
- QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.1 IS NULL");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertFalse( result.isMatch() );
-
- hl7Query = HL7Query.compile("SELECT MESSAGE WHERE ZZZ IS NULL");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("SELECT MESSAGE WHERE OBX IS NULL");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertFalse( result.isMatch() );
- }
-
-
- @Test
- public void testNotNull() throws HL7Exception, IOException {
- HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.999 NOT NULL");
- QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertFalse( result.isMatch() );
-
- hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.1 NOT NULL");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
-
- hl7Query = HL7Query.compile("SELECT MESSAGE WHERE ZZZ NOT NULL");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertFalse( result.isMatch() );
-
- hl7Query = HL7Query.compile("SELECT MESSAGE WHERE OBX NOT NULL");
- result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
- assertTrue( result.isMatch() );
- }
-
- private HL7Message createMessage(final File file) throws HL7Exception, IOException {
- final byte[] bytes = Files.readAllBytes(file.toPath());
- final String msgText = new String(bytes, "UTF-8");
-
- final HapiContext hapiContext = new DefaultHapiContext();
- hapiContext.setValidationContext(ValidationContextFactory.noValidation());
-
- final PipeParser parser = hapiContext.getPipeParser();
- final Message message = parser.parse(msgText);
- return new HapiMessage(message);
- }
-
+ @Test
+ public void testAssignAliases() {
+ final LinkedHashMap<String, List<Object>> possibleValueMap = new LinkedHashMap<>();
+
+ final List<Object> valuesA = new ArrayList<>();
+ valuesA.add("a");
+ valuesA.add("b");
+ valuesA.add("c");
+
+ final List<Object> valuesB = new ArrayList<>();
+ valuesB.add("d");
+
+ final List<Object> valuesC = new ArrayList<>();
+ valuesC.add("e");
+ valuesC.add("f");
+
+ final List<Object> valuesD = new ArrayList<>();
+ valuesD.add("g");
+ valuesD.add("h");
+
+ possibleValueMap.put("A", valuesA);
+ possibleValueMap.put("B", valuesB);
+ possibleValueMap.put("C", valuesC);
+ possibleValueMap.put("D", valuesD);
+
+ for (int i = 0; i < valuesA.size() * valuesB.size() * valuesC.size() * valuesD.size(); i++) {
+ System.out.println(i + " : " + HL7Query.assignAliases(possibleValueMap, i));
+ }
+
+ verifyAssignments(HL7Query.assignAliases(possibleValueMap, 0), "a", "d", "e", "g");
+ verifyAssignments(HL7Query.assignAliases(possibleValueMap, 1), "b", "d", "e", "g");
+ verifyAssignments(HL7Query.assignAliases(possibleValueMap, 2), "c", "d", "e", "g");
+ verifyAssignments(HL7Query.assignAliases(possibleValueMap, 3), "a", "d", "f", "g");
+ verifyAssignments(HL7Query.assignAliases(possibleValueMap, 4), "b", "d", "f", "g");
+ verifyAssignments(HL7Query.assignAliases(possibleValueMap, 5), "c", "d", "f", "g");
+ verifyAssignments(HL7Query.assignAliases(possibleValueMap, 6), "a", "d", "e", "h");
+ verifyAssignments(HL7Query.assignAliases(possibleValueMap, 7), "b", "d", "e", "h");
+ verifyAssignments(HL7Query.assignAliases(possibleValueMap, 8), "c", "d", "e", "h");
+ verifyAssignments(HL7Query.assignAliases(possibleValueMap, 9), "a", "d", "f", "h");
+ verifyAssignments(HL7Query.assignAliases(possibleValueMap, 10), "b", "d", "f", "h");
+ verifyAssignments(HL7Query.assignAliases(possibleValueMap, 11), "c", "d", "f", "h");
+ }
+
+ private void verifyAssignments(final Map<String, Object> map, final String a, final String b, final String c, final String d) {
+ assertEquals(a, map.get("A"));
+ assertEquals(b, map.get("B"));
+ assertEquals(c, map.get("C"));
+ assertEquals(d, map.get("D"));
+ }
+
+ @Test
+ public void testSelectMessage() throws HL7Exception, IOException {
+ final HL7Query query = HL7Query.compile("SELECT MESSAGE");
+ final HL7Message msg = createMessage(new File("src/test/resources/hypoglycemia"));
+ final QueryResult result = query.evaluate(msg);
+ assertTrue(result.isMatch());
+ final List<String> labels = result.getLabels();
+ assertEquals(1, labels.size());
+ assertEquals("MESSAGE", labels.get(0));
+
+ assertEquals(1, result.getHitCount());
+ assertEquals(msg, result.nextHit().getValue("MESSAGE"));
+ }
+
+ @Test
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public void testSelectField() throws HL7Exception, IOException {
+ final HL7Query query = HL7Query.compile("SELECT PID.5");
+ final HL7Message msg = createMessage(new File("src/test/resources/hypoglycemia"));
+ final QueryResult result = query.evaluate(msg);
+ assertTrue(result.isMatch());
+ final List<String> labels = result.getLabels();
+ assertEquals(1, labels.size());
+ assertEquals(1, result.getHitCount());
+
+ final Object names = result.nextHit().getValue("PID.5");
+ assertTrue(names instanceof List);
+ final List<Object> nameList = (List) names;
+ assertEquals(1, nameList.size());
+ final HL7Field nameField = (HL7Field) nameList.get(0);
+ assertEquals("SMITH^JOHN", nameField.getValue());
+ }
+
+ @Test
+ public void testSelectAbnormalTestResult() throws HL7Exception, IOException {
+ final String query = "DECLARE result AS REQUIRED OBX SELECT result WHERE result.7 != 'N' AND result.1 = 1";
+
+ final HL7Query hl7Query = HL7Query.compile(query);
+ final QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+ }
+
+ @Test
+ public void testFieldEqualsString() throws HL7Exception, IOException {
+ HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'L'");
+ QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'H'");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertFalse(result.isMatch());
+ }
+
+ @Test
+ public void testLessThan() throws HL7Exception, IOException {
+ HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 < 600");
+ QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 < 59");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertFalse(result.isMatch());
+ }
+
+ @Test
+ public void testCompareTwoFields() throws HL7Exception, IOException {
+ HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 < result.6.2");
+ QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE NOT(result.4 > result.6.3)");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertFalse(result.isMatch());
+ }
+
+ @Test
+ public void testLessThanOrEqual() throws HL7Exception, IOException {
+ HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 <= 59");
+ QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 <= 600");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 <= 58");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertFalse(result.isMatch());
+ }
+
+ @Test
+ public void testGreaterThanOrEqual() throws HL7Exception, IOException {
+ HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 >= 59");
+ QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 >= 6");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 >= 580");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertFalse(result.isMatch());
+ }
+
+ @Test
+ public void testGreaterThan() throws HL7Exception, IOException {
+ HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 > 58");
+ QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 > 6");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.4 > 580");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertFalse(result.isMatch());
+ }
+
+ @Test
+ public void testDistinctValuesReturned() throws HL7Exception, IOException {
+ HL7Query hl7Query = HL7Query.compile("DECLARE result1 AS REQUIRED OBX, result2 AS REQUIRED OBX SELECT MESSAGE WHERE result1.7 = 'L' OR result2.7 != 'H'");
+ QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+ assertEquals(1, result.getHitCount());
+ }
+
+ @Test
+ public void testAndWithParens() throws HL7Exception, IOException {
+ HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'L' AND result.3.1 = 'GLU'");
+ QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'L' AND result.3.1 = 'GLU'");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia")));
+ assertFalse(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'H' AND result.3.1 = 'GLU'");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertFalse(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.7 = 'H' AND result.3.1 = 'GLU'");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE (result.7 = 'H') AND (result.3.1 = 'GLU')");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE ((result.7 = 'H') AND (result.3.1 = 'GLU'))");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE (( ((result.7 = 'H')) AND ( ((result.3.1 = 'GLU')) )))");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hyperglycemia")));
+ assertTrue(result.isMatch());
+
+ }
+
+ @Test
+ public void testIsNull() throws HL7Exception, IOException {
+ HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.999 IS NULL");
+ QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.1 IS NULL");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertFalse(result.isMatch());
+
+ hl7Query = HL7Query.compile("SELECT MESSAGE WHERE ZZZ IS NULL");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("SELECT MESSAGE WHERE OBX IS NULL");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertFalse(result.isMatch());
+ }
+
+ @Test
+ public void testNotNull() throws HL7Exception, IOException {
+ HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.999 NOT NULL");
+ QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertFalse(result.isMatch());
+
+ hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.1 NOT NULL");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+
+ hl7Query = HL7Query.compile("SELECT MESSAGE WHERE ZZZ NOT NULL");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertFalse(result.isMatch());
+
+ hl7Query = HL7Query.compile("SELECT MESSAGE WHERE OBX NOT NULL");
+ result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
+ assertTrue(result.isMatch());
+ }
+
+ private HL7Message createMessage(final File file) throws HL7Exception, IOException {
+ final byte[] bytes = Files.readAllBytes(file.toPath());
+ final String msgText = new String(bytes, "UTF-8");
+
+ final HapiContext hapiContext = new DefaultHapiContext();
+ hapiContext.setValidationContext(ValidationContextFactory.noValidation());
+
+ final PipeParser parser = hapiContext.getPipeParser();
+ final Message message = parser.parse(msgText);
+ return new HapiMessage(message);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java b/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
index 3b427a7..4e3a502 100644
--- a/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
+++ b/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
@@ -360,7 +360,7 @@ public class NiFiProperties extends Properties {
/**
* The socket port to listen on for a Remote Input Port.
*
- * @return
+ * @return the remote input port
*/
public Integer getRemoteInputPort() {
return getPropertyAsPort(REMOTE_INPUT_PORT, DEFAULT_REMOTE_INPUT_PORT);
@@ -383,7 +383,7 @@ public class NiFiProperties extends Properties {
/**
* Returns the directory to which Templates are to be persisted
*
- * @return
+ * @return the template directory
*/
public Path getTemplateDirectory() {
final String strVal = getProperty(TEMPLATE_DIRECTORY);
@@ -414,7 +414,7 @@ public class NiFiProperties extends Properties {
* Returns the number of partitions that should be used for the FlowFile
* Repository
*
- * @return
+ * @return the number of partitions
*/
public int getFlowFileRepositoryPartitions() {
final String rawProperty = getProperty(FLOWFILE_REPOSITORY_PARTITIONS, DEFAULT_FLOWFILE_REPO_PARTITIONS);
@@ -425,7 +425,7 @@ public class NiFiProperties extends Properties {
* Returns the number of milliseconds between FlowFileRepository
* checkpointing
*
- * @return
+ * @return the number of milliseconds between checkpoint events
*/
public String getFlowFileRepositoryCheckpointInterval() {
return getProperty(FLOWFILE_REPOSITORY_CHECKPOINT_INTERVAL, DEFAULT_FLOWFILE_CHECKPOINT_INTERVAL);
@@ -504,7 +504,7 @@ public class NiFiProperties extends Properties {
public int getWebThreads() {
return getIntegerProperty(WEB_THREADS, DEFAULT_WEB_THREADS);
}
-
+
public File getWebWorkingDirectory() {
return new File(getProperty(WEB_WORKING_DIR, DEFAULT_WEB_WORKING_DIR));
}
@@ -551,7 +551,7 @@ public class NiFiProperties extends Properties {
/**
* Returns the auto refresh interval in seconds.
*
- * @return
+ * @return the interval over which the properties should auto refresh
*/
public String getAutoRefreshInterval() {
return getProperty(UI_AUTO_REFRESH_INTERVAL);
@@ -829,7 +829,7 @@ public class NiFiProperties extends Properties {
* values configured. No directories will be created as a result of this
* operation.
*
- * @return
+ * @return the name and paths of all provenance repository locations
*/
public Map<String, Path> getProvenanceRepositoryPaths() {
final Map<String, Path> provenanceRepositoryPaths = new HashMap<>();
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/CertificateUtils.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/CertificateUtils.java b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/CertificateUtils.java
index 087d891..5126933 100644
--- a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/CertificateUtils.java
+++ b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/CertificateUtils.java
@@ -36,10 +36,11 @@ public final class CertificateUtils {
/**
* Returns true if the given keystore can be loaded using the given keystore
* type and password. Returns false otherwise.
- * @param keystore
- * @param keystoreType
- * @param password
- * @return
+ *
+ * @param keystore the keystore to validate
+ * @param keystoreType the type of the keystore
+ * @param password the password to access the keystore
+ * @return true if valid; false otherwise
*/
public static boolean isStoreValid(final URL keystore, final KeystoreType keystoreType, final char[] password) {
@@ -81,8 +82,8 @@ public final class CertificateUtils {
* returned. If the CN cannot be extracted because the DN is in an
* unrecognized format, the entire DN is returned.
*
- * @param dn
- * @return
+ * @param dn the dn to extract the username from
+ * @return the exatracted username
*/
public static String extractUsername(String dn) {
String username = dn;
@@ -135,11 +136,11 @@ public final class CertificateUtils {
final List<String> result = new ArrayList<>();
for (final List<?> generalName : altNames) {
- /*
- * generalName has the name type as the first element a String or
- * byte array for the second element. We return any general names
+ /**
+ * generalName has the name type as the first element a String or
+ * byte array for the second element. We return any general names
* that are String types.
- *
+ *
* We don't inspect the numeric name type because some certificates
* incorrectly put IPs and DNS names under the wrong name types.
*/
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SecurityStoreTypes.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SecurityStoreTypes.java b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SecurityStoreTypes.java
index 9abfcc3..f448312 100644
--- a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SecurityStoreTypes.java
+++ b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SecurityStoreTypes.java
@@ -100,12 +100,12 @@ public enum SecurityStoreTypes {
/**
* Creates an instance.
*
- * @param storeProperty the Java system property for setting the keystore (
- * or truststore) path
+ * @param storeProperty the Java system property for setting the keystore or
+ * truststore path
* @param storePasswordProperty the Java system property for setting the
- * keystore (or truststore) password
+ * keystore or truststore path
* @param storeTypeProperty the Java system property for setting the
- * keystore (or truststore) type
+ * keystore or truststore type
*/
SecurityStoreTypes(final String storeProperty,
final String storePasswordProperty,
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SslContextFactory.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SslContextFactory.java b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SslContextFactory.java
index 2371b0c..aae8760 100644
--- a/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SslContextFactory.java
+++ b/nifi/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/SslContextFactory.java
@@ -60,12 +60,12 @@ public final class SslContextFactory {
* @param clientAuth the type of client authentication
*
* @return a SSLContext instance
- * @throws java.security.KeyStoreException
- * @throws java.io.IOException
- * @throws java.security.NoSuchAlgorithmException
- * @throws java.security.cert.CertificateException
- * @throws java.security.UnrecoverableKeyException
- * @throws java.security.KeyManagementException
+ * @throws java.security.KeyStoreException if any issues accessing the keystore
+ * @throws java.io.IOException for any problems loading the keystores
+ * @throws java.security.NoSuchAlgorithmException if an algorithm is found to be used but is unknown
+ * @throws java.security.cert.CertificateException if there is an issue with the certificate
+ * @throws java.security.UnrecoverableKeyException if the key is insufficient
+ * @throws java.security.KeyManagementException if unable to manage the key
*/
public static SSLContext createSslContext(
final String keystore, final char[] keystorePasswd, final String keystoreType,
@@ -113,12 +113,12 @@ public final class SslContextFactory {
* @param keystoreType the type of keystore (e.g., PKCS12, JKS)
*
* @return a SSLContext instance
- * @throws java.security.KeyStoreException
- * @throws java.io.IOException
- * @throws java.security.NoSuchAlgorithmException
- * @throws java.security.cert.CertificateException
- * @throws java.security.UnrecoverableKeyException
- * @throws java.security.KeyManagementException
+ * @throws java.security.KeyStoreException if any issues accessing the keystore
+ * @throws java.io.IOException for any problems loading the keystores
+ * @throws java.security.NoSuchAlgorithmException if an algorithm is found to be used but is unknown
+ * @throws java.security.cert.CertificateException if there is an issue with the certificate
+ * @throws java.security.UnrecoverableKeyException if the key is insufficient
+ * @throws java.security.KeyManagementException if unable to manage the key
*/
public static SSLContext createSslContext(
final String keystore, final char[] keystorePasswd, final String keystoreType)
@@ -149,12 +149,12 @@ public final class SslContextFactory {
* @param truststoreType the type of truststore (e.g., PKCS12, JKS)
*
* @return a SSLContext instance
- * @throws java.security.KeyStoreException
- * @throws java.io.IOException
- * @throws java.security.NoSuchAlgorithmException
- * @throws java.security.cert.CertificateException
- * @throws java.security.UnrecoverableKeyException
- * @throws java.security.KeyManagementException
+ * @throws java.security.KeyStoreException if any issues accessing the keystore
+ * @throws java.io.IOException for any problems loading the keystores
+ * @throws java.security.NoSuchAlgorithmException if an algorithm is found to be used but is unknown
+ * @throws java.security.cert.CertificateException if there is an issue with the certificate
+ * @throws java.security.UnrecoverableKeyException if the key is insufficient
+ * @throws java.security.KeyManagementException if unable to manage the key
*/
public static SSLContext createTrustSslContext(
final String truststore, final char[] truststorePasswd, final String truststoreType)
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/CoreAttributes.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/CoreAttributes.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/CoreAttributes.java
index 24f43ca..b0f4048 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/CoreAttributes.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/CoreAttributes.java
@@ -17,53 +17,50 @@
package org.apache.nifi.flowfile.attributes;
public enum CoreAttributes implements FlowFileAttributeKey {
+
/**
- * The flowfile's path indicates the relative directory to which a FlowFile belongs and does not
- * contain the filename
+ * The flowfile's path indicates the relative directory to which a FlowFile
+ * belongs and does not contain the filename
*/
PATH("path"),
-
/**
- * The flowfile's absolute path indicates the absolute directory to which a FlowFile belongs and does not
- * contain the filename
+ * The flowfile's absolute path indicates the absolute directory to which a
+ * FlowFile belongs and does not contain the filename
*/
ABSOLUTE_PATH("absolute.path"),
-
/**
- * The filename of the FlowFile. The filename should not contain any directory structure.
+ * The filename of the FlowFile. The filename should not contain any
+ * directory structure.
*/
FILENAME("filename"),
-
/**
* A unique UUID assigned to this FlowFile
*/
UUID("uuid"),
-
/**
* A numeric value indicating the FlowFile priority
*/
PRIORITY("priority"),
-
/**
* The MIME Type of this FlowFile
*/
MIME_TYPE("mime.type"),
-
/**
* Specifies the reason that a FlowFile is being discarded
*/
DISCARD_REASON("discard.reason"),
-
/**
- * Indicates an identifier other than the FlowFile's UUID that is known to refer to this FlowFile.
+ * Indicates an identifier other than the FlowFile's UUID that is known to
+ * refer to this FlowFile.
*/
ALTERNATE_IDENTIFIER("alternate.identifier");
-
+
private final String key;
+
private CoreAttributes(final String key) {
this.key = key;
}
-
+
@Override
public String key() {
return key;
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/FlowFileAttributeKey.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/FlowFileAttributeKey.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/FlowFileAttributeKey.java
index cc6c28e..9637631 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/FlowFileAttributeKey.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/flowfile/attributes/FlowFileAttributeKey.java
@@ -17,5 +17,6 @@
package org.apache.nifi.flowfile.attributes;
public interface FlowFileAttributeKey {
+
String key();
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/VersionNegotiator.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/VersionNegotiator.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/VersionNegotiator.java
index 74f9b3d..a05ea9d 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/VersionNegotiator.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/VersionNegotiator.java
@@ -29,7 +29,7 @@ public interface VersionNegotiator {
* Sets the version of this resource to the specified version. Only the
* lower byte of the version is relevant.
*
- * @param version
+ * @param version the version to set
* @throws IllegalArgumentException if the given Version is not supported by
* this resource, as is indicated by the {@link #isVersionSupported(int)}
* method
@@ -47,8 +47,8 @@ public interface VersionNegotiator {
* given maxVersion. If no acceptable version exists that is less than
* <code>maxVersion</code>, then <code>null</code> is returned
*
- * @param maxVersion
- * @return
+ * @param maxVersion the maximum version desired
+ * @return the preferred version if found; null otherwise
*/
Integer getPreferredVersion(int maxVersion);
@@ -56,8 +56,8 @@ public interface VersionNegotiator {
* Indicates whether or not the specified version is supported by this
* resource
*
- * @param version
- * @return
+ * @param version the version to test
+ * @return true if supported; false otherwise
*/
boolean isVersionSupported(int version);
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionInputStream.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionInputStream.java
index d953185..6434b2d 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionInputStream.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionInputStream.java
@@ -73,7 +73,7 @@ public class CompressionInputStream extends InputStream {
fillBuffer(fourByteBuffer);
compressedBuffer = new byte[toInt(fourByteBuffer)];
- bufferIndex = buffer.length; // indicate that buffer is empty
+ bufferIndex = buffer.length; // indicate that buffer is empty
}
private int toInt(final byte[] data) {
@@ -175,7 +175,8 @@ public class CompressionInputStream extends InputStream {
/**
* Does nothing. Does NOT close underlying InputStream
- * @throws java.io.IOException
+ *
+ * @throws java.io.IOException for any issues closing underlying stream
*/
@Override
public void close() throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionOutputStream.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionOutputStream.java
index bc46b0f..311c84c 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionOutputStream.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/CompressionOutputStream.java
@@ -61,7 +61,7 @@ public class CompressionOutputStream extends OutputStream {
* Compresses the currently buffered chunk of data and sends it to the
* output stream
*
- * @throws IOException
+ * @throws IOException if issues occur writing to stream
*/
protected void compressAndWrite() throws IOException {
if (bufferIndex <= 0) {
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/BufferStateManager.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/BufferStateManager.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/BufferStateManager.java
index 68913bd..e613155 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/BufferStateManager.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/BufferStateManager.java
@@ -42,7 +42,7 @@ public class BufferStateManager {
* resizing the buffer if necessary. This operation MAY change the direction
* of the buffer.
*
- * @param requiredSize
+ * @param requiredSize the desired size of the buffer
*/
public void ensureSize(final int requiredSize) {
if (buffer.capacity() < requiredSize) {
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInputStream.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInputStream.java
index 0ad0b74..1ec229d 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInputStream.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelInputStream.java
@@ -43,17 +43,17 @@ public class SocketChannelInputStream extends InputStream {
public void setTimeout(final int timeoutMillis) {
this.timeoutMillis = timeoutMillis;
}
-
+
public void consume() throws IOException {
channel.shutdownInput();
-
+
final byte[] b = new byte[4096];
final ByteBuffer buffer = ByteBuffer.wrap(b);
int bytesRead;
do {
bytesRead = channel.read(buffer);
buffer.flip();
- } while ( bytesRead > 0 );
+ } while (bytesRead > 0);
}
@Override
@@ -160,7 +160,8 @@ public class SocketChannelInputStream extends InputStream {
/**
* Closes the underlying socket channel.
- * @throws java.io.IOException
+ *
+ * @throws java.io.IOException for issues closing underlying stream
*/
@Override
public void close() throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutputStream.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutputStream.java
index 77049ad..a56d9dd 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutputStream.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/SocketChannelOutputStream.java
@@ -104,7 +104,8 @@ public class SocketChannelOutputStream extends OutputStream {
/**
* Closes the underlying SocketChannel
- * @throws java.io.IOException
+ *
+ * @throws java.io.IOException if issues closing underlying stream
*/
@Override
public void close() throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java
index 249ad48..1f23d79 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java
@@ -260,7 +260,7 @@ public class SSLSocketChannel implements Closeable {
public void consume() throws IOException {
channel.shutdownInput();
-
+
final byte[] b = new byte[4096];
final ByteBuffer buffer = ByteBuffer.wrap(b);
int readCount;
@@ -269,7 +269,7 @@ public class SSLSocketChannel implements Closeable {
buffer.flip();
} while (readCount > 0);
}
-
+
private int readData(final ByteBuffer dest) throws IOException {
final long startTime = System.currentTimeMillis();
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInputStream.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInputStream.java
index 6fb79d4..19179bc 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInputStream.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannelInputStream.java
@@ -30,7 +30,7 @@ public class SSLSocketChannelInputStream extends InputStream {
public void consume() throws IOException {
channel.consume();
}
-
+
@Override
public int read() throws IOException {
return channel.read();
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayOutputStream.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayOutputStream.java
index 459563b..bbc5cee 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayOutputStream.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteArrayOutputStream.java
@@ -98,8 +98,7 @@ public class ByteArrayOutputStream extends OutputStream {
newCapacity = minCapacity;
}
if (newCapacity < 0) {
- if (minCapacity < 0) // overflow
- {
+ if (minCapacity < 0) { // overflow
throw new OutOfMemoryError();
}
newCapacity = Integer.MAX_VALUE;
@@ -170,8 +169,7 @@ public class ByteArrayOutputStream extends OutputStream {
* @return the current contents of this output stream, as a byte array.
* @see java.io.ByteArrayOutputStream#size()
*/
- public byte toByteArray ()
- [] {
+ public byte[] toByteArray() {
return Arrays.copyOf(buf, count);
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingOutputStream.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingOutputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingOutputStream.java
index d8e1a42..3e3e3fe 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingOutputStream.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/ByteCountingOutputStream.java
@@ -39,8 +39,6 @@ public class ByteCountingOutputStream extends OutputStream {
write(b, 0, b.length);
}
- ;
-
@Override
public void write(byte[] b, int off, int len) throws IOException {
out.write(b, off, len);
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java
index ae075b5..ac6322d 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java
@@ -104,7 +104,7 @@ public class LeakyBucketStreamThrottler implements StreamThrottler {
@Override
public int read(final byte[] b) throws IOException {
- if(b.length == 0){
+ if (b.length == 0) {
return 0;
}
return read(b, 0, b.length);
@@ -112,13 +112,13 @@ public class LeakyBucketStreamThrottler implements StreamThrottler {
@Override
public int read(byte[] b, int off, int len) throws IOException {
- if ( len < 0 ) {
+ if (len < 0) {
throw new IllegalArgumentException();
}
- if ( len == 0 ) {
+ if (len == 0) {
return 0;
}
-
+
baos.reset();
final int copied = (int) LeakyBucketStreamThrottler.this.copy(toWrap, baos, len);
if (copied == 0) {
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LimitingInputStream.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LimitingInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LimitingInputStream.java
index 421d579..a657030 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LimitingInputStream.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LimitingInputStream.java
@@ -106,6 +106,6 @@ public class LimitingInputStream extends InputStream {
}
public long getLimit() {
- return limit;
+ return limit;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/MinimumLengthInputStream.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/MinimumLengthInputStream.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/MinimumLengthInputStream.java
index 2e93599..7d6d8d1 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/MinimumLengthInputStream.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/MinimumLengthInputStream.java
@@ -22,72 +22,71 @@ import java.io.IOException;
import java.io.InputStream;
/**
- * An InputStream that will throw EOFException if the underlying InputStream runs out of data before reaching the
- * configured minimum amount of data
+ * An InputStream that will throw EOFException if the underlying InputStream
+ * runs out of data before reaching the configured minimum amount of data
*/
public class MinimumLengthInputStream extends FilterInputStream {
- private final long minLength;
- private long consumedCount = 0L;
-
- public MinimumLengthInputStream(final InputStream in, final long minLength) {
- super(in);
- this.minLength = minLength;
- }
-
-
- @Override
- public int read() throws IOException {
- final int b = super.read();
- if ( b < 0 && consumedCount < minLength ) {
- throw new EOFException();
- }
-
- if ( b >= 0 ) {
- consumedCount++;
- }
-
- return b;
- }
-
- @Override
- public int read(byte[] b) throws IOException {
- return read(b, 0, b.length);
- }
-
- public int read(byte[] b, int off, int len) throws IOException {
- final int num = super.read(b, off, len);
-
- if ( num < 0 && consumedCount < minLength ) {
- throw new EOFException();
- }
-
- if ( num >= 0 ) {
- consumedCount += num;
- }
-
- return num;
- }
-
- @Override
- public long skip(final long n) throws IOException {
- long skipped = super.skip(n);
- if ( skipped < 1 ) {
- final int b = super.read();
- if ( b >= 0 ) {
- skipped = 1;
- }
- }
-
- if ( skipped < 0 && consumedCount < minLength ) {
- throw new EOFException();
- }
-
- if ( skipped >= 0 ) {
- consumedCount += skipped;
- }
-
- return skipped;
- }
-
+ private final long minLength;
+ private long consumedCount = 0L;
+
+ public MinimumLengthInputStream(final InputStream in, final long minLength) {
+ super(in);
+ this.minLength = minLength;
+ }
+
+ @Override
+ public int read() throws IOException {
+ final int b = super.read();
+ if (b < 0 && consumedCount < minLength) {
+ throw new EOFException();
+ }
+
+ if (b >= 0) {
+ consumedCount++;
+ }
+
+ return b;
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException {
+ return read(b, 0, b.length);
+ }
+
+ public int read(byte[] b, int off, int len) throws IOException {
+ final int num = super.read(b, off, len);
+
+ if (num < 0 && consumedCount < minLength) {
+ throw new EOFException();
+ }
+
+ if (num >= 0) {
+ consumedCount += num;
+ }
+
+ return num;
+ }
+
+ @Override
+ public long skip(final long n) throws IOException {
+ long skipped = super.skip(n);
+ if (skipped < 1) {
+ final int b = super.read();
+ if (b >= 0) {
+ skipped = 1;
+ }
+ }
+
+ if (skipped < 0 && consumedCount < minLength) {
+ throw new EOFException();
+ }
+
+ if (skipped >= 0) {
+ consumedCount += skipped;
+ }
+
+ return skipped;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java
index 8e3d606..101a546 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/StreamUtils.java
@@ -44,10 +44,10 @@ public class StreamUtils {
* <code>destination</code>. If <code>numBytes</code> are not available from
* <code>source</code>, throws EOFException
*
- * @param source
- * @param destination
- * @param numBytes
- * @throws IOException
+ * @param source the source of bytes to copy
+ * @param destination the destination to copy bytes to
+ * @param numBytes the number of bytes to copy
+ * @throws IOException if any issues occur while copying
*/
public static void copy(final InputStream source, final OutputStream destination, final long numBytes) throws IOException {
final byte[] buffer = new byte[8192];
@@ -68,9 +68,9 @@ public class StreamUtils {
* byte array. If the InputStream has less data than the given byte array,
* throws an EOFException
*
- * @param source
- * @param destination
- * @throws IOException
+ * @param source the source to copy bytes from
+ * @param destination the destination to fill
+ * @throws IOException if any issues occur reading bytes
*/
public static void fillBuffer(final InputStream source, final byte[] destination) throws IOException {
fillBuffer(source, destination, true);
@@ -82,12 +82,12 @@ public class StreamUtils {
* throws an EOFException if <code>ensureCapacity</code> is true and
* otherwise returns the number of bytes copied
*
- * @param source
- * @param destination
+ * @param source the source to read bytes from
+ * @param destination the destination to fill
* @param ensureCapacity whether or not to enforce that the InputStream have
* at least as much data as the capacity of the destination byte array
- * @return
- * @throws IOException
+ * @return the number of bytes actually filled
+ * @throws IOException if unable to read from the underlying stream
*/
public static int fillBuffer(final InputStream source, final byte[] destination, final boolean ensureCapacity) throws IOException {
int bytesRead = 0;
@@ -114,19 +114,19 @@ public class StreamUtils {
* <code>stoppers</code> parameter (returns the byte pattern matched). The
* bytes in the stopper will be copied.
*
- * @param in
- * @param out
- * @param maxBytes
- * @param stoppers
+ * @param in the source to read bytes from
+ * @param out the destination to write bytes to
+ * @param maxBytes the max bytes to copy
+ * @param stoppers patterns of bytes which if seen will cause the copy to stop
* @return the byte array matched, or null if end of stream was reached
- * @throws IOException
+ * @throws IOException if issues occur reading or writing bytes to the underlying streams
*/
public static byte[] copyInclusive(final InputStream in, final OutputStream out, final int maxBytes, final byte[]... stoppers) throws IOException {
if (stoppers.length == 0) {
return null;
}
- final List<NonThreadSafeCircularBuffer> circularBuffers = new ArrayList<NonThreadSafeCircularBuffer>();
+ final List<NonThreadSafeCircularBuffer> circularBuffers = new ArrayList<>();
for (final byte[] stopper : stoppers) {
circularBuffers.add(new NonThreadSafeCircularBuffer(stopper));
}
@@ -157,12 +157,12 @@ public class StreamUtils {
* byte pattern matched will NOT be copied to the output and will be un-read
* from the input.
*
- * @param in
- * @param out
- * @param maxBytes
- * @param stoppers
+ * @param in the source to read bytes from
+ * @param out the destination to write bytes to
+ * @param maxBytes the maximum number of bytes to copy
+ * @param stoppers byte patterns which will cause the copy to stop if found
* @return the byte array matched, or null if end of stream was reached
- * @throws IOException
+ * @throws IOException for issues reading or writing to underlying streams
*/
public static byte[] copyExclusive(final InputStream in, final OutputStream out, final int maxBytes, final byte[]... stoppers) throws IOException {
if (stoppers.length == 0) {
@@ -171,7 +171,7 @@ public class StreamUtils {
int longest = 0;
NonThreadSafeCircularBuffer longestBuffer = null;
- final List<NonThreadSafeCircularBuffer> circularBuffers = new ArrayList<NonThreadSafeCircularBuffer>();
+ final List<NonThreadSafeCircularBuffer> circularBuffers = new ArrayList<>();
for (final byte[] stopper : stoppers) {
final NonThreadSafeCircularBuffer circularBuffer = new NonThreadSafeCircularBuffer(stopper);
if (stopper.length > longest) {
@@ -220,9 +220,9 @@ public class StreamUtils {
*
* If unable to skip that number of bytes, throws EOFException
*
- * @param stream
- * @param bytesToSkip
- * @throws IOException
+ * @param stream the stream to skip over
+ * @param bytesToSkip the number of bytes to skip
+ * @throws IOException if any issues reading or skipping underlying stream
*/
public static void skip(final InputStream stream, final long bytesToSkip) throws IOException {
if (bytesToSkip <= 0) {
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/util/NonThreadSafeCircularBuffer.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/util/NonThreadSafeCircularBuffer.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/util/NonThreadSafeCircularBuffer.java
index b4b4c17..f18d824 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/util/NonThreadSafeCircularBuffer.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/util/NonThreadSafeCircularBuffer.java
@@ -38,7 +38,7 @@ public class NonThreadSafeCircularBuffer {
/**
* Returns the oldest byte in the buffer
*
- * @return
+ * @return the oldest byte
*/
public int getOldestByte() {
return buffer[insertionPointer];
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/EscapeUtils.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/EscapeUtils.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/EscapeUtils.java
index 9d48d3d..b7a663c 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/EscapeUtils.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/EscapeUtils.java
@@ -19,24 +19,25 @@ package org.apache.nifi.util;
public class EscapeUtils {
/**
- * Escapes the specified html by replacing &, <, >, ", ', /
- * with their corresponding html entity. If html is null, null is returned.
- *
- * @param html
- * @return
+ * Escapes the specified html by replacing &, <, >, ", ',
+ * / with their corresponding html entity. If html is null, null is
+ * returned.
+ *
+ * @param html to escape
+ * @return escaped html
*/
public static String escapeHtml(String html) {
if (html == null) {
return null;
}
-
+
html = html.replace("&", "&");
html = html.replace("<", "<");
html = html.replace(">", ">");
html = html.replace("\"", """);
html = html.replace("'", "'");
html = html.replace("/", "/");
-
+
return html;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java
index 805223f..03afec0 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java
@@ -49,8 +49,8 @@ public class FormatUtils {
/**
* Formats the specified count by adding commas.
*
- * @param count
- * @return
+ * @param count the value to add commas to
+ * @return the string representation of the given value with commas included
*/
public static String formatCount(final long count) {
return NumberFormat.getIntegerInstance().format(count);
@@ -59,9 +59,9 @@ public class FormatUtils {
/**
* Formats the specified duration in 'mm:ss.SSS' format.
*
- * @param sourceDuration
- * @param sourceUnit
- * @return
+ * @param sourceDuration the duration to format
+ * @param sourceUnit the unit to interpret the duration
+ * @return representation of the given time data in minutes/seconds
*/
public static String formatMinutesSeconds(final long sourceDuration, final TimeUnit sourceUnit) {
final long millis = TimeUnit.MILLISECONDS.convert(sourceDuration, sourceUnit);
@@ -72,9 +72,9 @@ public class FormatUtils {
/**
* Formats the specified duration in 'HH:mm:ss.SSS' format.
*
- * @param sourceDuration
- * @param sourceUnit
- * @return
+ * @param sourceDuration the duration to format
+ * @param sourceUnit the unit to interpret the duration
+ * @return representation of the given time data in hours/minutes/seconds
*/
public static String formatHoursMinutesSeconds(final long sourceDuration, final TimeUnit sourceUnit) {
final long millis = TimeUnit.MILLISECONDS.convert(sourceDuration, sourceUnit);
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9faaef8c/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java
index 85bfd96..b7831de 100644
--- a/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java
+++ b/nifi/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java
@@ -60,12 +60,10 @@ public class NaiveSearchRingBuffer {
}
/**
- * Returns the contents of the internal buffer, which represents the last X
+ * @return the contents of the internal buffer, which represents the last X
* bytes added to the buffer, where X is the minimum of the number of bytes
* added to the buffer or the length of the byte sequence for which we are
* looking
- *
- * @return
*/
public byte[] getBufferContents() {
final int contentLength = Math.min(lookingFor.length, bufferSize);
@@ -78,20 +76,16 @@ public class NaiveSearchRingBuffer {
}
/**
- * Returns the oldest byte in the buffer
- *
- * @return
+ * @return the oldest byte in the buffer
*/
public int getOldestByte() {
return buffer[insertionPointer];
}
/**
- * Returns <code>true</code> if the number of bytes that have been added to
+ * @return <code>true</code> if the number of bytes that have been added to
* the buffer is at least equal to the length of the byte sequence for which
* we are searching
- *
- * @return
*/
public boolean isFilled() {
return bufferSize >= buffer.length;
@@ -110,7 +104,7 @@ public class NaiveSearchRingBuffer {
* Add the given byte to the buffer and notify whether or not the byte
* completes the desired byte sequence.
*
- * @param data
+ * @param data the data to add to the buffer
* @return <code>true</code> if this byte completes the byte sequence,
* <code>false</code> otherwise.
*/