private void printProblemXML(IMarker marker, Document doc, StringBuilder sb)
      throws JavaModelException, CoreException {
    Object[] attribs = marker.getAttributes(MARKER_ATTRIBUTES);
    String problemType;
    int lineNumber = 0;
    int startOfLine = 0;
    int lineLength = 0;
    String lineOfCode = "";
    try {
      lineNumber = Integer.parseInt(attribs[1].toString()) - 1;
      startOfLine = doc.getLineOffset(lineNumber);
      lineLength = doc.getLineLength(lineNumber);
      lineOfCode = doc.get(startOfLine, lineLength);
    } catch (NumberFormatException e) {
      e.printStackTrace(Constants.writer);
    } catch (BadLocationException e) {
      e.printStackTrace(Constants.writer);
    }

    if (attribs[0].equals(IMarker.SEVERITY_ERROR)) problemType = "ERROR";
    else if (attribs[0].equals(IMarker.SEVERITY_WARNING)) problemType = "WARNING";
    else problemType = "INFORMATION";

    sb.append("<" + problemType + ">");
    sb.append("<LINE>" + attribs[1] + "</LINE>");
    sb.append("<MESSAGE>" + attribs[2] + "</MESSAGE>");
    sb.append("<CODELINE>" + lineOfCode.trim() + "</CODELINE>");
    sb.append("</" + problemType + ">");
  }
 private String getLineContent(Document document, int line) {
   try {
     int lineOffset = document.getLineOffset(line - 1);
     int lineLength = document.getLineLength(line - 1);
     return document.get(lineOffset, lineLength);
   } catch (BadLocationException e) {
     return null;
   }
 }