Java 类org.jdom.IllegalDataException 实例源码

项目:geowave    文件:JDOMUtils.java   
static private void addSanitizedContent(
        final Element e,
        final String val ) {
    try {
        e.addContent(val);
    }
    catch (final IllegalDataException ide) {
        LOGGER.warn(
                "Unable to add content",
                ide);
        // Unless a better idea can be found, we need to replace all
        // unparseable characters with a space as a placeholder
        final StringBuffer newVal = new StringBuffer();
        for (int i = 0, len = val.length(); i < len; i++) {
            if (Verifier.isXMLCharacter(val.charAt(i))) {
                newVal.append(val.charAt(i));
            }
            else {
                newVal.append(' ');
            }
        }
        e.addContent(newVal.toString());
    }
}
项目:intellij-ce-playground    文件:MethodParameterInjection.java   
private void readOldFormat(final Element e) {
  final JDOMExternalizableStringList list = new JDOMExternalizableStringList();
  try {
    list.readExternal(e);
  }
  catch (IllegalDataException ignored) {
  }
  if (list.isEmpty()) return;
  final boolean[] selection = new boolean[list.size()];
  for (int i = 0; i < list.size(); i++) {
    selection[i] = Boolean.parseBoolean(list.get(i));
  }
  final String methodSignature = fixSignature(JDOMExternalizer.readString(e, "METHOD"), false);
  myParameterMap.put(methodSignature, new MethodInfo(methodSignature, selection, false));
}
项目:intellij-ce-playground    文件:DefaultInspectionToolPresentation.java   
private void exportResults(@NotNull final CommonProblemDescriptor[] descriptors, @NotNull RefEntity refEntity, @NotNull Element parentNode) {
  for (CommonProblemDescriptor descriptor : descriptors) {
    @NonNls final String template = descriptor.getDescriptionTemplate();
    int line = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getLineNumber() : -1;
    final PsiElement psiElement = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getPsiElement() : null;
    @NonNls String problemText = StringUtil.replace(StringUtil.replace(template, "#ref", psiElement != null ? ProblemDescriptorUtil
      .extractHighlightedText(descriptor, psiElement) : ""), " #loc ", " ");

    Element element = refEntity.getRefManager().export(refEntity, parentNode, line);
    if (element == null) return;
    @NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
    problemClassElement.addContent(myToolWrapper.getDisplayName());
    if (refEntity instanceof RefElement){
      final RefElement refElement = (RefElement)refEntity;
      final HighlightSeverity severity = getSeverity(refElement);
      ProblemHighlightType problemHighlightType = descriptor instanceof ProblemDescriptor
                                                  ? ((ProblemDescriptor)descriptor).getHighlightType()
                                                  : ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
      final String attributeKey = getTextAttributeKey(refElement.getRefManager().getProject(), severity, problemHighlightType);
      problemClassElement.setAttribute("severity", severity.myName);
      problemClassElement.setAttribute("attribute_key", attributeKey);
    }
    element.addContent(problemClassElement);
    if (myToolWrapper instanceof GlobalInspectionToolWrapper) {
      final GlobalInspectionTool globalInspectionTool = ((GlobalInspectionToolWrapper)myToolWrapper).getTool();
      final QuickFix[] fixes = descriptor.getFixes();
      if (fixes != null) {
        @NonNls Element hintsElement = new Element("hints");
        for (QuickFix fix : fixes) {
          final String hint = globalInspectionTool.getHint(fix);
          if (hint != null) {
            @NonNls Element hintElement = new Element("hint");
            hintElement.setAttribute("value", hint);
            hintsElement.addContent(hintElement);
          }
        }
        element.addContent(hintsElement);
      }
    }
    try {
      Element descriptionElement = new Element(InspectionsBundle.message("inspection.export.results.description.tag"));
      descriptionElement.addContent(problemText);
      element.addContent(descriptionElement);
    }
    catch (IllegalDataException e) {
      //noinspection HardCodedStringLiteral,UseOfSystemOutOrSystemErr
      System.out.println("Cannot save results for " + refEntity.getName() + ", inspection which caused problem: " + myToolWrapper.getShortName());
    }
  }
}
项目:tools-idea    文件:DefaultInspectionToolPresentation.java   
private void exportResults(@NotNull final CommonProblemDescriptor[] descriptors, @NotNull RefEntity refEntity, @NotNull Element parentNode) {
  for (CommonProblemDescriptor descriptor : descriptors) {
    @NonNls final String template = descriptor.getDescriptionTemplate();
    int line = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getLineNumber() : -1;
    final PsiElement psiElement = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getPsiElement() : null;
    @NonNls String problemText = StringUtil.replace(StringUtil.replace(template, "#ref", psiElement != null ? ProblemDescriptorUtil
      .extractHighlightedText(descriptor, psiElement) : ""), " #loc ", " ");

    Element element = refEntity.getRefManager().export(refEntity, parentNode, line);
    if (element == null) return;
    @NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
    problemClassElement.addContent(myToolWrapper.getDisplayName());
    if (refEntity instanceof RefElement){
      final RefElement refElement = (RefElement)refEntity;
      final HighlightSeverity severity = getSeverity(refElement, getContext(), getToolWrapper());
      ProblemHighlightType problemHighlightType = descriptor instanceof ProblemDescriptor
                                                  ? ((ProblemDescriptor)descriptor).getHighlightType()
                                                  : ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
      final String attributeKey = getTextAttributeKey(refElement.getRefManager().getProject(), severity, problemHighlightType);
      problemClassElement.setAttribute("severity", severity.myName);
      problemClassElement.setAttribute("attribute_key", attributeKey);
    }
    element.addContent(problemClassElement);
    if (myToolWrapper instanceof GlobalInspectionToolWrapper) {
      final GlobalInspectionTool globalInspectionTool = ((GlobalInspectionToolWrapper)myToolWrapper).getTool();
      final QuickFix[] fixes = descriptor.getFixes();
      if (fixes != null) {
        @NonNls Element hintsElement = new Element("hints");
        for (QuickFix fix : fixes) {
          final String hint = globalInspectionTool.getHint(fix);
          if (hint != null) {
            @NonNls Element hintElement = new Element("hint");
            hintElement.setAttribute("value", hint);
            hintsElement.addContent(hintElement);
          }
        }
        element.addContent(hintsElement);
      }
    }
    try {
      Element descriptionElement = new Element(InspectionsBundle.message("inspection.export.results.description.tag"));
      descriptionElement.addContent(problemText);
      element.addContent(descriptionElement);
    }
    catch (IllegalDataException e) {
      //noinspection HardCodedStringLiteral,UseOfSystemOutOrSystemErr
      System.out.println("Cannot save results for " + refEntity.getName() + ", inspection which caused problem: " + myToolWrapper.getShortName());
    }
  }
}
项目:consulo    文件:DefaultInspectionToolPresentation.java   
private void exportResults(@Nonnull final CommonProblemDescriptor[] descriptors, @Nonnull RefEntity refEntity, @Nonnull Element parentNode) {
  for (CommonProblemDescriptor descriptor : descriptors) {
    @NonNls final String template = descriptor.getDescriptionTemplate();
    int line = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getLineNumber() : -1;
    final PsiElement psiElement = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getPsiElement() : null;
    @NonNls String problemText = StringUtil.replace(StringUtil.replace(template, "#ref", psiElement != null ? ProblemDescriptorUtil
            .extractHighlightedText(descriptor, psiElement) : ""), " #loc ", " ");

    Element element = refEntity.getRefManager().export(refEntity, parentNode, line);
    if (element == null) return;
    @NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
    problemClassElement.addContent(myToolWrapper.getDisplayName());
    if (refEntity instanceof RefElement){
      final RefElement refElement = (RefElement)refEntity;
      final HighlightSeverity severity = getSeverity(refElement);
      ProblemHighlightType problemHighlightType = descriptor instanceof ProblemDescriptor
                                                  ? ((ProblemDescriptor)descriptor).getHighlightType()
                                                  : ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
      final String attributeKey = getTextAttributeKey(refElement.getRefManager().getProject(), severity, problemHighlightType);
      problemClassElement.setAttribute("severity", severity.myName);
      problemClassElement.setAttribute("attribute_key", attributeKey);
    }
    element.addContent(problemClassElement);
    if (myToolWrapper instanceof GlobalInspectionToolWrapper) {
      final GlobalInspectionTool globalInspectionTool = ((GlobalInspectionToolWrapper)myToolWrapper).getTool();
      final QuickFix[] fixes = descriptor.getFixes();
      if (fixes != null) {
        @NonNls Element hintsElement = new Element("hints");
        for (QuickFix fix : fixes) {
          final String hint = globalInspectionTool.getHint(fix);
          if (hint != null) {
            @NonNls Element hintElement = new Element("hint");
            hintElement.setAttribute("value", hint);
            hintsElement.addContent(hintElement);
          }
        }
        element.addContent(hintsElement);
      }
    }
    try {
      Element descriptionElement = new Element(InspectionsBundle.message("inspection.export.results.description.tag"));
      descriptionElement.addContent(problemText);
      element.addContent(descriptionElement);
    }
    catch (IllegalDataException e) {
      //noinspection HardCodedStringLiteral,UseOfSystemOutOrSystemErr
      System.out.println("Cannot save results for " + refEntity.getName() + ", inspection which caused problem: " + myToolWrapper.getShortName());
    }
  }
}