当前位置: 首页>>代码示例>>Java>>正文


Java ValidationEvent.getMessage方法代码示例

本文整理汇总了Java中javax.xml.bind.ValidationEvent.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java ValidationEvent.getMessage方法的具体用法?Java ValidationEvent.getMessage怎么用?Java ValidationEvent.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.bind.ValidationEvent的用法示例。


在下文中一共展示了ValidationEvent.getMessage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reportError

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
public void reportError( ValidationEvent ve ) throws SAXException {
    ValidationEventHandler handler;

    try {
        handler = marshaller.getEventHandler();
    } catch( JAXBException e ) {
        throw new SAXException2(e);
    }

    if(!handler.handleEvent(ve)) {
        if(ve.getLinkedException() instanceof Exception)
            throw new SAXException2((Exception)ve.getLinkedException());
        else
            throw new SAXException2(ve.getMessage());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:XMLSerializer.java

示例2: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
/**
 * Reports an error to the user, and asks if s/he wants
 * to recover. If the canRecover flag is false, regardless
 * of the client instruction, an exception will be thrown.
 *
 * Only if the flag is true and the user wants to recover from an error,
 * the method returns normally.
 *
 * The thrown exception will be catched by the unmarshaller.
 */
public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
    ValidationEventHandler eventHandler = parent.getEventHandler();

    boolean recover = eventHandler.handleEvent(event);

    // if the handler says "abort", we will not return the object
    // from the unmarshaller.getResult()
    if(!recover)    aborted = true;

    if( !canRecover || !recover )
        throw new SAXParseException2( event.getMessage(), locator,
            new UnmarshalException(
                event.getMessage(),
                event.getLinkedException() ) );
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:UnmarshallingContext.java

示例3: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
/**
 * Rather than ignore any XML parsing events, we will log these with a
 * short message indicating where the parsing failed accompanied with
 * a corresponding stack trace.  An exception is not being thrown
 * because the events could be benign and we would not want to halt
 * execution of the process.  For example, if the Amazon Pay API's
 * started returning a new element in the XML that the SDK did not
 * know about, that's OK, and we don't want to kill the program
 * because something new is discovered.
 */
public boolean handleEvent(ValidationEvent event) {
    try {
        String message = "XML Parse Event at "
                + "Line " + event.getLocator().getLineNumber()
                + ", Column " + event.getLocator().getColumnNumber()
                + ": Message=" + event.getMessage();

        StringWriter sw = new StringWriter();
        new Exception(message).printStackTrace(new PrintWriter(sw));
        log.debug(sw.toString());

    } catch (Exception e) {
        throw new AmazonClientException("Encountered an Exception: ", e);
    }

    return true;
}
 
开发者ID:amzn,项目名称:amazon-pay-sdk-java,代码行数:28,代码来源:AmazonValidationEventHandler.java

示例4: formatEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
public static String formatEvent(ValidationEvent e) {
    StringBuilder sb = new StringBuilder();
    if (e.getLocator() != null) {
        appendLocator(sb, e.getLocator());
    }
    if (e.getMessage() != null) {
        sb.append(e.getMessage());
        if (e.getLinkedException() != null) {
            sb.append(" - ");
        }
    }
    if (e.getLinkedException() != null) {
        sb.append(e.getLinkedException().toString());
    }
    return sb.toString();
}
 
开发者ID:TAXIIProject,项目名称:java-taxii,代码行数:17,代码来源:ValidationErrorHandler.java

示例5: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
@Override
public boolean handleEvent(ValidationEvent validationEvent) {
	ValidationEventLocator locator = validationEvent.getLocator();
	lineNumber = locator.getLineNumber();
	columnNumber = locator.getColumnNumber();
	message = validationEvent.getMessage();
	return false;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:JaxbHelper.java

示例6: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
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;
}
 
开发者ID:bh4017,项目名称:mobac,代码行数:30,代码来源:CustomMapSourceLoader.java

示例7: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
public boolean handleEvent(ValidationEvent event) {
    String msg = event.getMessage();
    if (msg.startsWith("cvc-type.3.1.2: ")
        && msg.contains(marshaller.getLastMTOMElementName().getLocalPart())) {
        return true;
    }
    if (origHandler != null) {
        return origHandler.handleEvent(event);
    }
    return false;
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:12,代码来源:DataWriterImpl.java

示例8: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
public boolean handleEvent(ValidationEvent event) {
    String msg = event.getMessage();
    if (msg.contains(":Id") 
        && (msg.startsWith("cvc-type.3.1.1: ") 
            || msg.startsWith("cvc-type.3.2.2: ") 
            || msg.startsWith("cvc-complex-type.3.1.1: ")
            || msg.startsWith("cvc-complex-type.3.2.2: "))) {
        return true;
    }
    if (origHandler != null) {
        return origHandler.handleEvent(event);
    }
    return false;
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:15,代码来源:DataReaderImpl.java

示例9: handleEvent

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
public final boolean handleEvent (@Nonnull final ValidationEvent aEvent)
{
  final IErrorLevel aErrorLevel = getErrorLevel (aEvent.getSeverity ());
  final SingleErrorBuilder aErrBuilder = SingleError.builder ().setErrorLevel (aErrorLevel);

  final ValidationEventLocator aLocator = aEvent.getLocator ();
  aErrBuilder.setErrorLocation (new SimpleLocation (getLocationResourceID (aLocator),
                                                   aLocator != null ? aLocator.getLineNumber ()
                                                                    : ILocation.ILLEGAL_NUMBER,
                                                   aLocator != null ? aLocator.getColumnNumber ()
                                                                    : ILocation.ILLEGAL_NUMBER))
             .setErrorFieldName (getErrorFieldName (aLocator));

  // Message may be null in some cases (e.g. when a linked exception is
  // present), but is not allowed to be null!
  String sMsg = aEvent.getMessage ();
  if (sMsg == null)
  {
    if (aEvent.getLinkedException () != null)
    {
      sMsg = aEvent.getLinkedException ().getMessage ();
      if (sMsg == null)
        sMsg = "Exception";
    }
    else
    {
      // Does this ever happen????
      sMsg = "Validation event";
    }
  }
  aErrBuilder.setErrorText (sMsg).setLinkedException (aEvent.getLinkedException ());

  // call our callback
  onEvent (aErrBuilder.build ());

  // Continue processing?
  return continueProcessing (aErrorLevel);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:39,代码来源:AbstractValidationEventHandler.java

示例10: toResponse

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
@Override
public Response toResponse(LensJAXBValidationException e) {
  ValidationEvent event = e.getEvent();
  ValidationEventLocator vel = event.getLocator();
  String msg = "XML Validation Exception:  " + event.getMessage() + " at row: " + vel.getLineNumber() + " column: "
    + vel.getColumnNumber();
  LensAPIResult lensAPIResult =
    LensAPIResult.composedOf(null, new MappedDiagnosticLogSegregationContext().getLogSegragationId(),
      LensErrorTO.composedOf(LensCommonErrorCode.INVALID_XML_ERROR.getValue(), msg,
        Arrays.toString(e.getStackTrace())), Response.Status.BAD_REQUEST);
  return Response.status(Response.Status.BAD_REQUEST).entity(lensAPIResult).build();
}
 
开发者ID:apache,项目名称:lens,代码行数:13,代码来源:LensJAXBValidationExceptionMapper.java

示例11: validationEventToString

import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
private static String validationEventToString(final ValidationEvent validationEvent) {
    return validationEvent.getMessage() +
            " at line " +
            validationEvent.getLocator().getLineNumber() +
            " col " + validationEvent.getLocator().getColumnNumber();
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:7,代码来源:StatisticsMarshaller.java


注:本文中的javax.xml.bind.ValidationEvent.getMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。