@Override public int maxNumberOfSymbols() { return 10 * (innerConverter.maxNumberOfSymbols() + 1) - 1; } }
@Override public int maxNumberOfSymbols() { return converter.maxNumberOfSymbols(); }
@Override public String getSymbol(int code, OutputFormat mode) throws IndexConverterException { int subscript = code / (innerConverter.maxNumberOfSymbols() + 1); if (subscript == 0) return innerConverter.getSymbol(code, mode); else { String symbol = innerConverter.getSymbol(code % (innerConverter.maxNumberOfSymbols() + 1), mode); if (mode.is(OutputFormat.WolframMathematica)) return "Subscript[" + symbol + ", " + subscript + "]"; if (mode.is(OutputFormat.Maple)) return symbol + subscript; return symbol + "_" + ("{" + subscript + "}"); } }
@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]); }