1 /*
2 * sbxb library, part of ULMgen product
3 * Copyright (C) 2003,2005 Thierry Beigbeder
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 /*
20 * $Header: $
21 * $Revision: $
22 * $Date: $
23 *
24 * History :
25 * Who yyyy/mm/dd Action
26 * -------- ---------- ------
27 */
28
29
30 package org.otvl.sbxbsamp.abcref;
31
32
33 import org.otvl.sbxb.SbxbUtil;
34 import org.otvl.sbxb.binding.BindingSpec;
35 import org.otvl.sbxb.binding.ClassBindingSpec;
36 import org.otvl.sbxbsamp.complex.SbxbComplexSample;
37
38
39
40
41 /***
42 *
43 * @author
44 * @version
45 */
46
47
48 public class ABCRefSample
49 {
50 /*-------------------------------------------------------------------------
51 * Attributes declaration
52 *-------------------------------------------------------------------------*/
53
54
55 /*-------------------------------------------------------------------------
56 * Associations declaration
57 *-------------------------------------------------------------------------*/
58
59
60 /*-------------------------------------------------------------------------
61 * Operations
62 *-------------------------------------------------------------------------*/
63 /***
64 *
65 * @param args
66 */
67 public static void main(
68 String[] args
69 )
70 {
71
72 try {
73 org.apache.log4j.BasicConfigurator.configure();
74 new ABCRefSample().run();
75 } catch (Exception e) {
76 //System.err.println(e.getMessage());
77 e.printStackTrace();
78 }
79
80 }
81 /***
82 *
83 * @return boolean
84 */
85 public boolean run()
86 throws Exception
87
88 {
89 boolean vRun;
90
91 BindingSpec.loadProperties("org.otvl.sbxbsamp.abcref.ABCRefBindingSpec");
92 BindingSpec bs = BindingSpec.getInstance("abcref");
93 bs.putReferencer(ARefee.class,ABCRef.class);
94 bs.putReferencer(BRefee.class,ABCRef.class);
95 bs.putReferencer(CRefee.class,ABCRef.class);
96
97 CRefee cr = null;
98 RootRef rr = new RootRef();
99 ARefee ar = new ARefee();
100 ar.setId(99);
101
102 rr.addAByRef(ar);
103 ar = new ARefee();
104 ar.setId(100);
105 rr.addAByRef(ar);
106
107 ar = new ARefee();
108 ar.setId(98);
109 rr.addAByValue(ar);
110 cr = new CRefee();
111 cr.setCid("980");
112 ar.addCByRef(cr);
113
114 ar = new ARefee();
115 ar.setId(99);
116 rr.addAByValue(ar);
117 cr = new CRefee();
118 cr.setCid("990");
119 ar.addCByRef(cr);
120
121 ar = new ARefee();
122 ar.setId(11);
123 rr.addAByValue(ar);
124 cr = new CRefee();
125 cr.setCid("110");
126 ar.addCByRef(cr);
127
128 BRefee br = new BRefee();
129 br.setSid("11");
130 rr.addBByValue(br);
131 cr = new CRefee();
132 cr.setCid("110");
133 br.addCByRef(cr);
134
135 String xmlOut = SbxbUtil.sBeanToXml("RootRef","abcval",rr);
136
137 RootRef rrr = new RootRef();
138 SbxbUtil.xmlToSBean(xmlOut,"abcval",rrr);
139
140 vRun = true;
141 return vRun;
142
143 }
144
145
146 /*-------------------------------------------------------------------------
147 * Attribute accessors
148 *-------------------------------------------------------------------------*/
149
150
151 /*-------------------------------------------------------------------------
152 * Association accessors
153 *-------------------------------------------------------------------------*/
154
155 }