jochen 2005/04/28 16:57:40
Modified: src/jaxme/org/apache/ws/jaxme/junit Tag: v0_4
BaseTestCase.java
src/jaxme/org/apache/ws/jaxme/generator/types Tag: v0_4
StringSG.java AtomicTypeSGImpl.java
ListTypeSGImpl.java UnionTypeSGImpl.java
BooleanSG.java
src/jaxme/org/apache/ws/jaxme/generator/sg/impl Tag: v0_4
EnumerationSG.java ParsePrintSG.java
src/test/jaxb Tag: v0_4 types.xsd
. Tag: v0_4 status.xml
src/jaxme/org/apache/ws/jaxme/generator/sg Tag: v0_4
SimpleTypeSG.java
src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg Tag:
v0_4 SimpleContentHandlerSG.java
GroupHandlerSG.java HandlerSGImpl.java
Added: src/jaxme/org/apache/ws/jaxme/junit Tag: v0_4
EventsTest.java
Log:
Fixed that a simple types conversion from a string didn't generate a proper
ParseConversionEvent.
Revision Changes Path
No revision
No revision
1.7.2.2 +5 -2
ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/BaseTestCase.java
Index: BaseTestCase.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/BaseTestCase.java,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -r1.7.2.1 -r1.7.2.2
--- BaseTestCase.java 18 Apr 2005 20:31:49 -0000 1.7.2.1
+++ BaseTestCase.java 28 Apr 2005 23:57:40 -0000 1.7.2.2
@@ -37,7 +37,10 @@
* @version $Id$
*/
public abstract class BaseTestCase extends TestCase {
- protected BaseTestCase(String pName) {
+ protected BaseTestCase() {
+ }
+
+ protected BaseTestCase(String pName) {
super(pName);
}
No revision
Index: BaseTestCase.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/BaseTestCase.java,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -r1.7.2.1 -r1.7.2.2
--- BaseTestCase.java 18 Apr 2005 20:31:49 -0000 1.7.2.1
+++ BaseTestCase.java 28 Apr 2005 23:57:40 -0000 1.7.2.2
@@ -37,7 +37,10 @@
* @version $Id$
*/
public abstract class BaseTestCase extends TestCase {
- protected BaseTestCase(String pName) {
+ protected BaseTestCase() {
+ }
+
+ protected BaseTestCase(String pName) {
super(pName);
}
No revision
Index: BaseTestCase.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/BaseTestCase.java,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -r1.7.2.1 -r1.7.2.2
--- BaseTestCase.java 18 Apr 2005 20:31:49 -0000 1.7.2.1
+++ BaseTestCase.java 28 Apr 2005 23:57:40 -0000 1.7.2.2
@@ -37,7 +37,10 @@
* @version $Id$
*/
public abstract class BaseTestCase extends TestCase {
- protected BaseTestCase(String pName) {
+ protected BaseTestCase() {
+ }
+
+ protected BaseTestCase(String pName) {
super(pName);
}
1.1.2.1 +48 -0
ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/Attic/EventsTest.java
No revision
No revision
1.3.2.1 +89 -74
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/StringSG.java
Index: StringSG.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/StringSG.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- StringSG.java 8 Apr 2005 23:10:45 -0000 1.3
+++ StringSG.java 28 Apr 2005 23:57:40 -0000 1.3.2.1
@@ -44,6 +44,8 @@
super(pFactory, pSchema, pType);
}
+ /** The string type.
+ */
public final static JavaQName STRING_TYPE =
JavaQNameImpl.getInstance(String.class);
protected String getDatatypeName() { return "String"; }
protected JavaQName getDatatypeType() { return STRING_TYPE; }
@@ -74,78 +76,91 @@
pSGlet.generate(pMethod, pValue);
}
- public void addValidation(SimpleTypeSG pController, JavaMethod pMethod,
DirectAccessible pValue)
- throws SAXException {
- AtomicTypeSG atomicType = pController.getAtomicType();
- Long length = atomicType.getLength();
- Long maxLength = atomicType.getMaxLength();
- Long minLength = atomicType.getMinLength();
-
- if (minLength != null && minLength.longValue() < 0) {
- throw new LocSAXException("Negative value for minLength detected: " +
minLength, getLocator());
- }
- if (maxLength != null) {
- if (maxLength.longValue() < 0) {
- throw new LocSAXException("Negative value for maxLength detected: "
+ maxLength, getLocator());
- }
- if (minLength != null) {
- if (maxLength.longValue() < minLength.longValue()) {
- throw new LocSAXException("MaxLength value of " + maxLength + " is
smaller than minLength value of " + minLength,
- getLocator());
- }
- if (maxLength.longValue() == minLength.longValue()) {
- length = maxLength;
- }
- }
- }
- if (length != null) {
- if (length.longValue() < 0) {
- throw new LocSAXException("Negative value for length detected: " +
length, getLocator());
- }
- if (maxLength != null) {
- if (maxLength.longValue() < length.longValue()) {
- throw new LocSAXException("MaxLength value of " + maxLength + " is
smaller than length value of " + length,
- getLocator());
- }
- maxLength = null; // Avoid unnecessary checks
- }
- if (minLength != null) {
- if (minLength.longValue() > length.longValue()) {
- throw new LocSAXException("MinLength value of " + minLength + " is
larger than length value of " + length,
- getLocator());
- }
- minLength = null; // Avoid unnecessary checks
- }
- }
-
- if (length != null || maxLength != null || minLength != null) {
- if (pValue.isNullable()) {
- pMethod.addIf(pValue, " != null");
- }
- if (maxLength != null) {
- pMethod.addIf(pValue, ".length()", " > ", maxLength);
- pMethod.addThrowNew(IllegalArgumentException.class,
- JavaSource.getQuoted("Length of " + maxLength +
" characters exceeded: "),
- " + ", pValue);
- pMethod.addEndIf();
- }
- if (minLength != null) {
- pMethod.addIf(pValue, ".length()", " < ", minLength);
- pMethod.addThrowNew(IllegalArgumentException.class,
- JavaSource.getQuoted("Length of " + minLength +
" characters exceeded: "),
- " + ", pValue);
- pMethod.addEndIf();
- }
- if (length != null) {
- pMethod.addIf(pValue, ".length()", " != ", length);
- pMethod.addThrowNew(IllegalArgumentException.class,
- JavaSource.getQuoted("Length of " + length + "
characters not matched: "),
- " + ", pValue);
- pMethod.addEndIf();
- }
- if (pValue.isNullable()) {
- pMethod.addEndIf();
- }
- }
- }
+ public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
+ final AtomicTypeSG atomicType = pController.getAtomicType();
+ /* See addValidation(SimpleTypeSG, JavaMethod,
DirectAccessible) for
+ * when an exception can be thrown.
+ */
+ return atomicType.getLength() != null
+ || atomicType.getMinLength() != null
+ || atomicType.getMaxLength() != null;
+ }
+
+ public void addValidation(SimpleTypeSG pController, JavaMethod pMethod,
DirectAccessible pValue)
+ throws SAXException {
+ /* If you add additional checks here, you should possibly modify
+ * the isCausingParseConversionEvent(SimpleTypeSG) method as
well.
+ */
+ final AtomicTypeSG atomicType = pController.getAtomicType();
+ Long length = atomicType.getLength();
+ Long maxLength = atomicType.getMaxLength();
+ Long minLength = atomicType.getMinLength();
+
+ if (minLength != null && minLength.longValue() < 0) {
+ throw new LocSAXException("Negative value for minLength
detected: " + minLength, getLocator());
+ }
+ if (maxLength != null) {
+ if (maxLength.longValue() < 0) {
+ throw new LocSAXException("Negative value for
maxLength detected: " + maxLength, getLocator());
+ }
+ if (minLength != null) {
+ if (maxLength.longValue() <
minLength.longValue()) {
+ throw new LocSAXException("MaxLength
value of " + maxLength + " is smaller than minLength value of " + minLength,
+ getLocator());
+ }
+ if (maxLength.longValue() ==
minLength.longValue()) {
+ length = maxLength;
+ }
+ }
+ }
+ if (length != null) {
+ if (length.longValue() < 0) {
+ throw new LocSAXException("Negative value for
length detected: " + length, getLocator());
+ }
+ if (maxLength != null) {
+ if (maxLength.longValue() < length.longValue())
{
+ throw new LocSAXException("MaxLength
value of " + maxLength + " is smaller than length value of " + length,
+ getLocator());
+ }
+ maxLength = null; // Avoid unnecessary checks
+ }
+ if (minLength != null) {
+ if (minLength.longValue() > length.longValue())
{
+ throw new LocSAXException("MinLength
value of " + minLength + " is larger than length value of " + length,
+ getLocator());
+ }
+ minLength = null; // Avoid unnecessary checks
+ }
+ }
+
+ if (length != null || maxLength != null || minLength !=
null) {
+ if (pValue.isNullable()) {
+ pMethod.addIf(pValue, " != null");
+ }
+ if (maxLength != null) {
+ pMethod.addIf(pValue, ".length()", " > ",
maxLength);
+
pMethod.addThrowNew(IllegalArgumentException.class,
+ JavaSource.getQuoted("Length of
" + maxLength + " characters exceeded: "),
+ " + ", pValue);
+ pMethod.addEndIf();
+ }
+ if (minLength != null) {
+ pMethod.addIf(pValue, ".length()", " < ",
minLength);
+
pMethod.addThrowNew(IllegalArgumentException.class,
+ JavaSource.getQuoted("Length of
" + minLength + " characters exceeded: "),
+ " + ", pValue);
+ pMethod.addEndIf();
+ }
+ if (length != null) {
+ pMethod.addIf(pValue, ".length()", " != ",
length);
+
pMethod.addThrowNew(IllegalArgumentException.class,
+ JavaSource.getQuoted("Length of
" + length + " characters not matched: "),
+ " + ", pValue);
+ pMethod.addEndIf();
+ }
+ if (pValue.isNullable()) {
+ pMethod.addEndIf();
+ }
+ }
+ }
}
1.3.2.2 +4 -0
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/AtomicTypeSGImpl.java
Index: AtomicTypeSGImpl.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/AtomicTypeSGImpl.java,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -r1.3.2.1 -r1.3.2.2
--- AtomicTypeSGImpl.java 27 Apr 2005 06:25:49 -0000 1.3.2.1
+++ AtomicTypeSGImpl.java 28 Apr 2005 23:57:40 -0000 1.3.2.2
@@ -120,4 +120,8 @@
throws SAXException {
return new Object[]{pValue1, ".equals(", pValue2, ")"};
}
+
+ public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
+ return true;
+ }
}
1.3.2.1 +4 -0
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/ListTypeSGImpl.java
Index: ListTypeSGImpl.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/ListTypeSGImpl.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- ListTypeSGImpl.java 8 Apr 2005 23:10:45 -0000 1.3
+++ ListTypeSGImpl.java 28 Apr 2005 23:57:40 -0000 1.3.2.1
@@ -194,4 +194,8 @@
JavaQName listClass = "indexed".equals(s) ? ARRAYLIST_TYPE :
JavaQNameImpl.getInstance(s, true);
return new Object[]{"new ", listClass, "()"};
}
+
+ public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
+ return
itemType.getSimpleTypeSG().isCausingParseConversionEvent();
+ }
}
1.3.2.1 +9 -0
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/UnionTypeSGImpl.java
Index: UnionTypeSGImpl.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/UnionTypeSGImpl.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- UnionTypeSGImpl.java 8 Apr 2005 23:10:45 -0000 1.3
+++ UnionTypeSGImpl.java 28 Apr 2005 23:57:40 -0000 1.3.2.1
@@ -156,4 +156,13 @@
public Object getEqualsCheck(SimpleTypeSG pController, JavaMethod pMethod,
Object pValue1, Object pValue2) throws SAXException {
throw new IllegalStateException("Not implemented");
}
+
+ public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
+ for (int i = 0; i < memberTypes.length; i++) {
+ if
(!memberTypes[i].getSimpleTypeSG().isCausingParseConversionEvent()) {
+ return false;
+ }
+ }
+ return true;
+ }
}
1.3.2.2 +10 -2
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/BooleanSG.java
Index: BooleanSG.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/BooleanSG.java,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -r1.3.2.1 -r1.3.2.2
--- BooleanSG.java 27 Apr 2005 06:25:49 -0000 1.3.2.1
+++ BooleanSG.java 28 Apr 2005 23:57:40 -0000 1.3.2.2
@@ -32,8 +32,12 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a>
*/
public class BooleanSG extends PrimitiveTypeSG {
- public static final JavaQName BOOLEAN_TYPE =
JavaQNameImpl.getInstance(boolean.class);
- public static final JavaQName BOOLEAN_OBJECT_TYPE =
JavaQNameImpl.getInstance(Boolean.class);
+ /** The primitive boolean type.
+ */
+ public static final JavaQName BOOLEAN_TYPE =
JavaQNameImpl.getInstance(boolean.class);
+ /** The object boolean type.
+ */
+ public static final JavaQName BOOLEAN_OBJECT_TYPE =
JavaQNameImpl.getInstance(Boolean.class);
/** <p>Creates a new instance of BooleanSG.java.</p>
*/
@@ -60,4 +64,8 @@
}
}
}
+
+ public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
+ return false;
+ }
}
No revision
No revision
1.4.2.1 +4 -0
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/EnumerationSG.java
Index: EnumerationSG.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/EnumerationSG.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- EnumerationSG.java 8 Apr 2005 23:10:46 -0000 1.4
+++ EnumerationSG.java 28 Apr 2005 23:57:40 -0000 1.4.2.1
@@ -267,4 +267,8 @@
super.generate(pController, pSource);
getEnumClass(pController);
}
+
+ public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
+ return true;
+ }
}
1.6.2.1 +6 -19
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ParsePrintSG.java
Index: ParsePrintSG.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ParsePrintSG.java,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- ParsePrintSG.java 8 Apr 2005 23:10:46 -0000 1.6
+++ ParsePrintSG.java 28 Apr 2005 23:57:40 -0000 1.6.2.1
@@ -13,6 +13,7 @@
import org.apache.ws.jaxme.js.JavaSource;
import org.apache.ws.jaxme.js.LocalJavaField;
import org.apache.ws.jaxme.js.TypedValue;
+import org.apache.ws.jaxme.js.impl.TypedValueImpl;
import org.apache.ws.jaxme.xs.jaxb.JAXBJavaType;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -83,7 +84,6 @@
Object pValue, Object pData)
throws SAXParseException {
JavaQName type = getType(pController);
- LocalJavaField f = pMethod.newJavaField(type);
DirectAccessible value = getValue(pMethod, pValue,
JavaQNameImpl.getInstance(String.class));
String parseMethod = javaType.getParseMethod().trim();
@@ -98,24 +98,7 @@
addCall(pController, list, parseMethod, type);
}
addValues(list, value, pData);
- pMethod.addTry();
- pMethod.addLine(f, " = ", list, ";");
- DirectAccessible e = pMethod.addCatch(Exception.class);
- pMethod.addLine("getHandler().parseConversionEvent(",
- JavaSource.getQuoted("Failed to parse value "),
- " + ", value, " + ", JavaSource.getQuoted(": "),
- " + ", e, ".getClass().getName(), ", e, ");");
- if (type.isPrimitive()) {
- if (JavaQNameImpl.BOOLEAN.equals(type)) {
- pMethod.addLine(f, " = false;");
- } else {
- pMethod.addLine(f, " = 0;");
- }
- } else {
- pMethod.addLine(f, " = null;");
- }
- pMethod.addEndTry();
- return f;
+ return new TypedValueImpl(list, type);
}
private TypedValue getPrintCall(SimpleTypeSG pController, JavaMethod
pMethod,
@@ -167,4 +150,8 @@
return getPrintCall(pController, pMethod, pValue, pData);
}
}
+
+ public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
+ return true;
+ }
}
No revision
No revision
1.10.2.1 +2 -0 ws-jaxme/src/test/jaxb/types.xsd
Index: types.xsd
===================================================================
RCS file: /home/cvs/ws-jaxme/src/test/jaxb/types.xsd,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- types.xsd 8 Apr 2005 23:10:46 -0000 1.10
+++ types.xsd 28 Apr 2005 23:57:40 -0000 1.10.2.1
@@ -55,6 +55,8 @@
</xs:sequence>
</xs:complexType>
+ <xs:element name="EAllSimpleTypeAttrs" type="ex:AllSimpleTypeAttrs"/>
+
<xs:complexType name="AllSimpleTypeAttrs">
<xs:annotation><xs:documentation>
A complex type which includes the same type as attributes.
No revision
No revision
1.45.2.5 +4 -0 ws-jaxme/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/ws-jaxme/status.xml,v
retrieving revision 1.45.2.4
retrieving revision 1.45.2.5
diff -u -r1.45.2.4 -r1.45.2.5
--- status.xml 25 Apr 2005 19:59:30 -0000 1.45.2.4
+++ status.xml 28 Apr 2005 23:57:40 -0000 1.45.2.5
@@ -31,6 +31,10 @@
<changes>
<release version="0.4" date="Not yet published">
+ <action dev="JW" type="fix" context="generator">
+ A proper ParseConversionEvent is now generated, if the
+ conversion of a simple type fails.
+ </action>
<action dev="JW" type="fix" context="xs">
Fixed that recursive xs:include caused an endless loop.
(Daniel Barclay, daniel at fgm.com)
No revision
No revision
1.5.2.1 +6 -1
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java
Index: SimpleTypeSG.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- SimpleTypeSG.java 8 Apr 2005 23:10:45 -0000 1.5
+++ SimpleTypeSG.java 28 Apr 2005 23:57:40 -0000 1.5.2.1
@@ -74,6 +74,11 @@
*/
public JavaQName getRuntimeType();
+ /** Returns whether converting this type from a string can cause a
+ * [EMAIL PROTECTED] javax.xml.bind.ParseConversionEvent}.
+ */
+ public boolean isCausingParseConversionEvent();
+
/** <p>Returns a piece of Java code converting the string
<code>pValue</code>
* into the runtime type. Conversion occurs at runtime, using the
* given instance of [EMAIL PROTECTED]
org.apache.ws.jaxme.JMUnmarshallerHandler}.</p>
@@ -87,7 +92,7 @@
/** <p>Returns a piece of Java code converting the runtime type
* <code>pValue</code> into a string. Conversion occurs at runtime, using
the
- * given instance of [EMAIL PROTECTED]
org.apache.ws.jaxme.JMXmlSerializer.Data}.</p>
+ * given instance of [EMAIL PROTECTED]
org.apache.ws.jaxme.impl.JMUnmarshallerHandlerImpl}.</p>
*/
public TypedValue getCastToString(JavaMethod pMethod, Object pValue,
DirectAccessible pData) throws SAXException;
No revision
No revision
1.4.2.1 +2 -3
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/SimpleContentHandlerSG.java
Index: SimpleContentHandlerSG.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/SimpleContentHandlerSG.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- SimpleContentHandlerSG.java 8 Apr 2005 23:10:45 -0000 1.4
+++ SimpleContentHandlerSG.java 28 Apr 2005 23:57:40 -0000 1.4.2.1
@@ -43,9 +43,8 @@
LocalJavaField element = result.newJavaField(elementInterface);
element.addLine("(", elementInterface, ") result");
SimpleContentSG scSG = ctSG.getSimpleContentSG();
- Object v = getParamResult();
- v = new Object[]{"(", String.class, ") ", v};
- TypedValue tv =
scSG.getContentTypeSG().getSimpleTypeSG().getCastFromString(result, v,
"getHandler()");
+ TypedValue tv = createSimpleTypeConversion(result,
scSG.getContentTypeSG(),
+
getParamResult(), scSG.getPropertySG().getXMLFieldName());
scSG.getPropertySG().addValue(result, element, tv, null);
return result;
}
1.4.2.1 +4 -6
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/GroupHandlerSG.java
Index: GroupHandlerSG.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/GroupHandlerSG.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- GroupHandlerSG.java 8 Apr 2005 23:10:45 -0000 1.4
+++ GroupHandlerSG.java 28 Apr 2005 23:57:40 -0000 1.4.2.1
@@ -263,9 +263,9 @@
private void handleEndElementState(JavaMethod pJm, LocalJavaField
pElement,
ParticleSG pParticle) throws SAXException {
if (pParticle.isElement()) {
- ObjectSG osg = pParticle.getObjectSG();
- TypeSG childType = osg.getTypeSG();
- XsQName name = osg.getName();
+ ObjectSG oSG = pParticle.getObjectSG();
+ TypeSG childType = oSG.getTypeSG();
+ XsQName name = oSG.getName();
Object[] uriCondition;
if ("".equals(name.getNamespaceURI())) {
uriCondition = new Object[]{
@@ -285,9 +285,7 @@
if (childType.isComplex()) {
type =
childType.getComplexTypeSG().getClassContext().getXMLInterfaceName();
} else {
- Object s = new Object[]{"(", String.class, ")
", v};
- v = new
TypedValueImpl(childType.getSimpleTypeSG().getCastFromString(pJm, s,
"getHandler()"),
-
childType.getSimpleTypeSG().getRuntimeType());
+ v = createSimpleTypeConversion(pJm, childType,
v, oSG.getName().toString());
type = null;
}
pParticle.getPropertySG().addValue(pJm, pElement, v,
type);
1.2.2.1 +42 -1
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java
Index: HandlerSGImpl.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1
--- HandlerSGImpl.java 7 Mar 2005 20:00:28 -0000 1.2
+++ HandlerSGImpl.java 28 Apr 2005 23:57:40 -0000 1.2.2.1
@@ -25,12 +25,17 @@
import org.apache.ws.jaxme.ValidationEvents;
import org.apache.ws.jaxme.generator.sg.AttributeSG;
import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
+import org.apache.ws.jaxme.generator.sg.TypeSG;
+import org.apache.ws.jaxme.generator.types.BooleanSG;
+import org.apache.ws.jaxme.generator.types.StringSG;
import org.apache.ws.jaxme.js.DirectAccessible;
import org.apache.ws.jaxme.js.JavaMethod;
import org.apache.ws.jaxme.js.JavaQName;
import org.apache.ws.jaxme.js.JavaQNameImpl;
import org.apache.ws.jaxme.js.JavaSource;
import org.apache.ws.jaxme.js.LocalJavaField;
+import org.apache.ws.jaxme.js.TypedValue;
+import org.apache.ws.jaxme.js.impl.TypedValueImpl;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -133,7 +138,7 @@
jm.addIf(firstInNamespace,
JavaSource.getQuoted(attr.getName().getLocalName()), ".equals(", pLocalName,
")");
firstInNamespace = false;
- Object v =
myAttributes[i].getTypeSG().getSimpleTypeSG().getCastFromString(jm, pValue,
"getHandler()");
+ TypedValue v = createSimpleTypeConversion(jm,
myAttributes[i].getTypeSG(), pValue, "@" + myAttributes[i].getName());
attr.getPropertySG().setValue(jm, result, v,
null);
jm.addLine("return;");
}
@@ -215,6 +220,42 @@
return jm;
}
+ protected TypedValue createSimpleTypeConversion(JavaMethod pJm, TypeSG
pType,
+
TypedValue pValue, String pName)
+ throws SAXException {
+ JavaQName runtimeType =
pType.getSimpleTypeSG().getRuntimeType();
+ boolean causingParseConversionEvent =
pType.getSimpleTypeSG().isCausingParseConversionEvent();
+ LocalJavaField f = null;
+ if (causingParseConversionEvent) {
+ f = pJm.newJavaField(runtimeType);
+ pJm.addTry();
+ }
+ Object s = new Object[]{"(", StringSG.STRING_TYPE, ") ",
pValue};
+ TypedValue result = new
TypedValueImpl(pType.getSimpleTypeSG().getCastFromString(pJm, s,
"getHandler()"),
+
pType.getSimpleTypeSG().getRuntimeType());
+ if (causingParseConversionEvent) {
+ pJm.addLine(f, " = ", result, ";");
+ result = f;
+ DirectAccessible e = pJm.addCatch(Exception.class);
+ pJm.addLine("getHandler().parseConversionEvent(",
+ JavaSource.getQuoted("Failed to
convert value of " + pName + ": "),
+ " + ", pValue, ", ", e, ");");
+ Object o;
+ if (runtimeType.isPrimitive()) {
+ if (BooleanSG.BOOLEAN_TYPE.equals(runtimeType))
{
+ o = "false";
+ } else {
+ o = "0";
+ }
+ } else {
+ o = "null";
+ }
+ pJm.addLine(f, " = ", o, ";");
+ pJm.addEndTry();
+ }
+ return result;
+ }
+
public void generate() throws SAXException {
newAddAttributeMethod();
newStartElementMethod();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]