static ByteString fixName(ByteString name) { if (keyWords.contains(name)) { ByteBuffer buf = new ByteBuffer(); buf.append('_'); buf.append(name); return buf.toByteString(); } ByteString result = name; ByteString current = name; boolean match = true; while (match) { int len = current.length(); match = false; for (ByteString reservedPostfixe : reservedPostfixes) { if (current.endsWith(reservedPostfixe)) { ByteBuffer buf = new ByteBuffer(); buf.append('_'); buf.append(result); result = buf.toByteString(); int resultLen = reservedPostfixe.length(); if (len > resultLen) current = current.substring(0, len - resultLen); else current = new ByteString(""); match = true; break; } } } return name; }