code: public static String getNodeText(Node<?> node, InputBuffer inputBuffer) {
          checkArgNotNull(node, "node");
          checkArgNotNull(inputBuffer, "inputBuffer");
          if (node.hasError()) {
              // if the node has a parse error we cannot simply cut a string out of the underlying input buffer, since we
              // would also include illegal characters, so we need to build it constructively
              StringBuilder sb = new StringBuilder();
              for (int i = node.getStartIndex(); i < node.getEndIndex(); i++) {
                  char c = inputBuffer.charAt(i);
                  switch (c) {
                      case Chars.DEL_ERROR:
                          i++;
                          break;
                      case Chars.INS_ERROR:
                      case Chars.EOI:
                          break;
                      case Chars.RESYNC_START:
                          i++;
                          while (inputBuffer.charAt(i) != Chars.RESYNC_END) i++;
                          break;
                      case Chars.RESYNC_END:
                      case Chars.RESYNC_EOI:
                      case Chars.RESYNC:
                          // we should only see proper RESYNC_START / RESYNC_END blocks
                          throw new IllegalStateException();
                      default:
                          sb.append(c);
                  }
              }
              return sb.toString();
          }        
          return inputBuffer.extract(node.getStartIndex(), node.getEndIndex());
      }
docs: Returns the input text matched by the given node, with error correction.
  
  @param node        the node
  @param inputBuffer the underlying inputBuffer
  @return null if node is null otherwise a string with the matched input text (which can be empty)