boolean (StringBuilder buf, String pattern, int index, boolean oldInside) { char firstChar = pattern.charAt(index); boolean newInside = oldInside; //O and E are modifiers, they mean to present an alternative representation of the next char //we just handle the next char as if the O or E wasn't there if (firstChar == 'O' || firstChar == 'E') { if (index + 1 < pattern.length()) { newInside = translateCommand(buf, pattern, index + 1, oldInside); } else { buf.append(quote("%" + firstChar, oldInside)); } } else { String command = translate.get(String.valueOf(firstChar)); //If we don't find a format, treat it as a literal--That's what apache does if (command == null) { buf.append(quote("%" + firstChar, oldInside)); } else { //If we were inside quotes, close the quotes if (oldInside) { buf.append('\''); } buf.append(command); newInside = false; } } return newInside; }