@Override public int getCode(String symbol) throws IndexConverterException { return converter.getCode(getBase(symbol)); }
@Override public int getCode(String symbol) throws IndexConverterException { if (!symbol.contains("_")) return innerConverter.getCode(symbol); String[] split = symbol.split("_"); if (split.length != 2 || split[1].length() == 0) throw new IndexConverterException(); if (split[1].charAt(0) == '{') { if (split[1].length() < 3) throw new IndexConverterException(); split[1] = split[1].substring(1, split[1].length() - 1); } int num; try { num = Integer.parseInt(split[1]); } catch (NumberFormatException e) { throw new IndexConverterException(); } return (num) * (1 + innerConverter.maxNumberOfSymbols()) + innerConverter.getCode(split[0]); }
/** * Returns integer representation from specified string representation of single * index. * * @param index string representation of single index * @return integer representation of specified index * @throws IllegalArgumentException if rule for specified string */ public int getCode(String index) { try { for (IndexSymbolConverter converter : converters) if (converter.applicableToSymbol(index)) return (converter.getCode(index) & 0xFFFF) | ((converter.getType() & 0x7F) << 24); throw new IllegalArgumentException("No available converters for such symbol : " + index); } catch (IndexConverterException e) { throw new IllegalArgumentException("No available converters for such symbol : " + index); } } }