@Override public String getSymbol(int code, OutputFormat mode) throws IndexConverterException { int number = code + 0x41; if (number > 0x5A) throw new IndexConverterException(); return Character.toString((char) number); }
@Override public String getSymbol(int code, OutputFormat mode) throws IndexConverterException { int number = code + 0x61; if (number > 0x7A) throw new IndexConverterException(); return Character.toString((char) number); }
@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]); }
@Override public int getCode(String symbol) throws IndexConverterException { int code; if ((code = latexConverter.getCode(symbol)) < 0 && (code = utfConverter.getCode(symbol)) < 0) throw new IndexConverterException("Unknown index: " + symbol); return code; }
@Override public String getSymbol(int code, OutputFormat mode) throws IndexConverterException { String symbol; try { if (mode.is(OutputFormat.UTF8)) return utf[code]; symbol = symbols[code]; } catch (ArrayIndexOutOfBoundsException e) { throw new IndexConverterException(); } if (mode.is(OutputFormat.WolframMathematica)) symbol = "\\[" + Character.toUpperCase(symbol.charAt(1)) + symbol.substring(2) + "]"; if (mode.is(OutputFormat.Maple)) symbol = symbol.substring(1); return symbol; }