當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。