Hi James,
your enhancement to hash code calculation sounds reasonable but even if
it is a very small addition we like to track that with jira. Can you
therefore please create a new issue in jira and attach all relevant files.
Thanks in advance
Ralf
James Procter schrieb:
Hi.
I'm new to the list, but have been developing with castor for a year or
two now. So far, we have had few problems that weren't fixed in a timely
fashion by the castor developers - until now.
I was wondering if is worth re-opening or creating a new bug for the
sourcegenerator's hashCode() method generation function introduced
through http://jira.codehaus.org/browse/CASTOR-1417
Basically, the hashCode that is currently calculated is only dependent
on the elements and attributes specific defined specifically for an XML
type/element. This means that changes to any elements and attributes
inherited from base types do not affect the hashCode() for the whole
element.
I have a small patch to ensure that for a schema like:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="bar">
<xs:attribute name="name" type="xs:string"/>
</xs:complexType>
<xs:element name="foo">
<xs:complexType>
<xs:complexContent>
<xs:extension base="bar">
<xs:sequence>
<xs:element name="foobar" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:schema>
The value of hashCode for the source-generated class bound to element
'foo' changes when the attribute 'name' changes.
The patch for
castor-1.1\codegen\src\main\java\org\exolab\castor\builder\SourceFactory.java
is below:
-----Start of Patch
*** SourceFactory.java 2007-02-10 16:48:00.000000000 +0000
--- SourceFactory-new.java 2007-03-20 22:40:31.000000000 +0000
***************
*** 1107,1115 ****
jclass.addMethod(jMethod);
JSourceCode jsc = jMethod.getSourceCode();
jsc.add("int result = 17;");
jsc.add("");
jsc.add("long tmp;");
for (int i = 0; i < fields.length; i++) {
--- 1107,1119 ----
jclass.addMethod(jMethod);
JSourceCode jsc = jMethod.getSourceCode();
! if (jclass.getSuperClassQualifiedName()==null) {
jsc.add("int result = 17;");
+ } else {
+ jsc.add("int result = super.hashCode();");
+ }
jsc.add("");
+
jsc.add("long tmp;");
for (int i = 0; i < fields.length; i++) {
-----End of Patch
As I said. It's really small - so almost not worth tracking in Jira.
thanks for a great tool!
Jim Procter.
--
Syscon Ingenieurbüro für Meß- und Datentechnik GmbH
Ralf Joachim
Raiffeisenstraße 11
72127 Kusterdingen
Germany
Tel. +49 7071 3690 52
Mobil: +49 173 9630135
Fax +49 7071 3690 98
Internet: www.syscon.eu
E-Mail: [EMAIL PROTECTED]
Sitz der Gesellschaft: D-72127 Kusterdingen
Registereintrag: Amtsgericht Stuttgart, HRB 382295
Geschäftsleitung: Jens Joachim, Ralf Joachim
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email