Thread: AW: clone list
Brought to you by:
chanscte,
schulte2005
From: Schuster, A. <ale...@ca...> - 2010-05-10 13:54:34
|
Hi, first of all I would like to thank you for writing the copy-constructor plugin. Unfortunately I have some problems when it comes to a Java List, i.e. For the member protected List<DeviceInformation> members = new ArrayList<DeviceInformation>(); the plugin generates the following line in the copy-constructor this.members = ((o.getMembers() == null)?null:o.getMembers().clone()); with the help of the method public List<DeviceInformation> getMembers() { return members; } The problem hereby is that the Java interface 'List' does not have the method clone(), which results in the following compilation error Cannot find symbol : method clone() ArrayList would have the clone() method though, therefore I was wondering if a cast would help? this.members = ((o.getMembers() == null)?null((ArrayList)o.getMembers()).clone()); Have you had this problem before? Do you have any suggestions or solutions? Thank you very much for any help Alex |
From: Christian S. <sch...@us...> - 2010-05-10 21:37:33
|
Schuster, Alexander schrieb: > > For the member > protected List<DeviceInformation> members = new ArrayList<DeviceInformation>(); > > the plugin generates the following line in the copy-constructor > this.members = ((o.getMembers() == null)?null:o.getMembers().clone()); > > with the help of the method > public List<DeviceInformation> getMembers() { > return members; > } > Could you please provide a schema(fragment) used to produce that code ? -- Christian |
From: Schuster, A. <ale...@ca...> - 2010-05-12 10:31:31
|
Hi Christian, thanks for your fast response. I created an example in order to be able to comprehend the problem. The according .xsd as well as the generated classes are attached to this e-mail. During compilation the following error occurs: target\generated-sources\xjc\com\mycompany\mynamespace\TypeA.java:[80,65] cannot find symbol symbol : method clone() location: interface java.util.List<com.mycompany.mynamespace.TypeC> Thank you very much for any assistance Alex -----Ursprüngliche Nachricht----- Von: Christian Schulte [mailto:sch...@us...] Gesendet: Montag, 10. Mai 2010 23:19 An: CC-XJC Users Betreff: Re: AW: clone list Schuster, Alexander schrieb: > > For the member > protected List<DeviceInformation> members = new ArrayList<DeviceInformation>(); > > the plugin generates the following line in the copy-constructor > this.members = ((o.getMembers() == null)?null:o.getMembers().clone()); > > with the help of the method > public List<DeviceInformation> getMembers() { > return members; > } > Could you please provide a schema(fragment) used to produce that code ? -- Christian ------------------------------------------------------------------------------ _______________________________________________ ccxjc-users mailing list ccx...@li... https://lists.sourceforge.net/lists/listinfo/ccxjc-users |
From: Schuster, A. <ale...@ca...> - 2010-05-12 10:32:59
|
Attachment.... -----Ursprüngliche Nachricht----- Von: Schuster, Alexander [mailto:ale...@ca...] Gesendet: Mittwoch, 12. Mai 2010 12:31 An: CC-XJC Users Betreff: AW: AW: clone list Hi Christian, thanks for your fast response. I created an example in order to be able to comprehend the problem. The according .xsd as well as the generated classes are attached to this e-mail. During compilation the following error occurs: target\generated-sources\xjc\com\mycompany\mynamespace\TypeA.java:[80,65] cannot find symbol symbol : method clone() location: interface java.util.List<com.mycompany.mynamespace.TypeC> Thank you very much for any assistance Alex -----Ursprüngliche Nachricht----- Von: Christian Schulte [mailto:sch...@us...] Gesendet: Montag, 10. Mai 2010 23:19 An: CC-XJC Users Betreff: Re: AW: clone list Schuster, Alexander schrieb: > > For the member > protected List<DeviceInformation> members = new ArrayList<DeviceInformation>(); > > the plugin generates the following line in the copy-constructor > this.members = ((o.getMembers() == null)?null:o.getMembers().clone()); > > with the help of the method > public List<DeviceInformation> getMembers() { > return members; > } > Could you please provide a schema(fragment) used to produce that code ? -- Christian ------------------------------------------------------------------------------ _______________________________________________ ccxjc-users mailing list ccx...@li... https://lists.sourceforge.net/lists/listinfo/ccxjc-users ------------------------------------------------------------------------------ _______________________________________________ ccxjc-users mailing list ccx...@li... https://lists.sourceforge.net/lists/listinfo/ccxjc-users |
From: Schuster, A. <ale...@ca...> - 2010-05-12 10:35:33
|
Attachment 2nd try -----Ursprüngliche Nachricht----- Von: Schuster, Alexander [mailto:ale...@ca...] Gesendet: Mittwoch, 12. Mai 2010 12:31 An: CC-XJC Users Betreff: AW: AW: clone list Hi Christian, thanks for your fast response. I created an example in order to be able to comprehend the problem. The according .xsd as well as the generated classes are attached to this e-mail. During compilation the following error occurs: target\generated-sources\xjc\com\mycompany\mynamespace\TypeA.java:[80,65] cannot find symbol symbol : method clone() location: interface java.util.List<com.mycompany.mynamespace.TypeC> Thank you very much for any assistance Alex -----Ursprüngliche Nachricht----- Von: Christian Schulte [mailto:sch...@us...] Gesendet: Montag, 10. Mai 2010 23:19 An: CC-XJC Users Betreff: Re: AW: clone list Schuster, Alexander schrieb: > > For the member > protected List<DeviceInformation> members = new > ArrayList<DeviceInformation>(); > > the plugin generates the following line in the copy-constructor > this.members = ((o.getMembers() == null)?null:o.getMembers().clone()); > > with the help of the method > public List<DeviceInformation> getMembers() { > return members; > } > Could you please provide a schema(fragment) used to produce that code ? -- Christian ------------------------------------------------------------------------------ _______________________________________________ ccxjc-users mailing list ccx...@li... https://lists.sourceforge.net/lists/listinfo/ccxjc-users ------------------------------------------------------------------------------ _______________________________________________ ccxjc-users mailing list ccx...@li... https://lists.sourceforge.net/lists/listinfo/ccxjc-users |
From: Schuster, A. <ale...@ca...> - 2010-05-12 10:39:22
|
It seems as if attachments are not accepted so I paste the important files in the email: XSD: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://myNamespace.myCompany.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://myNamespace.myCompany.com"> <xsd:complexType name="TypeA"> <xsd:sequence> <xsd:element name="typeB" type="tns:TypeB" minOccurs="0"/> <xsd:element name="typeCs" type="tns:TypeCs"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="TypeB"> <xsd:sequence> <xsd:element name="a" type="xsd:string" minOccurs="0"/> <xsd:element name="b" type="xsd:string" minOccurs="0"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="TypeCs"> <xsd:sequence> <xsd:element name="member" type="tns:TypeC" nillable="true" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="TypeC"> <xsd:sequence> <xsd:element name="a" type="xsd:string" minOccurs="0"/> <xsd:element name="b" type="xsd:long" minOccurs="0"/> </xsd:sequence> </xsd:complexType> </xsd:schema> Generated-Class TypeA: public class TypeA implements Cloneable { protected TypeB typeB; @XmlElementWrapper(name = "typeCs") @XmlElement(name = "member") protected List<TypeC> typeCs = new ArrayList<TypeC>(); /** * Creates a new {@code TypeA} instance. * */ public TypeA() { // CC-XJC Version 1.3 Build 2010-02-27T15:04:03+0000 super(); } /** * Creates a new {@code TypeA} instance by deeply copying a given {@code TypeA} instance. * * * @param o * The instance to copy. * @throws NullPointerException * if {@code o} is {@code null}. */ public TypeA(final TypeA o) { // CC-XJC Version 1.3 Build 2010-02-27T15:04:03+0000 super(); if (o == null) { throw new NullPointerException("Cannot create a copy of 'TypeA' from 'null'."); } // CClassInfo: com.mycompany.mynamespace.TypeB this.typeB = ((o.getTypeB() == null)?null:o.getTypeB().clone()); // CClassInfo: com.mycompany.mynamespace.TypeCs this.typeCs = ((o.getTypeCs() == null)?null:o.getTypeCs().clone()); } /** * Gets the value of the typeB property. * * @return * possible object is * {@link TypeB } * */ public TypeB getTypeB() { return typeB; } /** * Sets the value of the typeB property. * * @param value * allowed object is * {@link TypeB } * */ public void setTypeB(TypeB value) { this.typeB = value; } public List<TypeC> getTypeCs() { return typeCs; } /** * Creates and returns a deep copy of this object. * * * @return * A deep copy of this object. */ @Override public TypeA clone() { // CC-XJC Version 1.3 Build 2010-02-27T15:04:03+0000 return new TypeA(this); } } -----Ursprüngliche Nachricht----- Von: Schuster, Alexander [mailto:ale...@ca...] Gesendet: Mittwoch, 12. Mai 2010 12:35 An: CC-XJC Users Betreff: AW: AW: clone list Attachment 2nd try -----Ursprüngliche Nachricht----- Von: Schuster, Alexander [mailto:ale...@ca...] Gesendet: Mittwoch, 12. Mai 2010 12:31 An: CC-XJC Users Betreff: AW: AW: clone list Hi Christian, thanks for your fast response. I created an example in order to be able to comprehend the problem. The according .xsd as well as the generated classes are attached to this e-mail. During compilation the following error occurs: target\generated-sources\xjc\com\mycompany\mynamespace\TypeA.java:[80,65] cannot find symbol symbol : method clone() location: interface java.util.List<com.mycompany.mynamespace.TypeC> Thank you very much for any assistance Alex -----Ursprüngliche Nachricht----- Von: Christian Schulte [mailto:sch...@us...] Gesendet: Montag, 10. Mai 2010 23:19 An: CC-XJC Users Betreff: Re: AW: clone list Schuster, Alexander schrieb: > > For the member > protected List<DeviceInformation> members = new > ArrayList<DeviceInformation>(); > > the plugin generates the following line in the copy-constructor > this.members = ((o.getMembers() == null)?null:o.getMembers().clone()); > > with the help of the method > public List<DeviceInformation> getMembers() { > return members; > } > Could you please provide a schema(fragment) used to produce that code ? -- Christian ------------------------------------------------------------------------------ _______________________________________________ ccxjc-users mailing list ccx...@li... https://lists.sourceforge.net/lists/listinfo/ccxjc-users ------------------------------------------------------------------------------ _______________________________________________ ccxjc-users mailing list ccx...@li... https://lists.sourceforge.net/lists/listinfo/ccxjc-users |
From: Christian S. <sch...@us...> - 2010-05-12 13:22:59
|
Schuster, Alexander schrieb: > It seems as if attachments are not accepted so I paste the important files in the email: > > > XSD: > > <?xml version="1.0" encoding="UTF-8"?> > > <xsd:schema targetNamespace="http://myNamespace.myCompany.com" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:tns="http://myNamespace.myCompany.com"> > > <xsd:complexType name="TypeA"> > <xsd:sequence> > <xsd:element name="typeB" type="tns:TypeB" minOccurs="0"/> > <xsd:element name="typeCs" type="tns:TypeCs"/> > </xsd:sequence> > </xsd:complexType> > > <xsd:complexType name="TypeB"> > <xsd:sequence> > <xsd:element name="a" type="xsd:string" minOccurs="0"/> > <xsd:element name="b" type="xsd:string" minOccurs="0"/> > </xsd:sequence> > </xsd:complexType> > > <xsd:complexType name="TypeCs"> > <xsd:sequence> > <xsd:element name="member" type="tns:TypeC" nillable="true" minOccurs="0" maxOccurs="unbounded"/> > </xsd:sequence> > </xsd:complexType> > > <xsd:complexType name="TypeC"> > <xsd:sequence> > <xsd:element name="a" type="xsd:string" minOccurs="0"/> > <xsd:element name="b" type="xsd:long" minOccurs="0"/> > </xsd:sequence> > </xsd:complexType> > > </xsd:schema> Compiling that schema using the JAXB RI 2.0.5 and 2.1.12 [0] produces different code without compile errors. What JAXB implementation are you using ? [0] http://jaxb.dev.java.net -- Christian |
From: Schuster, A. <ale...@ca...> - 2010-05-12 18:12:05
|
Hi Christian, thanks for your support. You are right, the plugin works correctly. Unfortunately we have problems to use it in combination with the xml-element-wrapper plugin (http://www.conspicio.dk/blog/bjarne/jaxb-xmlelementwrapper-plugin). The wrapper plugin modifies the structure of the model which leads to compilation errors in the copy-constructor. Thank you Alex ____________________________________________________________ Alexander Schuster / Capgemini sd&m / München Tel: +49 89 63812-548 / www.de.capgemini-sdm.com Fax: +49 89 63812-490 / ale...@ca... Capgemini sd&m AG, Carl-Wery-Straße 42, 81739 München ____________________________________________________________ Vorstand: Burkhard Kehrbusch (Vorsitzender), Rüdiger Azone, Dr. Uwe Dumslaff, Kai Grambow, Dr. Michael Rading, Josef Ranner Aufsichtsrat: Patrick Nicolet (Vorsitzender) Sitz und Amtsgericht: München HRB 126057 -----Ursprüngliche Nachricht----- Von: Christian Schulte [mailto:sch...@us...] Gesendet: Mittwoch, 12. Mai 2010 15:20 An: CC-XJC Users Betreff: Re: AW: AW: clone list Schuster, Alexander schrieb: > It seems as if attachments are not accepted so I paste the important files in the email: > > > XSD: > > <?xml version="1.0" encoding="UTF-8"?> > > <xsd:schema targetNamespace="http://myNamespace.myCompany.com" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:tns="http://myNamespace.myCompany.com"> > > <xsd:complexType name="TypeA"> > <xsd:sequence> > <xsd:element name="typeB" type="tns:TypeB" minOccurs="0"/> > <xsd:element name="typeCs" type="tns:TypeCs"/> > </xsd:sequence> > </xsd:complexType> > > <xsd:complexType name="TypeB"> > <xsd:sequence> > <xsd:element name="a" type="xsd:string" minOccurs="0"/> > <xsd:element name="b" type="xsd:string" minOccurs="0"/> > </xsd:sequence> > </xsd:complexType> > > <xsd:complexType name="TypeCs"> > <xsd:sequence> > <xsd:element name="member" type="tns:TypeC" nillable="true" minOccurs="0" maxOccurs="unbounded"/> > </xsd:sequence> > </xsd:complexType> > > <xsd:complexType name="TypeC"> > <xsd:sequence> > <xsd:element name="a" type="xsd:string" minOccurs="0"/> > <xsd:element name="b" type="xsd:long" minOccurs="0"/> > </xsd:sequence> > </xsd:complexType> > > </xsd:schema> Compiling that schema using the JAXB RI 2.0.5 and 2.1.12 [0] produces different code without compile errors. What JAXB implementation are you using ? [0] http://jaxb.dev.java.net -- Christian ------------------------------------------------------------------------------ _______________________________________________ ccxjc-users mailing list ccx...@li... https://lists.sourceforge.net/lists/listinfo/ccxjc-users |