KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > trading > db > pse > offers > ProxyOffer


1
2 // Copyright (C) 1998-1999
3
// Object Oriented Concepts, Inc.
4

5 // **********************************************************************
6
//
7
// Copyright (c) 1997
8
// Mark Spruiell (mark@intellisoft.com)
9
//
10
// See the COPYING file for more information
11
//
12
// **********************************************************************
13

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 JavaDoc m_id;
32   private String JavaDoc m_target;
33   private OSVector m_props;
34   private boolean m_ifMatchAll;
35   private String JavaDoc 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 JavaDoc id,
47     Lookup target,
48     Property[] props,
49     boolean ifMatchAll,
50     String JavaDoc 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 JavaDoc 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 JavaDoc o)
110   {
111     ProxyOffer proxy = (ProxyOffer)o;
112     return m_id.equals(proxy.m_id);
113   }
114
115
116   /** ObjectStore PSE hook method to initialize transient fields */
117   public void postInitializeContents()
118   {
119     m_description = null;
120   }
121
122
123   /** ObjectStore PSE hook method to clear transient fields */
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