jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • castor
  • CASTOR-416

No resetValue generated, setValue adds null

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 0.9.4.2, 1.0, 1.0.1, 1.0.2, 1.0.3
  • Fix Version/s: 1.0.4
  • Component/s: XML code generator
  • Labels:
    None
  • Environment:
    Operating System: Windows 2000
    Platform: PC
  • Bugzilla Id:
    1273

Description

As opposed to what the comment in XMLFieldHandler.resetValue says
//-- Do nothing, this method is overloaded by the
//-- source code generator
the Source Generator doesn't generate the resetValue method, at least not for
multi-valued fields (didn't check for single-valued). So the only way to access
multi-valued fields generically through the field handler is setValue - so there
is no way to remove values!
If there are any workarounds, please let me know...

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Lars Klose added a comment - 01/Apr/03 1:21 AM

This is what I added to DescriptorSourceFactory.createXMLFieldHandler to get a
working resetValue method for Java2 Collections - comments welcome!

//-- reset method
//--handle collections
if (member.isMultivalued()) {
CollectionInfo cInfo = (CollectionInfo) member;
FieldInfo content = cInfo.getContent();
jsc.add("public void resetValue( Object object ) throws
IllegalStateException, IllegalArgumentException {");
jsc.indent();
jsc.add("try {");
jsc.indent();
jsc.add(localClassName);
jsc.append(" target = (");
jsc.append(localClassName);
jsc.append(") object;");
String cName = JavaNaming.toJavaClassName(cInfo.getElementName());
if (cInfo instanceof CollectionInfoJ2) { jsc.add("target.clear" + cName + "();"); } else { jsc.add("target.removeAll" + cName + "()"); }
jsc.unindent();
jsc.add("} catch (java.lang.Exception ex) {"); jsc.indent(); jsc.add("throw new IllegalStateException(ex.toString());"); jsc.unindent(); jsc.add("}");
jsc.unindent();
jsc.add("}");
}
//-- end of reset method

Show
Lars Klose added a comment - 01/Apr/03 1:21 AM This is what I added to DescriptorSourceFactory.createXMLFieldHandler to get a working resetValue method for Java2 Collections - comments welcome! //-- reset method //--handle collections if (member.isMultivalued()) { CollectionInfo cInfo = (CollectionInfo) member; FieldInfo content = cInfo.getContent(); jsc.add("public void resetValue( Object object ) throws IllegalStateException, IllegalArgumentException {"); jsc.indent(); jsc.add("try {"); jsc.indent(); jsc.add(localClassName); jsc.append(" target = ("); jsc.append(localClassName); jsc.append(") object;"); String cName = JavaNaming.toJavaClassName(cInfo.getElementName()); if (cInfo instanceof CollectionInfoJ2) { jsc.add("target.clear" + cName + "();"); } else { jsc.add("target.removeAll" + cName + "()"); } jsc.unindent(); jsc.add("} catch (java.lang.Exception ex) {"); jsc.indent(); jsc.add("throw new IllegalStateException(ex.toString());"); jsc.unindent(); jsc.add("}"); jsc.unindent(); jsc.add("}"); } //-- end of reset method
Hide
Permalink
Keith Visco added a comment - 01/Apr/03 1:27 AM

Thanks Lars, I'll review the code once I have an opportunity to do so, hopefully
this week.

Show
Keith Visco added a comment - 01/Apr/03 1:27 AM Thanks Lars, I'll review the code once I have an opportunity to do so, hopefully this week.
Hide
Permalink
Werner Guttmann added a comment - 08/Oct/06 6:04 AM

I think a sample XML schema would be of great benefit in this context. Given a working XML schema, it should be straight-forward to turn this (possible) patch around quickly.

Show
Werner Guttmann added a comment - 08/Oct/06 6:04 AM I think a sample XML schema would be of great benefit in this context. Given a working XML schema, it should be straight-forward to turn this (possible) patch around quickly.
Hide
Permalink
Lars Klose added a comment - 09/Oct/06 6:34 AM

Unfortunately, after a mere 3.5 years after reporting this bug, I don't have the original schema I was working on then available any more...
However, I think the original bug description should be clear enough. Any schema containing a multi-valued type would have exhibited the described behaviour, which didn't allow to reset/clear the values of such a field in the generated class.

Show
Lars Klose added a comment - 09/Oct/06 6:34 AM Unfortunately, after a mere 3.5 years after reporting this bug, I don't have the original schema I was working on then available any more... However, I think the original bug description should be clear enough. Any schema containing a multi-valued type would have exhibited the described behaviour, which didn't allow to reset/clear the values of such a field in the generated class.
Hide
Permalink
Werner Guttmann added a comment - 09/Oct/06 7:24 AM

Thanks, Lars, for the feedback (despite the long time it took us to pick this up).

Show
Werner Guttmann added a comment - 09/Oct/06 7:24 AM Thanks, Lars, for the feedback (despite the long time it took us to pick this up).
Hide
Permalink
Werner Guttmann added a comment - 14/Oct/06 6:28 AM

Patch committed as is (after slight refactoring).

Show
Werner Guttmann added a comment - 14/Oct/06 6:28 AM Patch committed as is (after slight refactoring).

People

  • Assignee:
    Werner Guttmann
    Reporter:
    Lars Klose
Vote (0)
Watch (0)

Dates

  • Created:
    31/Mar/03 1:55 PM
    Updated:
    22/Oct/06 3:21 PM
    Resolved:
    14/Oct/06 6:28 AM

Time Tracking

Estimated:
45m
Original Estimate - 45 minutes
Remaining:
45m
Remaining Estimate - 45 minutes
Logged:
Not Specified
Time Spent - Not Specified
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.