KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > trading > db > pse > types > Type


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.types;
15
16
17 import java.io.*;
18 import java.util.*;
19 import COM.odi.*;
20 import COM.odi.util.*;
21 import org.omg.CORBA.*;
22 import org.omg.CosTradingRepos.ServiceTypeRepositoryPackage.*;
23
24
25 public class Type
26 {
27   private String JavaDoc m_name;
28   private String JavaDoc m_interfaceName;
29   private OSVector m_properties;
30   private String JavaDoc[] m_superTypes;
31   private Incarnation m_incarnation;
32   private boolean m_masked;
33   private transient TypeStruct m_description;
34
35
36   public Type()
37   {
38   }
39
40
41   public Type(
42     String JavaDoc name,
43     String JavaDoc interfaceName,
44     PropStruct[] props,
45     String JavaDoc[] superTypes,
46     IncarnationNumber inc)
47   {
48     m_name = name;
49     m_interfaceName = interfaceName;
50     m_incarnation = new Incarnation(inc);
51     m_masked = false;
52
53     m_superTypes = new String JavaDoc[superTypes.length];
54     for (int i = 0; i < superTypes.length; i++)
55       m_superTypes[i] = superTypes[i];
56
57     m_properties = new OSVector();
58     for (int i = 0; i < props.length; i++) {
59       TypeProperty prop = new TypeProperty(props[i]);
60       m_properties.addElement(prop);
61     }
62   }
63
64
65   public TypeStruct describe()
66   {
67     return getDescription();
68   }
69
70
71   public PropStruct getPropertyInfo(String JavaDoc name)
72   {
73     PropStruct result = null;
74
75     getDescription();
76     for (int i = 0; i < m_description.props.length && result == null; i++) {
77       if (name.equals(m_description.props[i].name))
78         result = m_description.props[i];
79     }
80
81     return result;
82   }
83
84
85   public String JavaDoc getName()
86   {
87     return m_name;
88   }
89
90
91   public String JavaDoc getInterfaceName()
92   {
93     return m_interfaceName;
94   }
95
96
97   public boolean getMasked()
98   {
99     return m_masked;
100   }
101
102
103   public String JavaDoc[] getSuperTypes()
104   {
105     getDescription();
106     return m_description.super_types;
107   }
108
109
110   public void mask()
111   {
112     m_masked = true;
113     if (m_description != null)
114       m_description.masked = true;
115   }
116
117
118   public void unmask()
119   {
120     m_masked = false;
121     if (m_description != null)
122       m_description.masked = false;
123   }
124
125
126   public Incarnation getIncarnation()
127   {
128     return m_incarnation;
129   }
130
131
132   public int hashCode()
133   {
134     return m_name.hashCode();
135   }
136
137
138   public boolean equals(java.lang.Object JavaDoc o)
139   {
140     Type impl = (Type)o;
141     return m_name.equals(impl.getName());
142   }
143
144
145   /** ObjectStore PSE hook method to initialize transient fields */
146   public void postInitializeContents()
147   {
148     m_description = null;
149   }
150
151
152   /** ObjectStore PSE hook method to clear transient fields */
153   public void preClearContents()
154   {
155     m_description = null;
156   }
157
158
159   private TypeStruct getDescription()
160   {
161     if (m_description == null) {
162       m_description = new TypeStruct();
163       m_description.if_name = m_interfaceName;
164       m_description.masked = m_masked;
165       m_description.incarnation = m_incarnation.getIncarnationNumber();
166
167       Enumeration e;
168       int count;
169
170       m_description.props = new PropStruct[m_properties.size()];
171       count = 0;
172       e = m_properties.elements();
173       while (e.hasMoreElements()) {
174         TypeProperty prop = (TypeProperty)e.nextElement();
175         m_description.props[count] = prop.describe();
176         count++;
177       }
178
179       m_description.super_types = new String JavaDoc[m_superTypes.length];
180       for (int i = 0; i < m_superTypes.length; i++)
181         m_description.super_types[i] = m_superTypes[i];
182     }
183
184     return m_description;
185   }
186 }
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
Popular Tags