KickJava   Java API By Example, From Geeks To Geeks.

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