コード例 #1
0
  /** Calculate a location message for the event */
  private String getLocation(ValidationEvent event) {
    StringBuffer msg = new StringBuffer();

    ValidationEventLocator locator = event.getLocator();

    if (locator != null) {

      URL url = locator.getURL();
      Object obj = locator.getObject();
      Node node = locator.getNode();
      int line = locator.getLineNumber();

      if (url != null || line != -1) {
        msg.append("line " + line);
        if (url != null) msg.append(" of " + url);
      } else if (obj != null) {
        msg.append(" obj: " + obj.toString());
      } else if (node != null) {
        msg.append(" node: " + node.toString());
      }
    } else {
      msg.append(Messages.format(Messages.LOCATION_UNAVAILABLE));
    }

    return msg.toString();
  }
コード例 #2
0
 @Override
 public boolean handleEvent(ValidationEvent validationEvent) {
   ValidationEventLocator locator = validationEvent.getLocator();
   lineNumber = locator.getLineNumber();
   columnNumber = locator.getColumnNumber();
   message = validationEvent.getMessage();
   return false;
 }
コード例 #3
0
 @Override
 public boolean handleEvent(ValidationEvent ve) {
   if (ve.getSeverity() == ValidationEvent.FATAL_ERROR
       || ve.getSeverity() == ValidationEvent.ERROR) {
     ValidationEventLocator locator = ve.getLocator();
     log.error(
         "{}: {} at line={}, column={}",
         locator.getURL(),
         ve.getMessage(),
         locator.getLineNumber(),
         locator.getColumnNumber());
     foundErrors = true;
   }
   return true;
 }
コード例 #4
0
  public boolean handleEvent(ValidationEvent event) {
    ValidationEventLocator loc = event.getLocator();
    String file = loc.getURL().getFile();
    try {
      file = URLDecoder.decode(file, "UTF-8");
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    int lastSlash = file.lastIndexOf('/');
    if (lastSlash > 0) file = file.substring(lastSlash + 1);

    String errorMsg = event.getMessage();
    if (errorMsg == null) {
      Throwable t = event.getLinkedException();
      while (t != null && errorMsg == null) {
        errorMsg = t.getMessage();
        t = t.getCause();
      }
    }

    JOptionPane.showMessageDialog(
        null,
        "<html><h3>Failed to load a custom map</h3><p><i>"
            + errorMsg
            + "</i></p><br><p>file: \"<b>"
            + file
            + "</b>\"<br>line/column: <i>"
            + loc.getLineNumber()
            + "/"
            + loc.getColumnNumber()
            + "</i></p>",
        "Error: custom map loading failed",
        JOptionPane.ERROR_MESSAGE);
    log.error(event.toString());
    return false;
  }
コード例 #5
0
ファイル: JaxbUtil.java プロジェクト: pj164/fawkez
 private void appendLocator(final StringBuffer sb, ValidationEventLocator locator) {
   if (locator != null) {
     if (locator.getObject() != null) {
       sb.append("Object: ");
       sb.append(locator.getObject());
       appendSpace(sb);
     }
     if (locator.getNode() != null) {
       sb.append("Node: ");
       sb.append(locator.getObject());
       appendSpace(sb);
     }
     if (locator.getOffset() >= 0) {
       sb.append("Offset: ");
       sb.append(locator.getOffset());
       appendSpace(sb);
     }
   }
 }