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


Java ValidationEventHandler.handleEvent方法代码示例

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


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

示例1: reportError

import javax.xml.bind.ValidationEventHandler; //导入方法依赖的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.ValidationEventHandler; //导入方法依赖的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: and

import javax.xml.bind.ValidationEventHandler; //导入方法依赖的package包/类
/**
 * Create an instance of {@link IValidationEventHandler} that invokes both
 * passed event handlers.
 *
 * @param aOne
 *        The first event handler. May be <code>null</code>.
 * @param aOther
 *        The second event handler. May be <code>null</code>.
 * @return Never <code>null</code>.
 * @since 8.6.0
 */
@Nonnull
static IValidationEventHandler and (@Nullable final ValidationEventHandler aOne,
                                    @Nullable final ValidationEventHandler aOther)
{
  if (aOne != null)
  {
    if (aOther != null)
      return x -> {
        if (!aOne.handleEvent (x))
        {
          // We should not continue
          return false;
        }
        return aOther.handleEvent (x);
      };
    return x -> aOne.handleEvent (x);
  }

  if (aOther != null)
    return x -> aOther.handleEvent (x);

  return x -> true;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:35,代码来源:IValidationEventHandler.java

示例4: reportError

import javax.xml.bind.ValidationEventHandler; //导入方法依赖的package包/类
public void reportError( ValidationEvent ve ) throws AbortSerializationException {
    ValidationEventHandler handler;
    
    try {
        handler = owner.getEventHandler();
    } catch( JAXBException e ) {
        throw new AbortSerializationException(e);
    }
    
    if(!handler.handleEvent(ve)) {
        if(ve.getLinkedException() instanceof Exception)
            throw new AbortSerializationException((Exception)ve.getLinkedException());
        else
            throw new AbortSerializationException(ve.getMessage());
    }
}
 
开发者ID:nhrdl,项目名称:javacash,代码行数:17,代码来源:SAXMarshaller.java

示例5: handleEvent

import javax.xml.bind.ValidationEventHandler; //导入方法依赖的package包/类
public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
    ValidationEventHandler eventHandler;
    try {
        eventHandler = parent.getEventHandler();
    } catch( JAXBException e ) {
        // impossible.
        throw new JAXBAssertionError();
    }

    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 SAXException( new UnmarshalException(
            event.getMessage(),
            event.getLinkedException() ) );
}
 
开发者ID:nhrdl,项目名称:javacash,代码行数:21,代码来源:SAXUnmarshallerHandlerImpl.java


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