You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by zi...@apache.org on 2003/12/17 08:05:36 UTC

cvs commit: xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal FailFastErrorHandler.java BindingContextImpl.java

zieg        2003/12/16 23:05:35

  Modified:    v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        BindingContextImpl.java
  Added:       v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        FailFastErrorHandler.java
  Log:
  temp fix to get fail fast behavior when an error collection is not provided.
  
  DRT: passed
  
  Revision  Changes    Path
  1.6       +4 -2      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BindingContextImpl.java
  
  Index: BindingContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BindingContextImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BindingContextImpl.java	16 Dec 2003 05:59:47 -0000	1.5
  +++ BindingContextImpl.java	17 Dec 2003 07:05:35 -0000	1.6
  @@ -112,8 +112,10 @@
       static Collection extractErrorHandler(XmlOptions options)
       {
           Collection underlying = (Collection)options.get(XmlOptions.ERROR_LISTENER);
  -        Collection errors = new XmlErrorWatcher(underlying);
  -        return errors;
  +        if (underlying != null)
  +            return underlying;
  +
  +        return FailFastErrorHandler.getInstance();
       }
   
   
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/FailFastErrorHandler.java
  
  Index: FailFastErrorHandler.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2000-2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.XmlError;
  import org.apache.xmlbeans.XmlRuntimeException;
  import org.apache.xmlbeans.impl.marshal.util.collections.EmptyIterator;
  
  import java.util.AbstractCollection;
  import java.util.Iterator;
  
  public class FailFastErrorHandler extends AbstractCollection
  {
      private static final FailFastErrorHandler INSTANCE =
          new FailFastErrorHandler();
  
      public static FailFastErrorHandler getInstance()
      {
          return INSTANCE;
      }
  
      private FailFastErrorHandler()
      {
      }
  
      //TODO: this is pretty ugly in that we are throwing a Runtime Exception
      //we really need to revisit the entire error propogation strategy.
      public boolean add(Object obj)
      {
          if (obj instanceof XmlError) {
              XmlError err = (XmlError)obj;
              throw new XmlRuntimeException(err);
          }
          throw new XmlRuntimeException("unknown error: " + obj);
      }
  
      public Iterator iterator()
      {
          return EmptyIterator.getInstance();
      }
  
      public int size()
      {
          return 0;
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org