Author: jochen Date: Sat Jan 20 19:00:40 2007 New Revision: 498237 URL: http://svn.apache.org/viewvc?view=rev&rev=498237 Log: Fixed an NPE when using minExclusive.
Modified: webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/parser/impl/AbstractXsSAXParser.java webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/xml/impl/XsTSimpleRestrictionTypeImpl.java webservices/jaxme/branches/b0_5/status.xml Modified: webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/parser/impl/AbstractXsSAXParser.java URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/parser/impl/AbstractXsSAXParser.java?view=diff&rev=498237&r1=498236&r2=498237 ============================================================================== --- webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/parser/impl/AbstractXsSAXParser.java (original) +++ webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/parser/impl/AbstractXsSAXParser.java Sat Jan 20 19:00:40 2007 @@ -34,289 +34,292 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a> */ public abstract class AbstractXsSAXParser implements ContentHandler, XsSAXParser { - private final static Class[] ZERO_CLASSES = new Class[0]; - private final static Object[] ZERO_OBJECTS = new Object[0]; - - private Object bean; - private int level; - private String qName, namespaceURI, localName; - private ContentHandler childHandler; - - protected abstract XSContext getData(); - - public AbstractXsSAXParser(Object pBean) { - bean = pBean; - } - - public Object getBean() { - return bean; - } - - public void setQName(String pQName) { - qName = pQName; - } - - public void setNamespaceURI(String pNamespaceURI) { - namespaceURI = pNamespaceURI; - } - - public String getNamespaceURI() { - return namespaceURI; - } - - public void setLocalName(String pLocalName) { - localName = pLocalName; - } - - public String getLocalName() { - return localName; - } - - public String getQName() { - return qName; - } - - public ContentHandler getChildHandler() { - return childHandler; - } - - public void startPrefixMapping(String pPrefix, String pURI) - throws SAXException { - if (childHandler == null) { - getData().getNamespaceSupport().declarePrefix(pPrefix, pURI); - } else { - childHandler.startPrefixMapping(pPrefix, pURI); - } - } - - public void endPrefixMapping(String pPrefix) throws SAXException { - if (childHandler != null) { - childHandler.endPrefixMapping(pPrefix); - } - } - - public void startDocument() throws SAXException { - getData().getNamespaceSupport().pushContext(); - } - - public void endDocument() throws SAXException { - getData().getNamespaceSupport().popContext(); - } - - public void characters(char[] pBuffer, int pOffset, int pLen) throws SAXException { - if (childHandler == null) { - try { - getData().getTextSetter().addText(new String(pBuffer, pOffset, pLen)); - } catch (SAXException e) { - throw e; - } catch (RuntimeException e) { - Exception ex = e; - for (;;) { - UndeclaredThrowableException te = null; - Throwable t; - if (ex instanceof UndeclaredThrowableException) { - te = ((UndeclaredThrowableException) ex); - t = te.getUndeclaredThrowable(); - } else if (ex instanceof InvocationTargetException) { - t = ((InvocationTargetException) ex).getTargetException(); - } else { - break; - } - if (t instanceof Exception) { - ex = (Exception) t; - } else { - if (te == null) { - te = new UndeclaredThrowableException(t); - } - t.printStackTrace(); - throw te; - } + private final static Class[] ZERO_CLASSES = new Class[0]; + private final static Object[] ZERO_OBJECTS = new Object[0]; + + private final Object bean; + private int level; + private String qName, namespaceURI, localName; + private ContentHandler childHandler; + + protected abstract XSContext getData(); + + public AbstractXsSAXParser(Object pBean) { + if (pBean == null) { + throw new NullPointerException("The target bean is null."); } - throw new LocSAXException(ex.getClass().getName() + ": " + ex.getMessage(), - getData().getLocator(), ex); - } - } else { - childHandler.characters(pBuffer, pOffset, pLen); - } - } - - public void ignorableWhitespace(char[] pBuffer, int pOffset, int pLen) - throws SAXException { - if (childHandler == null) { - characters(pBuffer, pOffset, pLen); - } else { - childHandler.ignorableWhitespace(pBuffer, pOffset, pLen); - } - } - - public void skippedEntity(String pEntity) throws SAXException { - if (childHandler == null) { - throw new LocSAXException("Unable to skip entities: " + pEntity, - getData().getLocator()); - } else { - skippedEntity(pEntity); - } - } - - public void processingInstruction(String pTarget, String pData) - throws SAXException { - if (childHandler != null) { - childHandler.processingInstruction(pTarget, pData); - } - } - - public void startElement(String pNamespaceURI, String pLocalName, String pQName, Attributes pAttr) - throws SAXException { - switch (++level) { - case 1: - setQName(pQName); - setNamespaceURI(pNamespaceURI); - setLocalName(pLocalName); - if (pAttr != null) { - for (int i = 0; i < pAttr.getLength(); i++) { + bean = pBean; + } + + public Object getBean() { + return bean; + } + + public void setQName(String pQName) { + qName = pQName; + } + + public void setNamespaceURI(String pNamespaceURI) { + namespaceURI = pNamespaceURI; + } + + public String getNamespaceURI() { + return namespaceURI; + } + + public void setLocalName(String pLocalName) { + localName = pLocalName; + } + + public String getLocalName() { + return localName; + } + + public String getQName() { + return qName; + } + + public ContentHandler getChildHandler() { + return childHandler; + } + + public void startPrefixMapping(String pPrefix, String pURI) + throws SAXException { + if (childHandler == null) { + getData().getNamespaceSupport().declarePrefix(pPrefix, pURI); + } else { + childHandler.startPrefixMapping(pPrefix, pURI); + } + } + + public void endPrefixMapping(String pPrefix) throws SAXException { + if (childHandler != null) { + childHandler.endPrefixMapping(pPrefix); + } + } + + public void startDocument() throws SAXException { + getData().getNamespaceSupport().pushContext(); + } + + public void endDocument() throws SAXException { + getData().getNamespaceSupport().popContext(); + } + + public void characters(char[] pBuffer, int pOffset, int pLen) throws SAXException { + if (childHandler == null) { try { - AttributeSetter attrSetter = getData().getAttributeSetter(); - attrSetter.setAttribute(pAttr.getQName(i), pAttr.getURI(i), - pAttr.getLocalName(i), pAttr.getValue(i)); + getData().getTextSetter().addText(new String(pBuffer, pOffset, pLen)); } catch (SAXException e) { - throw e; + throw e; } catch (RuntimeException e) { - Exception ex = e; - for (;;) { - UndeclaredThrowableException te = null; - Throwable t; - if (ex instanceof UndeclaredThrowableException) { - te = ((UndeclaredThrowableException) ex); - t = te.getUndeclaredThrowable(); - } else if (ex instanceof InvocationTargetException) { - t = ((InvocationTargetException) ex).getTargetException(); - } else { - break; + Exception ex = e; + for (;;) { + UndeclaredThrowableException te = null; + Throwable t; + if (ex instanceof UndeclaredThrowableException) { + te = ((UndeclaredThrowableException) ex); + t = te.getUndeclaredThrowable(); + } else if (ex instanceof InvocationTargetException) { + t = ((InvocationTargetException) ex).getTargetException(); + } else { + break; + } + if (t instanceof Exception) { + ex = (Exception) t; + } else { + if (te == null) { + te = new UndeclaredThrowableException(t); + } + t.printStackTrace(); + throw te; + } } - if (t instanceof Exception) { - ex = (Exception) t; - } else { - if (te == null) { - te = new UndeclaredThrowableException(t); - } - t.printStackTrace(); - throw te; - } - } - throw new LocSAXException(ex.getClass().getName() + ": " + ex.getMessage(), - getData().getLocator(), ex); + throw new LocSAXException(ex.getClass().getName() + ": " + ex.getMessage(), + getData().getLocator(), ex); } - } + } else { + childHandler.characters(pBuffer, pOffset, pLen); } - break; - case 2: - try { - ChildSetter childSetter = getData().getChildSetter(); - childHandler = childSetter.getChildHandler(pQName, pNamespaceURI, pLocalName); - } catch (SAXException e) { - throw e; - } catch (RuntimeException e) { - Exception ex = e; - for (;;) { - UndeclaredThrowableException te = null; - Throwable t; - if (ex instanceof UndeclaredThrowableException) { - te = ((UndeclaredThrowableException) ex); - t = te.getUndeclaredThrowable(); - } else if (ex instanceof InvocationTargetException) { - t = ((InvocationTargetException) ex).getTargetException(); - } else { - break; - } - if (t instanceof Exception) { - ex = (Exception) t; - } else { - if (te == null) { - te = new UndeclaredThrowableException(t); - } - t.printStackTrace(); - throw te; - } - } - throw new LocSAXException(ex.getClass().getName() + ": " + ex.getMessage(), - getData().getLocator(), ex); + } + + public void ignorableWhitespace(char[] pBuffer, int pOffset, int pLen) + throws SAXException { + if (childHandler == null) { + characters(pBuffer, pOffset, pLen); + } else { + childHandler.ignorableWhitespace(pBuffer, pOffset, pLen); + } + } + + public void skippedEntity(String pEntity) throws SAXException { + if (childHandler == null) { + throw new LocSAXException("Unable to skip entities: " + pEntity, + getData().getLocator()); + } else { + skippedEntity(pEntity); + } + } + + public void processingInstruction(String pTarget, String pData) + throws SAXException { + if (childHandler != null) { + childHandler.processingInstruction(pTarget, pData); } - getData().setCurrentContentHandler(childHandler); - childHandler.startDocument(); - childHandler.startElement(pNamespaceURI, pLocalName, pQName, pAttr); - break; - default: - childHandler.startElement(pNamespaceURI, pLocalName, pQName, pAttr); - break; } - } - public void endElement(String pNamespaceURI, String pLocalName, String pQName) - throws SAXException { - switch (level--) { - case 1: - Object o = getBean(); - if (o != null) { - Method m = null; - try { - m = o.getClass().getMethod("validate", ZERO_CLASSES); - } catch (NoSuchMethodException e) { - } - if (m != null) { + public void startElement(String pNamespaceURI, String pLocalName, String pQName, Attributes pAttr) + throws SAXException { + switch (++level) { + case 1: + setQName(pQName); + setNamespaceURI(pNamespaceURI); + setLocalName(pLocalName); + if (pAttr != null) { + for (int i = 0; i < pAttr.getLength(); i++) { + try { + AttributeSetter attrSetter = getData().getAttributeSetter(); + attrSetter.setAttribute(pAttr.getQName(i), pAttr.getURI(i), + pAttr.getLocalName(i), pAttr.getValue(i)); + } catch (SAXException e) { + throw e; + } catch (RuntimeException e) { + Exception ex = e; + for (;;) { + UndeclaredThrowableException te = null; + Throwable t; + if (ex instanceof UndeclaredThrowableException) { + te = ((UndeclaredThrowableException) ex); + t = te.getUndeclaredThrowable(); + } else if (ex instanceof InvocationTargetException) { + t = ((InvocationTargetException) ex).getTargetException(); + } else { + break; + } + if (t instanceof Exception) { + ex = (Exception) t; + } else { + if (te == null) { + te = new UndeclaredThrowableException(t); + } + t.printStackTrace(); + throw te; + } + } + throw new LocSAXException(ex.getClass().getName() + ": " + ex.getMessage(), + getData().getLocator(), ex); + } + } + } + break; + case 2: try { - m.invoke(o, ZERO_OBJECTS); + ChildSetter childSetter = getData().getChildSetter(); + childHandler = childSetter.getChildHandler(pQName, pNamespaceURI, pLocalName); + } catch (SAXException e) { + throw e; } catch (RuntimeException e) { - throw new LocSAXException(e.getClass().getName() + ": " + e.getMessage(), - getData().getLocator(), e); - } catch (InvocationTargetException e) { - Throwable t = e.getTargetException(); - if (t instanceof SAXException) { - throw (SAXException) t; - } else if (t instanceof RuntimeException) { - throw new LocSAXException(t.getClass().getName() + ": " + t.getMessage(), - getData().getLocator(), - (RuntimeException) t); - } else if (t instanceof Exception) { - throw new LocSAXException("Failed to invoke method validate() " + - " of class " + m.getDeclaringClass() + - " with argument " + o.getClass().getName() + ": " + - t.getClass().getName() + ", " + t.getMessage(), - getData().getLocator(), - (Exception) t); - } else { - throw new LocSAXException("Failed to invoke method validate() " + - " of class " + m.getDeclaringClass() + - " with argument " + o.getClass().getName() + ": " + - t.getClass().getName() + ", " + t.getMessage(), - getData().getLocator(), e); - } - } catch (IllegalAccessException e) { - throw new LocSAXException("Failed to invoke method validate() " + - " of class " + m.getDeclaringClass() + - " with argument " + o.getClass().getName() + ": IllegalAccessException, " + - e.getMessage(), - getData().getLocator(), e); - + Exception ex = e; + for (;;) { + UndeclaredThrowableException te = null; + Throwable t; + if (ex instanceof UndeclaredThrowableException) { + te = ((UndeclaredThrowableException) ex); + t = te.getUndeclaredThrowable(); + } else if (ex instanceof InvocationTargetException) { + t = ((InvocationTargetException) ex).getTargetException(); + } else { + break; + } + if (t instanceof Exception) { + ex = (Exception) t; + } else { + if (te == null) { + te = new UndeclaredThrowableException(t); + } + t.printStackTrace(); + throw te; + } + } + throw new LocSAXException(ex.getClass().getName() + ": " + ex.getMessage(), + getData().getLocator(), ex); } - } - } - break; - case 2: - childHandler.endElement(pNamespaceURI, pLocalName, pQName); - childHandler.endDocument(); - getData().setCurrentContentHandler(this); - childHandler = null; + getData().setCurrentContentHandler(childHandler); + childHandler.startDocument(); + childHandler.startElement(pNamespaceURI, pLocalName, pQName, pAttr); + break; + default: + childHandler.startElement(pNamespaceURI, pLocalName, pQName, pAttr); break; - default: - childHandler.endElement(pNamespaceURI, pLocalName, pQName); + } + } + + public void endElement(String pNamespaceURI, String pLocalName, String pQName) + throws SAXException { + switch (level--) { + case 1: + Object o = getBean(); + if (o != null) { + Method m = null; + try { + m = o.getClass().getMethod("validate", ZERO_CLASSES); + } catch (NoSuchMethodException e) { + } + if (m != null) { + try { + m.invoke(o, ZERO_OBJECTS); + } catch (RuntimeException e) { + throw new LocSAXException(e.getClass().getName() + ": " + e.getMessage(), + getData().getLocator(), e); + } catch (InvocationTargetException e) { + Throwable t = e.getTargetException(); + if (t instanceof SAXException) { + throw (SAXException) t; + } else if (t instanceof RuntimeException) { + throw new LocSAXException(t.getClass().getName() + ": " + t.getMessage(), + getData().getLocator(), + (RuntimeException) t); + } else if (t instanceof Exception) { + throw new LocSAXException("Failed to invoke method validate() " + + " of class " + m.getDeclaringClass() + + " with argument " + o.getClass().getName() + ": " + + t.getClass().getName() + ", " + t.getMessage(), + getData().getLocator(), + (Exception) t); + } else { + throw new LocSAXException("Failed to invoke method validate() " + + " of class " + m.getDeclaringClass() + + " with argument " + o.getClass().getName() + ": " + + t.getClass().getName() + ", " + t.getMessage(), + getData().getLocator(), e); + } + } catch (IllegalAccessException e) { + throw new LocSAXException("Failed to invoke method validate() " + + " of class " + m.getDeclaringClass() + + " with argument " + o.getClass().getName() + ": IllegalAccessException, " + + e.getMessage(), + getData().getLocator(), e); + + } + } + } + break; + case 2: + childHandler.endElement(pNamespaceURI, pLocalName, pQName); + childHandler.endDocument(); + getData().setCurrentContentHandler(this); + childHandler = null; + break; + default: + childHandler.endElement(pNamespaceURI, pLocalName, pQName); break; + } } - } - public void setDocumentLocator(Locator pLocator) { - getData().setLocator(pLocator); - if (childHandler != null) { - childHandler.setDocumentLocator(pLocator); + public void setDocumentLocator(Locator pLocator) { + getData().setLocator(pLocator); + if (childHandler != null) { + childHandler.setDocumentLocator(pLocator); + } } - } } Modified: webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/xml/impl/XsTSimpleRestrictionTypeImpl.java URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/xml/impl/XsTSimpleRestrictionTypeImpl.java?view=diff&rev=498237&r1=498236&r2=498237 ============================================================================== --- webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/xml/impl/XsTSimpleRestrictionTypeImpl.java (original) +++ webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/xml/impl/XsTSimpleRestrictionTypeImpl.java Sat Jan 20 19:00:40 2007 @@ -62,7 +62,7 @@ } public XsEMinExclusive createMinExclusive() throws SAXException { - return impl.getMinExclusive(); + return impl.createMinExclusive(); } public XsEMinExclusive getMinExclusive() { Modified: webservices/jaxme/branches/b0_5/status.xml URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/b0_5/status.xml?view=diff&rev=498237&r1=498236&r2=498237 ============================================================================== --- webservices/jaxme/branches/b0_5/status.xml (original) +++ webservices/jaxme/branches/b0_5/status.xml Sat Jan 20 19:00:40 2007 @@ -53,6 +53,10 @@ The "blockDefaults" handling has been inverted. (Brian Uri, [EMAIL PROTECTED]) </action> + <action dev="JW" type="fix" context="xs"> + Fixed an NPE when using minExclusive. + (Brian Uri, [EMAIL PROTECTED]) + </action> </release> <release version="0.5.2" date="25-Oct-2006"> <action dev="JW" type="enhancement" context="generator"> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]