Index: src/main/java/java/util/Scanner.java =================================================================== --- src/main/java/java/util/Scanner.java (revision 538081) +++ src/main/java/java/util/Scanner.java (working copy) @@ -78,18 +78,15 @@ LINE_TERMINATOR = Pattern.compile(terminator); - StringBuilder multiTerminator = new StringBuilder(); + CharSequence multiTerminator = new StringBuilder("(") //$NON-NLS-1$ + .append(terminator).append(")+"); //$NON-NLS-1$ MULTI_LINE_TERMINATOR = Pattern - .compile(multiTerminator.append("(") //$NON-NLS-1$ - .append(terminator) - .append(")+").toString()); //$NON-NLS-1$ - StringBuilder line = new StringBuilder(); + .compile(multiTerminator.toString()); + CharSequence line = new StringBuilder(".*(").append(terminator).append( //$NON-NLS-1$ + ")|.+(").append(terminator) //$NON-NLS-1$ + .append(")?"); //$NON-NLS-1$ LINE_PATTERN = Pattern - .compile(line.append(".*(") //$NON-NLS-1$ - .append(terminator) - .append(")|.+(") //$NON-NLS-1$ - .append(terminator) - .append(")?").toString()); //$NON-NLS-1$ + .compile(line.toString()); //$NON-NLS-1$ } // The pattern matches anything. @@ -531,12 +528,11 @@ } /** - * Returns true if this scanner has next token. This method may be blocked - * when it is waiting for input to scan. This scanner does not advance past - * the input. + * Returns true if both the predecessor and the successor of the token + * matches the default delimiter. Client may be blocked when invoking this + * method. The matched input will not be eaten on success. * - * @return true - * iff this scanner has next token + * @return true iff this scanner has next token * @throws IllegalStateException * if the scanner has been closed */ @@ -545,16 +541,15 @@ } /** - * Returns true if this scanner's next token matches the specified pattern. - * This method may be blocked when it is waiting for input to scan. This - * scanner does not advance past the input that matched the pattern. + * Returns true if both the predecessor and the successor of the token + * matches the specified delimiter. Client may be blocked when invoking this + * method. The matched input will not be eaten on success. * * @param pattern * the specified pattern to scan - * @return - * true iff this scanner's next token matches the specified pattern + * @return true iff this scanner's next token matches the specified pattern * @throws IllegalStateException - * if the scanner has been closed + * if the scanner has been closed */ public boolean hasNext(Pattern pattern) { checkClosed(); @@ -580,18 +575,13 @@ /** - * Returns true if this scanner's next token matches the pattern constructed - * from the specified string. This method may be blocked when it is waiting - * for input to scan. This scanner does not advance past the input that - * matched the pattern. + * Returns true if input matches the specified string pattern. Client may be + * blocked when invoking this method. The matched input will not be eaten on + * success. * - * The invocation of this method in the form hasNext(pattern) behaves in the - * same way as the invocation of hasNext(Pattern.compile(pattern)). - * * @param pattern - * the string specifying the pattern to scan for - * @return true - * iff this scanner's next token matches the specified pattern + * the specified pattern to scan + * @return true iff this scanner's next token matches the specified pattern * @throws IllegalStateException * if the scanner has been closed */ @@ -805,7 +795,7 @@ String intString = matcher.group(); intString = removeLocaleInfo(intString, DataType.INT); try { - cacheHasNextValue = Integer.valueOf(intString, radix); + cacheHasNextValue = Integer.valueOf(intString, radix); isIntValue = true; } catch (NumberFormatException e) { matchSuccessful = false; @@ -927,7 +917,7 @@ String intString = matcher.group(); intString = removeLocaleInfo(intString, DataType.INT); try { - cacheHasNextValue = Short.valueOf(intString, radix); + cacheHasNextValue = Short.valueOf(intString, radix); isShortValue = true; } catch (NumberFormatException e) { matchSuccessful = false; @@ -982,14 +972,11 @@ } /** - * Finds and Returns the next complete token which is prefixed and postfixed - * by input that matches the delimiter pattern. This method may be blocked - * when it is waiting for input to scan, even if a previous invocation of - * hasNext() returned true. If this match successes, the scanner advances - * past the next complete token. + * If input matches the default delimiter, a token will be returned. Client + * may be blocked when invoking this method , even if a previous call of + * hasNext() was not blocked. The matched input will be eaten on success. * - * @return - * the next complete token + * @return the next complete token * @throws IllegalStateException * if this scanner has been closed * @throws NoSuchElementException @@ -1000,17 +987,13 @@ } /** - * Returns the next token which is prefixed and postfixed by input that - * matches the delimiter pattern if this token matches the specified - * pattern. This method may be blocked when it is waiting for input to scan, - * even if a previous invocation of hasNext(Pattern) returned true. If this - * match successes, the scanner advances past the next token that matched - * the pattern. + * If input matches the specified pattern, a token will be returned. Client + * may be blocked when invoking this method , even if a previous call of + * hasNext() was not blocked. The matched input will be eaten on success. * * @param pattern * the specified pattern to scan - * @return - * the next token + * @return the next token * @throws IllegalStateException * if this scanner has been closed * @throws NoSuchElementException @@ -1062,9 +1045,8 @@ /** * Translates the next token in this scanner's input into a BigDecimal and * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextBigDecimal() - * returned true. If this match succeeds, the scanner advances past the - * input that matched. + * input to scan, even if a previous call of hasNextBigDecimal() + * was not blocked. The matched input will be eaten on success. * * If the next token matches the Float regular expression successfully, the * token is translated into a BigDecimal as following steps. At first all @@ -1084,13 +1066,13 @@ * BigDecimal */ public BigDecimal nextBigDecimal() { - checkClosed(); - Object obj = cacheHasNextValue; - cacheHasNextValue = null; - if (obj instanceof BigDecimal) { - findStartIndex = cachehasNextIndex; - return (BigDecimal) obj; - } + checkClosed(); + Object obj = cacheHasNextValue; + cacheHasNextValue = null; + if (obj instanceof BigDecimal) { + findStartIndex = cachehasNextIndex; + return (BigDecimal) obj; + } Pattern floatPattern = getFloatPattern(); String floatString = next(floatPattern); floatString = removeLocaleInfoFromFloat(floatString); @@ -1108,9 +1090,8 @@ /** * Translates the next token in this scanner's input into a BigInteger and * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextBigInteger() - * returned true. If this match succeeds, the scanner advances past the - * input that matched. + * input to scan, even if a previous call of hasNextBigInteger() + * was not blocked. The matched input will be eaten on success. * * The invocation of this method in the form nextBigInteger() behaves in the * same way as the invocation of nextBigInteger(radix), the radix is the @@ -1132,9 +1113,8 @@ /** * Translates the next token in this scanner's input into a BigInteger and * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextBigInteger(radix) - * returned true. If this match succeeds, the scanner advances past the - * input that matched. + * input to scan, even if a previous call of hasNextBigInteger(radix) + * was not blocked. The matched input will be eaten on success. * * If the next token matches the Integer regular expression successfully, * the token is translated into a BigInteger as following steps. At first @@ -1157,13 +1137,13 @@ * BigInteger, or it is out of range */ public BigInteger nextBigInteger(int radix) { - checkClosed(); - Object obj = cacheHasNextValue; - cacheHasNextValue = null; - if (obj instanceof BigInteger) { - findStartIndex = cachehasNextIndex; - return (BigInteger) obj; - } + checkClosed(); + Object obj = cacheHasNextValue; + cacheHasNextValue = null; + if (obj instanceof BigInteger) { + findStartIndex = cachehasNextIndex; + return (BigInteger) obj; + } Pattern integerPattern = getIntegerPattern(radix); String intString = next(integerPattern); intString = removeLocaleInfo(intString, DataType.INT); @@ -1179,11 +1159,9 @@ } /** - * Translates the next token in this scanner's input into a boolean value and - * returns this value. This method will throw InputMismatchException if the - * next token can not be interpreted as a boolean value with a case - * insensitive pattern created from the string "true|false". If this match - * succeeds, the scanner advances past the input that matched. + * Finds and Returns the next token, if it matches the boolean pattern. The + * matched input will be eaten on success. An InputMismatchException will be + * thrown if the input is not a valid boolean. * * @return the boolean value scanned from the input * @throws IllegalStateException @@ -1199,15 +1177,12 @@ } /** - * Translates the next token in this scanner's input into a byte value and - * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextByte() returned - * true. If this match succeeds, the scanner advances past the input that - * matched. + * Finds and Returns the next byte token. The matched input will be eaten on + * success. An InputMismatchException will be thrown if the input is not a + * valid byte. * - * The invocation of this method in the form nextByte() behaves in the same - * way as the invocation of nextByte(radix), the radix is the default radix - * of this scanner. + * This method invokes nextByte(radix), the radix is the default radix of + * this scanner. * * @return the byte value scanned from the input * @throws IllegalStateException @@ -1223,20 +1198,18 @@ } /** - * Translates the next token in this scanner's input into a byte value and - * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextByte(radix) - * returned true. If this match succeeds, the scanner advances past the - * input that matched. + * Finds and Returns the next byte token. The matched input will be eaten on + * success. An InputMismatchException will be thrown if the input is not a + * valid byte. * - * If the next token matches the Integer regular expression successfully, - * the token is translated into a byte value as following steps. At first - * all locale specific prefixes ,group separators, and locale specific - * suffixes are removed. Then non-ASCII digits are mapped into ASCII digits - * via {@link Character#digit(char, int)}}, a negative sign (-) is added if - * the locale specific negative prefixes and suffixes were present. At last - * the resulting String is passed to {@link Byte#parseByte(String, int)}} - * with the specified radix. + * If the input matches the Integer pattern, the matched token is translated + * into a byte value by following steps: First, all locale specific prefixes + * ,group separators, and locale specific suffixes are removed. Then + * non-ASCII digits are mapped into ASCII digits via + * {@link Character#digit(char, int)}}, a negative sign (-) is added if the + * locale specific negative prefixes and suffixes were present. At last, the + * resulting String is passed to {@link Byte#parseByte(String, int)}} with + * the specified radix. * * @param radix * the radix used to translate the token into byte value @@ -1251,13 +1224,13 @@ */ @SuppressWarnings("boxing") public byte nextByte(int radix) { - checkClosed(); - Object obj = cacheHasNextValue; - cacheHasNextValue = null; - if (obj instanceof Byte) { - findStartIndex = cachehasNextIndex; - return (Byte) obj; - } + checkClosed(); + Object obj = cacheHasNextValue; + cacheHasNextValue = null; + if (obj instanceof Byte) { + findStartIndex = cachehasNextIndex; + return (Byte) obj; + } Pattern integerPattern = getIntegerPattern(radix); String intString = next(integerPattern); intString = removeLocaleInfo(intString, DataType.INT); @@ -1275,9 +1248,8 @@ /** * Translates the next token in this scanner's input into a double value and * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextDouble() returned - * true. If this match succeeds, the scanner advances past the input that - * matched. + * input to scan, even if a previous call of hasNextDouble() was not blocked . + * The matched input will be eaten on success. * * If the next token matches the Float regular expression successfully, the * token is translated into a double value as following steps. At first all @@ -1302,13 +1274,13 @@ */ @SuppressWarnings("boxing") public double nextDouble() { - checkClosed(); - Object obj = cacheHasNextValue; - cacheHasNextValue = null; - if (obj instanceof Double) { - findStartIndex = cachehasNextIndex; - return (Double) obj; - } + checkClosed(); + Object obj = cacheHasNextValue; + cacheHasNextValue = null; + if (obj instanceof Double) { + findStartIndex = cachehasNextIndex; + return (Double) obj; + } Pattern floatPattern = getFloatPattern(); String floatString = next(floatPattern); floatString = removeLocaleInfoFromFloat(floatString); @@ -1326,9 +1298,8 @@ /** * Translates the next token in this scanner's input into a float value and * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextFloat() returned - * true. If this match succeeds, the scanner advances past the input that - * matched. + * input to scan, even if a previous call of hasNextFloat() was not blocked. + * The matched input will be eaten on success. * * If the next token matches the Float regular expression successfully, the * token is translated into a float value as following steps. At first all @@ -1351,13 +1322,13 @@ */ @SuppressWarnings("boxing") public float nextFloat() { - checkClosed(); - Object obj = cacheHasNextValue; - cacheHasNextValue = null; - if (obj instanceof Float) { - findStartIndex = cachehasNextIndex; - return (Float) obj; - } + checkClosed(); + Object obj = cacheHasNextValue; + cacheHasNextValue = null; + if (obj instanceof Float) { + findStartIndex = cachehasNextIndex; + return (Float) obj; + } Pattern floatPattern = getFloatPattern(); String floatString = next(floatPattern); floatString = removeLocaleInfoFromFloat(floatString); @@ -1375,9 +1346,8 @@ /** * Translates the next token in this scanner's input into an int value and * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextInt() returned - * true. If this match succeeds, the scanner advances past the input that - * matched. + * input to scan, even if a previous call of hasNextInt() was not + * blocked. The matched input will be eaten on success. * * The invocation of this method in the form nextInt() behaves in the same * way as the invocation of nextInt(radix), the radix is the default radix @@ -1399,9 +1369,8 @@ /** * Translates the next token in this scanner's input into an int value and * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextInt(radix) - * returned true. If this match succeeds, the scanner advances past the - * input that matched. + * input to scan, even if a previous call of hasNextInt(radix) + * was not blocked. The matched input will be eaten on success. * * If the next token matches the Integer regular expression successfully, * the token is translated into an int value as following steps. At first @@ -1424,13 +1393,13 @@ */ @SuppressWarnings("boxing") public int nextInt(int radix) { - checkClosed(); - Object obj = cacheHasNextValue; - cacheHasNextValue = null; - if (obj instanceof Integer) { - findStartIndex = cachehasNextIndex; - return (Integer) obj; - } + checkClosed(); + Object obj = cacheHasNextValue; + cacheHasNextValue = null; + if (obj instanceof Integer) { + findStartIndex = cachehasNextIndex; + return (Integer) obj; + } Pattern integerPattern = getIntegerPattern(radix); String intString=next(integerPattern); intString = removeLocaleInfo(intString, DataType.INT); @@ -1495,15 +1464,12 @@ } /** - * Translates the next token in this scanner's input into a long value and - * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextLong() returned - * true. If this match succeeds, the scanner advances past the input that - * matched. + * Finds and Returns the next long token. The matched input will be eaten on + * success. An InputMismatchException will be thrown if the input is not a + * valid long. * - * The invocation of this method in the form nextLong() behaves in the same - * way as the invocation of nextLong(radix), the radix is the default radix - * of this scanner. + * This method invokes nextLong(radix), the radix is the default radix of + * this scanner. * * @return the long value scanned from the input * @throws IllegalStateException @@ -1519,20 +1485,18 @@ } /** - * Translates the next token in this scanner's input into a long value and - * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextLong(radix) - * returned true. If this match succeeds, the scanner advances past the - * input that matched. + * Finds and Returns the next long token. The matched input will be eaten on + * success. An InputMismatchException will be thrown if the input is not a + * valid long. * - * If the next token matches the Integer regular expression successfully, - * the token is translated into a long value as following steps. At first - * all locale specific prefixes, group separators, and locale specific - * suffixes are removed. Then non-ASCII digits are mapped into ASCII digits - * via {@link Character#digit(char, int)}}, a negative sign (-) is added if - * the locale specific negative prefixes and suffixes were present. At last - * the resulting String is passed to {@link Long#parseLong(String, int)}} - * with the specified radix. + * If the input matches the Integer pattern, the matched token is translated + * into a long value by following steps: First, all locale specific prefixes + * ,group separators, and locale specific suffixes are removed. Then + * non-ASCII digits are mapped into ASCII digits via + * {@link Character#digit(char, int)}}, a negative sign (-) is added if the + * locale specific negative prefixes and suffixes were present. At last, the + * resulting String is passed to {@link Byte#parseLong(String, int)}} with + * the specified radix. * * @param radix * the radix used to translate the token into a long value @@ -1547,13 +1511,13 @@ */ @SuppressWarnings("boxing") public long nextLong(int radix) { - checkClosed(); - Object obj = cacheHasNextValue; - cacheHasNextValue = null; - if (obj instanceof Long) { - findStartIndex = cachehasNextIndex; - return (Long) obj; - } + checkClosed(); + Object obj = cacheHasNextValue; + cacheHasNextValue = null; + if (obj instanceof Long) { + findStartIndex = cachehasNextIndex; + return (Long) obj; + } Pattern integerPattern = getIntegerPattern(radix); String intString = next(integerPattern); intString = removeLocaleInfo(intString, DataType.INT); @@ -1571,9 +1535,8 @@ /** * Translates the next token in this scanner's input into a short value and * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextShort() returned - * true. If this match succeeds, the scanner advances past the input that - * matched. + * input to scan, even if a previous call of hasNextShort() was not blocked. + * The matched input will be eaten on success. * * The invocation of this method in the form nextShort() behaves in the same * way as the invocation of nextShort(radix), the radix is the default radix @@ -1595,9 +1558,8 @@ /** * Translates the next token in this scanner's input into a short value and * returns this value. This method may be blocked when it is waiting for - * input to scan, even if a previous invocation of hasNextShort(radix) - * returned true. If this match succeeds, the scanner advances past the - * input that matched. + * input to scan, even if a previous call of hasNextShort(radix) was not + * blocked. The matched input will be eaten on success. * * If the next token matches the Integer regular expression successfully, * the token is translated into a short value as following steps. At first @@ -1621,13 +1583,13 @@ */ @SuppressWarnings("boxing") public short nextShort(int radix) { - checkClosed(); - Object obj = cacheHasNextValue; - cacheHasNextValue = null; - if (obj instanceof Short) { - findStartIndex = cachehasNextIndex; - return (Short) obj; - } + checkClosed(); + Object obj = cacheHasNextValue; + cacheHasNextValue = null; + if (obj instanceof Short) { + findStartIndex = cachehasNextIndex; + return (Short) obj; + } Pattern integerPattern = getIntegerPattern(radix); String intString = next(integerPattern); intString = removeLocaleInfo(intString, DataType.INT); @@ -1878,13 +1844,13 @@ String ASCIIDigit=allAvailableDigits.substring(0, radix); String nonZeroASCIIDigit=allAvailableDigits.substring(1, radix); - StringBuilder digit = new StringBuilder("((?i)[").append(ASCIIDigit) //$NON-NLS-1$ + CharSequence digit = new StringBuilder("((?i)[").append(ASCIIDigit) //$NON-NLS-1$ .append("]|\\p{javaDigit})"); //$NON-NLS-1$ - StringBuilder nonZeroDigit = new StringBuilder("((?i)[").append( //$NON-NLS-1$ + CharSequence nonZeroDigit = new StringBuilder("((?i)[").append( //$NON-NLS-1$ nonZeroASCIIDigit).append("]|([\\p{javaDigit}&&[^0]]))"); //$NON-NLS-1$ - StringBuilder numeral = getNumeral(digit, nonZeroDigit); + CharSequence numeral = getNumeral(digit, nonZeroDigit); - StringBuilder integer = new StringBuilder("(([-+]?(").append(numeral) //$NON-NLS-1$ + CharSequence integer = new StringBuilder("(([-+]?(").append(numeral) //$NON-NLS-1$ .append(")))|(").append(addPositiveSign(numeral)).append(")|(") //$NON-NLS-1$ //$NON-NLS-2$ .append(addNegativeSign(numeral)).append(")"); //$NON-NLS-1$ @@ -1898,54 +1864,54 @@ private Pattern getFloatPattern() { decimalFormat = (DecimalFormat) NumberFormat.getInstance(locale); - StringBuilder digit = new StringBuilder("([0-9]|(\\p{javaDigit}))"); //$NON-NLS-1$ - StringBuilder nonZeroDigit = new StringBuilder("[\\p{javaDigit}&&[^0]]"); //$NON-NLS-1$ - StringBuilder numeral = getNumeral(digit, nonZeroDigit); + CharSequence digit = new StringBuilder("([0-9]|(\\p{javaDigit}))"); //$NON-NLS-1$ + CharSequence nonZeroDigit = new StringBuilder("[\\p{javaDigit}&&[^0]]"); //$NON-NLS-1$ + CharSequence numeral = getNumeral(digit, nonZeroDigit); String decimalSeparator = "\\" + decimalFormat.getDecimalFormatSymbols()//$NON-NLS-1$ .getDecimalSeparator(); - StringBuilder decimalNumeral = new StringBuilder("(").append(numeral) //$NON-NLS-1$ + CharSequence decimalNumeral = new StringBuilder("(").append(numeral) //$NON-NLS-1$ .append("|").append(numeral) //$NON-NLS-1$ .append(decimalSeparator).append(digit).append("*+|").append( //$NON-NLS-1$ decimalSeparator).append(digit).append("++)"); //$NON-NLS-1$ - StringBuilder exponent = new StringBuilder("([eE][+-]?").append(digit) //$NON-NLS-1$ + CharSequence exponent = new StringBuilder("([eE][+-]?").append(digit) //$NON-NLS-1$ .append("+)?"); //$NON-NLS-1$ - StringBuilder decimal = new StringBuilder("(([-+]?").append( //$NON-NLS-1$ + CharSequence decimal = new StringBuilder("(([-+]?").append( //$NON-NLS-1$ decimalNumeral).append("(").append(exponent).append("?)") //$NON-NLS-1$ //$NON-NLS-2$ .append(")|(").append(addPositiveSign(decimalNumeral)).append( //$NON-NLS-1$ "(").append(exponent).append("?)").append(")|(") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ .append(addNegativeSign(decimalNumeral)).append("(").append( //$NON-NLS-1$ exponent).append("?)").append("))"); //$NON-NLS-1$ //$NON-NLS-2$ - StringBuilder hexFloat = new StringBuilder("([-+]?0[xX][0-9a-fA-F]*") //$NON-NLS-1$ + CharSequence hexFloat = new StringBuilder("([-+]?0[xX][0-9a-fA-F]*") //$NON-NLS-1$ .append("\\.").append(//$NON-NLS-1$ "[0-9a-fA-F]+([pP][-+]?[0-9]+)?)"); //$NON-NLS-1$ String localNaN = decimalFormat.getDecimalFormatSymbols().getNaN(); String localeInfinity = decimalFormat.getDecimalFormatSymbols() .getInfinity(); - StringBuilder nonNumber = new StringBuilder("(NaN|\\Q").append(localNaN) //$NON-NLS-1$ + CharSequence nonNumber = new StringBuilder("(NaN|\\Q").append(localNaN) //$NON-NLS-1$ .append("\\E|Infinity|\\Q").append(localeInfinity).append("\\E)"); //$NON-NLS-1$ //$NON-NLS-2$ - StringBuilder singedNonNumber = new StringBuilder("((([-+]?(").append( //$NON-NLS-1$ + CharSequence singedNonNumber = new StringBuilder("((([-+]?(").append( //$NON-NLS-1$ nonNumber).append(")))|(").append(addPositiveSign(nonNumber)) //$NON-NLS-1$ .append(")|(").append(addNegativeSign(nonNumber)).append("))"); //$NON-NLS-1$ //$NON-NLS-2$ - StringBuilder floatString = new StringBuilder().append(decimal).append( + CharSequence floatString = new StringBuilder().append(decimal).append( "|").append(hexFloat).append("|").append(singedNonNumber); //$NON-NLS-1$ //$NON-NLS-2$ Pattern floatPattern = Pattern.compile(floatString.toString()); return floatPattern; } - private StringBuilder getNumeral(StringBuilder digit, - StringBuilder nonZeroDigit) { + private CharSequence getNumeral(CharSequence digit, + CharSequence nonZeroDigit) { String groupSeparator = "\\"//$NON-NLS-1$ + decimalFormat.getDecimalFormatSymbols() .getGroupingSeparator(); - StringBuilder groupedNumeral = new StringBuilder("(").append( //$NON-NLS-1$ + CharSequence groupedNumeral = new StringBuilder("(").append( //$NON-NLS-1$ nonZeroDigit).append(digit).append("?").append(digit).append( //$NON-NLS-1$ "?(").append(groupSeparator).append(digit).append(digit) //$NON-NLS-1$ .append(digit).append(")+)"); //$NON-NLS-1$ - StringBuilder numeral = new StringBuilder("((").append(digit).append( //$NON-NLS-1$ + CharSequence numeral = new StringBuilder("((").append(digit).append( //$NON-NLS-1$ "++)|").append(groupedNumeral).append(")"); //$NON-NLS-1$ //$NON-NLS-2$ return numeral; } @@ -1953,7 +1919,7 @@ /* * Add the locale specific positive prefixes and suffixes to the pattern */ - private StringBuilder addPositiveSign(StringBuilder unSignNumeral) { + private CharSequence addPositiveSign(CharSequence unSignNumeral) { String positivePrefix = ""; //$NON-NLS-1$ String positiveSuffix = ""; //$NON-NLS-1$ if (!decimalFormat.getPositivePrefix().equals("")) { //$NON-NLS-1$ @@ -1962,7 +1928,7 @@ if (!decimalFormat.getPositiveSuffix().equals("")) { //$NON-NLS-1$ positiveSuffix = "\\Q" + decimalFormat.getPositiveSuffix()+"\\E"; //$NON-NLS-1$ //$NON-NLS-2$ } - StringBuilder signedNumeral = new StringBuilder() + CharSequence signedNumeral = new StringBuilder() .append(positivePrefix).append(unSignNumeral).append( positiveSuffix); return signedNumeral; @@ -1971,7 +1937,7 @@ /* * Add the locale specific negative prefixes and suffixes to the pattern */ - private StringBuilder addNegativeSign(StringBuilder unSignNumeral) { + private CharSequence addNegativeSign(CharSequence unSignNumeral) { String negativePrefix = ""; //$NON-NLS-1$ String negativeSuffix = ""; //$NON-NLS-1$ if (!decimalFormat.getNegativePrefix().equals("")) { //$NON-NLS-1$ @@ -1980,7 +1946,7 @@ if (!decimalFormat.getNegativeSuffix().equals("")) { //$NON-NLS-1$ negativeSuffix = "\\Q" + decimalFormat.getNegativeSuffix()+"\\E"; //$NON-NLS-1$//$NON-NLS-2$ } - StringBuilder signedNumeral = new StringBuilder() + CharSequence signedNumeral = new StringBuilder() .append(negativePrefix).append(unSignNumeral).append( negativeSuffix); return signedNumeral; @@ -2287,4 +2253,4 @@ buffer.position(oldPosition); buffer.limit(oldLimit); } -} +} \ No newline at end of file