Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 41559 invoked from network); 1 May 2004 23:35:00 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 1 May 2004 23:35:00 -0000 Received: (qmail 41130 invoked by uid 500); 1 May 2004 23:34:39 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 41108 invoked by uid 500); 1 May 2004 23:34:39 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 41093 invoked from network); 1 May 2004 23:34:38 -0000 Received: from unknown (HELO moutng.kundenserver.de) (212.227.126.187) by daedalus.apache.org with SMTP; 1 May 2004 23:34:38 -0000 Received: from [212.227.126.162] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BK40M-0007bv-00 for commons-user@jakarta.apache.org; Sun, 02 May 2004 01:34:46 +0200 Received: from [217.235.98.227] (helo=diego5v37jdeuw) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1BK40L-0005i0-00 for commons-user@jakarta.apache.org; Sun, 02 May 2004 01:34:45 +0200 Message-ID: <003e01c42fd4$dd1fd680$fe78a8c0@diego5v37jdeuw> From: "Diego Amicabile" <1822-912@onlinehome.de> To: Subject: [Betwixt] Example continued, I have a problem Date: Sun, 2 May 2004 01:34:35 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_003B_01C42FE5.A04BB970" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:9aee4a804953eb2f9d4fc775c32ac6e4 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N ------=_NextPart_000_003B_01C42FE5.A04BB970 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable but if I add a class CustomerList import java.util.ArrayList; import java.util.Collection; import org.apache.commons.betwixt.io.BeanCreateRule; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class CustomerList { Collection customers =3D new ArrayList(); =20 private static Log log =3D LogFactory.getLog( BeanCreateRule.class ); =20 public static void setLog(Log aLog) { log =3D aLog; } =20 =20 =20 public Collection getCustomers() { if (customers =3D=3D null) { customers =3D new ArrayList(); } return customers; =20 } public void addCustomer(CustomerBean newCustomerBean) { log.info("adding "+newCustomerBean);=20 getCustomers().add(newCustomerBean); } =20 =20 =20 public String toString() { return ToStringBuilder.reflectionToString(this); } =20 } I leave CustomerBean.betwixt intact I use this class to write CustomerBean3.xml import java.io.File; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StringWriter; import org.apache.commons.betwixt.io.BeanWriter; import org.apache.commons.betwixt.strategy.DecapitalizeNameMapper; import org.apache.commons.betwixt.strategy.HyphenatedNameMapper; public class WriteCustomerListApp { public static final void main(String [] args) throws Exception { =20 StringWriter outputWriter =3D new StringWriter();=20 outputWriter.write(""); BeanWriter beanWriter =3D new BeanWriter(outputWriter); =20 = beanWriter.getXMLIntrospector().setAttributesForPrimitives(false); beanWriter.setWriteIDs(false); beanWriter.enablePrettyPrint(); beanWriter.getXMLIntrospector().setAttributeNameMapper(new = HyphenatedNameMapper()); =20 beanWriter.getXMLIntrospector().setElementNameMapper(new = DecapitalizeNameMapper()); CustomerList customerList =3D new CustomerList(); =20 CustomerBean customerBean =3D new CustomerBean(); customerBean.setName("Diego"); customerBean.addEmailAddre("A"); customerBean.addEmailAddre("B"); customerBean.addEmailAddre("C"); =20 customerBean.addOrder(new Order(1)); customerBean.addOrder(new Order(2)); CustomerBean customerBean2 =3D new CustomerBean(); customerBean2.setName("Paolo"); customerBean2.addEmailAddre("E"); customerBean2.addEmailAddre("F"); =20 customerBean2.addOrder(new Order(4)); customerBean2.addOrder(new Order(5)); customerBean2.addOrder(new Order(6)); customerList.addCustomer(customerBean); customerList.addCustomer(customerBean2); beanWriter.write("customerList", customerList); =20 System.out.println(outputWriter.toString()); FileOutputStream fos =3D new FileOutputStream( new File( = "CustomerBean3.xml" )); PrintWriter out =3D new PrintWriter(new = OutputStreamWriter(fos));=20 out.println(outputWriter.toString()); out.println(); =20 out.flush(); out.close(); =20 } =20 } Result is following A B C Diego E F Paolo/ I try to read this file like that import java.io.FileReader; import java.util.Collection; import org.apache.commons.betwixt.io.BeanReader; import org.apache.commons.betwixt.strategy.DecapitalizeNameMapper; import org.apache.commons.betwixt.strategy.HyphenatedNameMapper; public class ReadCustomerListApp { =20 public static final void main(String args[]) throws Exception{ FileReader xmlReader =3D new FileReader("CustomerBean3.xml"); BeanReader beanReader =3D new BeanReader(); =20 = beanReader.getXMLIntrospector().setAttributesForPrimitives(false); beanReader.setMatchIDs(false); beanReader.getXMLIntrospector().setAttributeNameMapper(new = HyphenatedNameMapper()); beanReader.getXMLIntrospector().setElementNameMapper(new = DecapitalizeNameMapper()); beanReader.registerBeanClass("customerList", = CustomerList.class); =20 beanReader.registerBeanClass("customer", CustomerBean.class); =20 =20 beanReader.registerBeanClass("order", Order.class); =20 CustomerList customerList =3D (CustomerList ) = beanReader.parse(xmlReader); =20 System.out.println(customerList ); } =20 } and I get the output=20 CustomerList@329f3d[customers=3D[CustomerBean@186c6b2[name=3DDiego,orders= =3D[],emailAddres=3D[]], = CustomerBean@1749757[name=3DPaolo,orders=3D[],emailAddres=3D[]]]] that, is the methods addOrder and addEmailAddre are never called ------=_NextPart_000_003B_01C42FE5.A04BB970--