< prev index next >

src/java.base/share/classes/java/util/Scanner.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


1280             LocaleProviderAdapter adapter = LocaleProviderAdapter
1281                     .getAdapter(NumberFormatProvider.class, locale);
1282             if (!(adapter instanceof ResourceBundleBasedAdapter)) {
1283                 adapter = LocaleProviderAdapter.getResourceBundleBased();
1284             }
1285             String[] all = adapter.getLocaleResources(locale)
1286                     .getNumberPatterns();
1287             df = new DecimalFormat(all[0], dfs);
1288         }
1289 
1290         // These must be literalized to avoid collision with regex
1291         // metacharacters such as dot or parenthesis
1292         groupSeparator =   "\\" + dfs.getGroupingSeparator();
1293         decimalSeparator = "\\" + dfs.getDecimalSeparator();
1294 
1295         // Quoting the nonzero length locale-specific things
1296         // to avoid potential conflict with metacharacters
1297         nanString = "\\Q" + dfs.getNaN() + "\\E";
1298         infinityString = "\\Q" + dfs.getInfinity() + "\\E";
1299         positivePrefix = df.getPositivePrefix();
1300         if (positivePrefix.length() > 0)
1301             positivePrefix = "\\Q" + positivePrefix + "\\E";
1302         negativePrefix = df.getNegativePrefix();
1303         if (negativePrefix.length() > 0)
1304             negativePrefix = "\\Q" + negativePrefix + "\\E";
1305         positiveSuffix = df.getPositiveSuffix();
1306         if (positiveSuffix.length() > 0)
1307             positiveSuffix = "\\Q" + positiveSuffix + "\\E";
1308         negativeSuffix = df.getNegativeSuffix();
1309         if (negativeSuffix.length() > 0)
1310             negativeSuffix = "\\Q" + negativeSuffix + "\\E";
1311 
1312         // Force rebuilding and recompilation of locale dependent
1313         // primitive patterns
1314         integerPattern = null;
1315         floatPattern = null;
1316 
1317         return this;
1318     }
1319 
1320     /**
1321      * Returns this scanner's default radix.
1322      *
1323      * <p>A scanner's radix affects elements of its default
1324      * number matching regular expressions; see
1325      * <a href= "#localized-numbers">localized numbers</a> above.
1326      *
1327      * @return the default radix of this scanner
1328      */
1329     public int radix() {




1280             LocaleProviderAdapter adapter = LocaleProviderAdapter
1281                     .getAdapter(NumberFormatProvider.class, locale);
1282             if (!(adapter instanceof ResourceBundleBasedAdapter)) {
1283                 adapter = LocaleProviderAdapter.getResourceBundleBased();
1284             }
1285             String[] all = adapter.getLocaleResources(locale)
1286                     .getNumberPatterns();
1287             df = new DecimalFormat(all[0], dfs);
1288         }
1289 
1290         // These must be literalized to avoid collision with regex
1291         // metacharacters such as dot or parenthesis
1292         groupSeparator =   "\\" + dfs.getGroupingSeparator();
1293         decimalSeparator = "\\" + dfs.getDecimalSeparator();
1294 
1295         // Quoting the nonzero length locale-specific things
1296         // to avoid potential conflict with metacharacters
1297         nanString = "\\Q" + dfs.getNaN() + "\\E";
1298         infinityString = "\\Q" + dfs.getInfinity() + "\\E";
1299         positivePrefix = df.getPositivePrefix();
1300         if (!positivePrefix.isEmpty())
1301             positivePrefix = "\\Q" + positivePrefix + "\\E";
1302         negativePrefix = df.getNegativePrefix();
1303         if (!negativePrefix.isEmpty())
1304             negativePrefix = "\\Q" + negativePrefix + "\\E";
1305         positiveSuffix = df.getPositiveSuffix();
1306         if (!positiveSuffix.isEmpty())
1307             positiveSuffix = "\\Q" + positiveSuffix + "\\E";
1308         negativeSuffix = df.getNegativeSuffix();
1309         if (!negativeSuffix.isEmpty())
1310             negativeSuffix = "\\Q" + negativeSuffix + "\\E";
1311 
1312         // Force rebuilding and recompilation of locale dependent
1313         // primitive patterns
1314         integerPattern = null;
1315         floatPattern = null;
1316 
1317         return this;
1318     }
1319 
1320     /**
1321      * Returns this scanner's default radix.
1322      *
1323      * <p>A scanner's radix affects elements of its default
1324      * number matching regular expressions; see
1325      * <a href= "#localized-numbers">localized numbers</a> above.
1326      *
1327      * @return the default radix of this scanner
1328      */
1329     public int radix() {


< prev index next >