[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jibx-cvs
Subject:    [Jibx-cvs] core/build/src/org/jibx/runtime/impl UnmarshallingContext.java,1.7,1.8
From:       Dennis Sosnoski <dsosnoski () users ! sourceforge ! net>
Date:       2005-06-24 20:06:24
Message-ID: E1DluRU-00079n-V9 () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/jibx/core/build/src/org/jibx/runtime/impl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27440/build/src/org/jibx/runtime/impl

Modified Files:
	UnmarshallingContext.java 
Log Message:
Improve reporting of problems getting unmarshaller, and start tag/end tag not found errors.

Index: UnmarshallingContext.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/runtime/impl/UnmarshallingContext.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** UnmarshallingContext.java	30 Mar 2005 19:24:14 -0000	1.7
--- UnmarshallingContext.java	24 Jun 2005 20:06:21 -0000	1.8
***************
*** 730,739 ****
  
      /**
!      * Parse to start of element. Ignores
!      * character data to next start or end tag, but throws exception if an
!      * end tag is seen before a start tag, or if the start tag seen does
!      * not match the expected name. Leaves the parse positioned at the
       * start tag.
!      *
       * @param ns namespace URI for expected element (may be <code>null</code>
       * or the empty string for the empty namespace)
--- 730,738 ----
  
      /**
!      * Internal parse to expected start tag. Ignores character data seen prior
!      * to a start tag, but throws exception if an end tag or the end of the
!      * document is seen before a start tag. Leaves the parser positioned at the
       * start tag.
!      * 
       * @param ns namespace URI for expected element (may be <code>null</code>
       * or the empty string for the empty namespace)
***************
*** 741,759 ****
       * @throws JiBXException on any error (possibly wrapping other exception)
       */
!     public void parseToStartTag(String ns, String name) throws JiBXException {
!         if (toStart().equals(name) && verifyNamespace(ns)) {
!             return;
          } else {
!             throwStartTagNameError(ns, name);
          }
      }
  
      /**
!      * Parse past start of element. Ignores
!      * character data to next start or end tag, but throws exception if an
!      * end tag is seen before a start tag, or if the start tag seen does
!      * not match the expected name. Leaves the parse positioned following
!      * the start tag.
!      *
       * @param ns namespace URI for expected element (may be <code>null</code>
       * or the empty string for the empty namespace)
--- 740,776 ----
       * @throws JiBXException on any error (possibly wrapping other exception)
       */
!     private void matchStart(String ns, String name) throws JiBXException {
!         if (toTag() == XmlPullParser.START_TAG) {
!             if (!m_parser.getName().equals(name) || !verifyNamespace(ns)) {
!                 throwStartTagNameError(ns, name);
!             }
          } else {
!             throw new JiBXException("Expected " + buildNameString(ns, name)
!                 + " start tag, found " + currentNameString() + " end tag "
!                 + buildPositionString());
          }
      }
  
      /**
!      * Parse to start of element. Ignores character data to next start or end
!      * tag, but throws exception if an end tag is seen before a start tag, or if
!      * the start tag seen does not match the expected name. Leaves the parse
!      * positioned at the start tag.
!      * 
!      * @param ns namespace URI for expected element (may be <code>null</code>
!      * or the empty string for the empty namespace)
!      * @param name element name expected
!      * @throws JiBXException on any error (possibly wrapping other exception)
!      */
!     public void parseToStartTag(String ns, String name) throws JiBXException {
!         matchStart(ns, name);
!     }
! 
!     /**
!      * Parse past start of element. Ignores character data to next start or end
!      * tag, but throws exception if an end tag is seen before a start tag, or if
!      * the start tag seen does not match the expected name. Leaves the parse
!      * positioned following the start tag.
!      * 
       * @param ns namespace URI for expected element (may be <code>null</code>
       * or the empty string for the empty namespace)
***************
*** 762,770 ****
       */
      public void parsePastStartTag(String ns, String name) throws JiBXException {
!         if (toStart().equals(name) && verifyNamespace(ns)) {
!             advance();
!         } else {
!             throwStartTagNameError(ns, name);
!         }
      }
  
--- 779,784 ----
       */
      public void parsePastStartTag(String ns, String name) throws JiBXException {
!         matchStart(ns, name);
!         advance();
      }
  
***************
*** 791,800 ****
  
      /**
!      * Parse past end of element. Ignores
!      * character data to next start or end tag, but throws exception if a
!      * start tag is seen before a end tag, or if the end tag seen does
!      * not match the expected name. Leaves the parse positioned following
!      * the end tag.
!      *
       * @param ns namespace URI for expected element (may be <code>null</code>
       * or the empty string for the empty namespace)
--- 805,813 ----
  
      /**
!      * Parse past end of element. Ignores character data to next start or end
!      * tag, but throws exception if a start tag is seen before a end tag, or if
!      * the end tag seen does not match the expected name. Leaves the parse
!      * positioned following the end tag.
!      * 
       * @param ns namespace URI for expected element (may be <code>null</code>
       * or the empty string for the empty namespace)
***************
*** 803,810 ****
       */
      public void parsePastEndTag(String ns, String name) throws JiBXException {
!         if (toEnd().equals(name) && verifyNamespace(ns)) {
!             advance();
!         } else {
!             throwEndTagNameError(ns, name);
          }
      }
--- 816,844 ----
       */
      public void parsePastEndTag(String ns, String name) throws JiBXException {
!         try {
!             
!             // most past current tag if start
!             int event = m_parser.getEventType();
!             if (event != XmlPullParser.END_TAG) {
!                 advance();
!                 event = toTag();
!             }
!             
!             // check for match on expected end tag
!             if (event == XmlPullParser.END_TAG) {
!                 if (m_parser.getName().equals(name) && verifyNamespace(ns)) {
!                     advance();
!                 } else {
!                     throwEndTagNameError(ns, name);
!                 }
!             } else {
!                 throw new JiBXException("Expected " + buildNameString(ns, name)
!                     + " end tag, found " + currentNameString() + " start tag "
!                     + buildPositionString());
!             }
!             
!         } catch (XmlPullParserException e) {
!             throw new JiBXException
!                 ("Error parsing document " + buildPositionString(), e);
          }
      }
***************
*** 2360,2369 ****
              
              // load the unmarshaller class and create an instance
!             Exception ex = null;
              try {
                  
                  // first try loading class from context classloader
                  Class clas = null;
!                 String name = m_unmarshallerClasses[index];
                  ClassLoader loader =
                      Thread.currentThread().getContextClassLoader();
--- 2394,2407 ----
              
              // load the unmarshaller class and create an instance
!             String name = m_unmarshallerClasses[index];
!             if (name == null) {
!                 throw new JiBXException
!                     ("No unmarshaller defined for class at index " + index);
!             }
              try {
                  
                  // first try loading class from context classloader
                  Class clas = null;
!                 
                  ClassLoader loader =
                      Thread.currentThread().getContextClassLoader();
***************
*** 2384,2401 ****
                  m_unmarshallers[index] = um;
                  
!             } catch (ClassNotFoundException e) {
!                 ex = e;
!             } catch (ClassCastException e) {
!                 ex = e;
!             } catch (InstantiationException e) {
!                 ex = e;
!             } catch (IllegalAccessException e) {
!                 ex = e;
!             } finally {
!                 if (ex != null) {
!                     throw new JiBXException
!                         ("Unable to create unmarshaller of class " +
!                         m_unmarshallerClasses[index] + ": " + ex, ex);
!                 }
              }
          }
--- 2422,2428 ----
                  m_unmarshallers[index] = um;
                  
!             } catch (Exception e) {
!                 throw new JiBXException
!                     ("Unable to create unmarshaller of class " + name + ":", e);
              }
          }



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Jibx-cvs mailing list
Jibx-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic