[
https://issues.apache.org/jira/browse/NIFI-3145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15722568#comment-15722568
]
ASF GitHub Bot commented on NIFI-3145:
--------------------------------------
Github user mattyb149 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/1296#discussion_r90889705
--- Diff:
nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/util/NumberParsing.java
---
@@ -21,54 +21,57 @@
public class NumberParsing {
-
public static enum ParseResultType {
NOT_NUMBER, WHOLE_NUMBER, DECIMAL;
}
- private static final String Digits = "(\\p{Digit}+)";
-
- // Double regex according to Oracle documentation:
http://docs.oracle.com/javase/6/docs/api/java/lang/Double.html#valueOf%28java.lang.String%29
- private static final String HexDigits = "(\\p{XDigit}+)";
- // an exponent is 'e' or 'E' followed by an optionally
- // signed decimal integer.
- private static final String Exp = "[eE][+-]?"+Digits;
- private static final String fpRegex =
- ("[\\x00-\\x20]*"+ // Optional leading "whitespace"
- "[+-]?(" + // Optional sign character
- "NaN|" + // "NaN" string
- "Infinity|" + // "Infinity" string
-
- // A decimal floating-point string representing a
finite positive
- // number without a leading sign has at most five
basic pieces:
- // Digits . Digits ExponentPart FloatTypeSuffix
- //
- // Since this method allows integer-only strings as
input
- // in addition to strings of floating-point literals,
the
- // two sub-patterns below are simplifications of the
grammar
- // productions from the Java Language Specification,
2nd
- // edition, section 3.10.2.
-
- // Digits ._opt Digits_opt ExponentPart_opt
FloatTypeSuffix_opt
- "((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
-
- // . Digits ExponentPart_opt FloatTypeSuffix_opt
- "(\\.("+Digits+")("+Exp+")?)|"+
-
- // Hexadecimal strings
- "((" +
- // 0[xX] HexDigits ._opt BinaryExponent
FloatTypeSuffix_opt
- "(0[xX]" + HexDigits + "(\\.)?)|" +
-
- // 0[xX] HexDigits_opt . HexDigits BinaryExponent
FloatTypeSuffix_opt
- "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" +
-
- ")[pP][+-]?" + Digits + "))" +
- "[fFdD]?))" +
- "[\\x00-\\x20]*");// Optional trailing "whitespace"
-
- private static final Pattern DOUBLE_PATTERN = Pattern.compile(fpRegex);
-
- private static final Pattern NUMBER_PATTERN =
Pattern.compile("-?((\\d+)|(0[xX]" + HexDigits + "))");
+ private static final String OptionalSign = "[\\-\\+]?";
+
+ private static final String Infinity = "(Infinity)";
--- End diff --
Ah, I see it's only for the regex, not an actual token. I take that back :)
However in the future we may want to consider using the lexer/parser classes
(invoking a lower-level rule) so we don't have multiple ways of recognizing the
elements.
> Re-implement NumberParsing double expression
> --------------------------------------------
>
> Key: NIFI-3145
> URL: https://issues.apache.org/jira/browse/NIFI-3145
> Project: Apache NiFi
> Issue Type: Bug
> Reporter: Joseph Percivall
> Assignee: Joseph Percivall
> Priority: Blocker
> Fix For: 1.1.1
>
>
> It leverages sample code from the docs here
> http://docs.oracle.com/javase/6/docs/api/java/lang/Double.html#valueOf%28java.lang.String%29
> and it is unclear what terms those are under.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)