1 18 19 package sync4j.framework.core.dm.ddf; 20 21 import java.beans.XMLEncoder ; 22 import java.util.Map ; 23 import java.util.HashMap ; 24 import org.apache.commons.collections.map.ListOrderedMap; 25 26 27 34 35 public class SyncMLDM implements java.io.Serializable { 36 37 public static final String SYNCML_DM_BASE_URI = "./SyncML"; 39 public static final String SYNCML_DM_DMACC = "/DMAcc"; 40 public static final String SYNCML_DM_CON = "/Con" ; 41 42 43 private DMAcc dmAcc; 45 private ConNode con; 46 47 48 50 public SyncMLDM() {} 51 52 59 public SyncMLDM(final DMAcc dmAcc, 60 final ConNode con) { 61 this.dmAcc = dmAcc; 62 this.con = con; 63 } 64 65 66 68 73 public DMAcc getDmAcc() { 74 return dmAcc; 75 } 76 77 82 public void setDmAcc(DMAcc dmAcc) { 83 this.dmAcc = dmAcc; 84 } 85 86 91 public ConNode getCon() { 92 return con; 93 } 94 95 100 public void setCon(ConNode con) { 101 this.con = con; 102 } 103 104 105 109 public static void main(String [] args) { 110 SyncMLDM syncmlDm = new SyncMLDM(); 111 112 DMAcc acc = new DMAcc(); 113 Map accounts = new ListOrderedMap(); 114 115 DMAccount account = new DMAccount(); 116 accounts.put("AccountName", account); 117 118 DMAccount account2 = new DMAccount(); 119 accounts.put("AccountName2", account2); 120 account2.setAddressType(2); 121 account2.setClientNonce(new byte[] {23,24,25,26}); 122 123 acc.setDMAccounts(accounts); 124 syncmlDm.setDmAcc(acc); 125 126 account.setConRef("ConnectionName"); 127 128 Ext ext = new Ext(); 129 ext.setNode("service", "5"); 130 131 XMLEncoder enc = new XMLEncoder (System.out); 132 enc.writeObject(ext); 133 enc.flush(); 134 enc.close(); 135 136 Map auths = new ListOrderedMap(); 137 Auth auth = new Auth("id", "secret"); 138 auths.put("auth-method", auth ); 139 NAP nap = new NAP("napBearer", "napAddress", "napAddressType"); 140 nap.setAuths(auths); 141 142 Map authsPx = new ListOrderedMap(); 143 Auth authPx = new Auth("id", "secret"); 144 authsPx.put("auth-method", authPx ); 145 PX px = new PX("portNbr", "pxAddress", "pxAddressType"); 146 px.setAuths(authsPx); 147 148 Connection con = new Connection(ext, nap, px); 149 ConNode conNode = new ConNode(con, "ConnectionName"); 150 151 syncmlDm.setCon(conNode); 152 153 enc = new XMLEncoder (System.out); 154 enc.writeObject(syncmlDm); 155 enc.flush(); 156 enc.close(); 157 } 158 159 } | Popular Tags |