You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2007/01/21 04:00:07 UTC
svn commit: r498236 - in /webservices/jaxme/trunk/ws-jaxme: ./
jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/parser/impl/
jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/impl/
jaxme-xs/src/test/java/org/apache/ws/jaxme/xs/junit/
Author: jochen
Date: Sat Jan 20 19:00:06 2007
New Revision: 498236
URL: http://svn.apache.org/viewvc?view=rev&rev=498236
Log:
Fixed an NPE when using minExclusive.
Modified:
webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/parser/impl/AbstractXsSAXParser.java
webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/impl/XsTSimpleRestrictionTypeImpl.java
webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/test/java/org/apache/ws/jaxme/xs/junit/JiraTest.java
webservices/jaxme/trunk/ws-jaxme/status.xml
Modified: webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/parser/impl/AbstractXsSAXParser.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/parser/impl/AbstractXsSAXParser.java?view=diff&rev=498236&r1=498235&r2=498236
==============================================================================
--- webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/parser/impl/AbstractXsSAXParser.java (original)
+++ webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/parser/impl/AbstractXsSAXParser.java Sat Jan 20 19:00:06 2007
@@ -34,289 +34,292 @@
* @author <a href="mailto:joe@ispsoft.de">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/trunk/ws-jaxme/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/impl/XsTSimpleRestrictionTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/impl/XsTSimpleRestrictionTypeImpl.java?view=diff&rev=498236&r1=498235&r2=498236
==============================================================================
--- webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/impl/XsTSimpleRestrictionTypeImpl.java (original)
+++ webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/xml/impl/XsTSimpleRestrictionTypeImpl.java Sat Jan 20 19:00:06 2007
@@ -62,7 +62,7 @@
}
public XsEMinExclusive createMinExclusive() throws SAXException {
- return impl.getMinExclusive();
+ return impl.createMinExclusive();
}
public XsEMinExclusive getMinExclusive() {
Modified: webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/test/java/org/apache/ws/jaxme/xs/junit/JiraTest.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/test/java/org/apache/ws/jaxme/xs/junit/JiraTest.java?view=diff&rev=498236&r1=498235&r2=498236
==============================================================================
--- webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/test/java/org/apache/ws/jaxme/xs/junit/JiraTest.java (original)
+++ webservices/jaxme/trunk/ws-jaxme/jaxme-xs/src/test/java/org/apache/ws/jaxme/xs/junit/JiraTest.java Sat Jan 20 19:00:06 2007
@@ -250,4 +250,28 @@
XSElement b = assertElement(particles[1]);
assertEquals(new XsQName("http://namespaces.softwareag.com/de/s/xDWS/soap-api", "b"), b.getName());
}
+
+ public void testMinExclusiveNPE() throws Exception {
+ final String xml =
+ "<xsd:schema\n"
+ + " xmlns:xsd='http://www.w3.org/2001/XMLSchema'\n"
+ + " xmlns:xsdi='http://www.w3.org/2001/XMLSchema-instance'\n"
+ + " xmlns:dummy='target:ns:dummy'\n"
+ + " targetNamespace='target:ns:dummy'\n"
+ + " elementFormDefault='qualified'\n"
+ + " xsdi:schemaLocation='http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd'>\n"
+ + " <xsd:simpleType name='ExclusiveInclusiveSimple'>\n"
+ + " <xsd:restriction base='xsd:decimal'>\n"
+ + " <xsd:maxInclusive value='90'/>\n"
+ + " <xsd:minExclusive value='-90'/>\n"
+ + " </xsd:restriction>\n"
+ + " </xsd:simpleType>\n"
+ + " <xsd:complexType name='ExclusiveInclusive'>\n"
+ + " <xsd:simpleContent>\n"
+ + " <xsd:extension base='dummy:ExclusiveInclusiveSimple'/>\n"
+ + " </xsd:simpleContent>\n"
+ + " </xsd:complexType>\n"
+ + "</xsd:schema>";
+ parse(xml, "testMinExclusiveNPE.xsd");
+ }
}
Modified: webservices/jaxme/trunk/ws-jaxme/status.xml
URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/status.xml?view=diff&rev=498236&r1=498235&r2=498236
==============================================================================
--- webservices/jaxme/trunk/ws-jaxme/status.xml (original)
+++ webservices/jaxme/trunk/ws-jaxme/status.xml Sat Jan 20 19:00:06 2007
@@ -69,6 +69,10 @@
The "blockDefaults" handling has been inverted.
(Brian Uri, buri@fgm.com)
</action>
+ <action dev="JW" type="fix" context="xs">
+ Fixed an NPE when using minExclusive.
+ (Brian Uri, buri@fgm.com)
+ </action>
</release>
<release version="0.5.2" date="25-Oct-2006">
<action dev="JW" type="enhancement" context="generator">
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org