1 2 5 14 package org.jacorb.trading.db.pse.offers; 15 16 17 import java.util.*; 18 import COM.odi.*; 19 import COM.odi.util.*; 20 import org.omg.CosTrading.Lookup; 21 import org.omg.CosTrading.LookupHelper; 22 import org.omg.CosTrading.ProxyPackage.*; 23 import org.omg.CosTrading.RegisterPackage.*; 24 import org.omg.CosTrading.Property; 25 import org.omg.CosTrading.Policy; 26 import jtport.ORBLayer; 27 28 29 public class ProxyOffer 30 { 31 private String m_id; 32 private String m_target; 33 private OSVector m_props; 34 private boolean m_ifMatchAll; 35 private String m_recipe; 36 private OSVector m_policies; 37 private transient ProxyInfo m_description; 38 39 40 private ProxyOffer() 41 { 42 } 43 44 45 public ProxyOffer( 46 String id, 47 Lookup target, 48 Property[] props, 49 boolean ifMatchAll, 50 String recipe, 51 Policy[] policies) 52 { 53 m_id = id; 54 m_target = ORBLayer.instance().getORB().object_to_string(target); 55 setProperties(props); 56 m_ifMatchAll = ifMatchAll; 57 m_recipe = recipe; 58 setPolicies(policies); 59 m_description = null; 60 } 61 62 63 public ProxyInfo describe() 64 { 65 ProxyInfo result = null; 66 67 if (m_description == null) { 68 result = new ProxyInfo(); 69 org.omg.CORBA.Object obj = 70 ORBLayer.instance().getORB().string_to_object(m_target); 71 result.target = LookupHelper.narrow(obj); 72 73 result.properties = new Property[m_props.size()]; 74 int count = 0; 75 Enumeration e = m_props.elements(); 76 while (e.hasMoreElements()) { 77 OfferProperty prop = (OfferProperty)e.nextElement(); 78 result.properties[count] = prop.describe(); 79 count++; 80 } 81 82 result.if_match_all = m_ifMatchAll; 83 result.recipe = m_recipe; 84 85 result.policies_to_pass_on = new Policy[m_policies.size()]; 86 count = 0; 87 e = m_policies.elements(); 88 while (e.hasMoreElements()) { 89 ProxyPolicy policy = (ProxyPolicy)e.nextElement(); 90 result.policies_to_pass_on[count] = policy.describe(); 91 count++; 92 } 93 94 m_description = result; 95 } 96 else 97 result = m_description; 98 99 return result; 100 } 101 102 103 public int hashCode() 104 { 105 return m_id.hashCode(); 106 } 107 108 109 public boolean equals(java.lang.Object o) 110 { 111 ProxyOffer proxy = (ProxyOffer)o; 112 return m_id.equals(proxy.m_id); 113 } 114 115 116 117 public void postInitializeContents() 118 { 119 m_description = null; 120 } 121 122 123 124 public void preClearContents() 125 { 126 m_description = null; 127 } 128 129 130 protected void setProperties(Property[] props) 131 { 132 m_props = new OSVector(); 133 for (int i = 0; i < props.length; i++) { 134 OfferProperty prop = new OfferProperty(props[i]); 135 m_props.addElement(prop); 136 } 137 } 138 139 140 protected void setPolicies(Policy[] policies) 141 { 142 m_policies = new OSVector(); 143 for (int i = 0; i < policies.length; i++) { 144 ProxyPolicy policy = new ProxyPolicy(policies[i]); 145 m_policies.addElement(policy); 146 } 147 } 148 } 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | Popular Tags |