private boolean checkNumber(char ch) throws UcumException { if (ch == '+' || ch == '-') { token = String.valueOf(ch); ch = peekChar(); while ((ch >= '0' && ch <= '9')) { token = token + ch; index++; ch = peekChar(); } if (token.length() == 1) { throw new UcumException("Error processing unit'"+source+"': unexpected character '"+ch+"' at position "+Integer.toString(start)+": a + or - must be followed by at least one digit"); } type = TokenType.NUMBER; return true; } else return false; }
private boolean checkNumberOrSymbol(char ch) throws UcumException { boolean isSymbol = false; boolean inBrackets = false; if (isValidSymbolChar(ch, true)) { token = String.valueOf(ch); isSymbol = isSymbol || !((ch >= '0' && ch <= '9')); inBrackets = checkBrackets(ch, inBrackets); ch = peekChar(); inBrackets = checkBrackets(ch, inBrackets); while (isValidSymbolChar(ch, !isSymbol || inBrackets)) { token = token + ch; isSymbol = isSymbol || ((ch != NO_CHAR) && !((ch >= '0' && ch <= '9'))); index++; ch = peekChar(); inBrackets = checkBrackets(ch, inBrackets); } if (isSymbol) type = TokenType.SYMBOL; else type = TokenType.NUMBER; return true; } else return false; }
private boolean checkNumber(char ch) throws UcumException { if (ch == '+' || ch == '-') { token = String.valueOf(ch); ch = peekChar(); while ((ch >= '0' && ch <= '9')) { token = token + ch; index++; ch = peekChar(); } if (token.length() == 1) { throw new UcumException("Error processing unit'"+source+"': unexpected character '"+ch+"' at position "+Integer.toString(start)+": a + or - must be followed by at least one digit"); } type = TokenType.NUMBER; return true; } else return false; }
private boolean checkNumberOrSymbol(char ch) throws UcumException { boolean isSymbol = false; boolean inBrackets = false; if (isValidSymbolChar(ch, true)) { token = String.valueOf(ch); isSymbol = isSymbol || !((ch >= '0' && ch <= '9')); inBrackets = checkBrackets(ch, inBrackets); ch = peekChar(); inBrackets = checkBrackets(ch, inBrackets); while (isValidSymbolChar(ch, !isSymbol || inBrackets)) { token = token + ch; isSymbol = isSymbol || ((ch != NO_CHAR) && !((ch >= '0' && ch <= '9'))); index++; ch = peekChar(); inBrackets = checkBrackets(ch, inBrackets); } if (isSymbol) type = TokenType.SYMBOL; else type = TokenType.NUMBER; return true; } else return false; }