/** * Constructor. * * @param info input info * @param map decimal format * @throws QueryException query exception */ public DecFormatter(final InputInfo info, final TokenMap map) throws QueryException { // assign map values int z = '0'; if (map != null) { for (final byte[] key : map) { final String k = string(key); final byte[] v = map.get(key); if (k.equals(DF_INF)) { inf = v; } else if (k.equals(DF_NAN)) { nan = v; } else if (v.length != 0 && cl(v, 0) == v.length) { final int cp = cp(v, 0); switch (k) { case DF_DEC: decimal = cp; break; case DF_GRP: grouping = cp; break; case DF_EXP: exponent = cp; break; case DF_PAT: pattern = cp; break; case DF_MIN: minus = cp; break; case DF_DIG: optional = cp; break; case DF_PC: percent = cp; break; case DF_PM: permille = cp; break; case DF_ZD: z = zeroes(cp); if (z == -1) throw INVDECFORM_X_X.get(info, k, v); if (z != cp) throw INVDECZERO_X.get(info, (char) cp); break; } } else { // signs must have single character throw INVDECSINGLE_X_X.get(info, k, v); } } } // check for duplicate characters zero = z; final IntSet is = new IntSet(); for (int i = 0; i < 10; i++) is.add(zero + i); final int[] ss = {decimal, grouping, exponent, percent, permille, optional, pattern}; for (final int s : ss) if (!is.add(s)) throw DUPLDECFORM_X.get(info, (char) s); // create auxiliary strings final TokenBuilder tb = new TokenBuilder(); for (int i = 0; i < 10; i++) tb.add(zero + i); digits = tb.toArray(); // "decimal-separator-sign, exponent-separator-sign, grouping-sign, decimal-digit-family, // optional-digit-sign and pattern-separator-sign are classified as active characters" // -> decimal-digit-family: added above. pattern-separator-sign: will never occur at this stage actives = tb.add(decimal).add(exponent).add(grouping).add(optional).finish(); // "all other characters (including the percent-sign and per-mille-sign) are classified // as passive characters." }