KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

13 package org.jacorb.trading.db.pse.types;
14
15 import java.util.*;
16 import org.omg.CORBA.*;
17 import org.omg.CosTradingRepos.ServiceTypeRepositoryPackage.*;
18
19 public class TypeProperty
20 {
21     private String JavaDoc m_name;
22     private int m_kind;
23     private boolean m_sequence;
24     private int m_mode;
25
26     public TypeProperty()
27     {
28     }
29
30     public TypeProperty(PropStruct ps)
31     {
32     m_name = ps.name;
33     m_mode = ps.mode.value();
34
35     TCKind kind = ps.value_type.kind();
36     if (kind == TCKind.tk_sequence) {
37         m_sequence = true;
38         try {
39         TypeCode elemTC = ps.value_type.content_type();
40         kind = elemTC.kind();
41         m_kind = kind.value();
42         }
43         catch (org.omg.CORBA.TypeCodePackage.BadKind JavaDoc e) {
44         throw new RuntimeException JavaDoc();
45         }
46     }
47     else {
48         m_sequence = false;
49         m_kind = kind.value();
50     }
51     }
52
53
54     public String JavaDoc getName()
55     {
56     return m_name;
57     }
58
59
60     public PropStruct describe()
61     {
62     PropStruct result = new PropStruct();
63
64     ORB orb = ORB.init();
65
66     result.name = m_name;
67
68     if (m_sequence) {
69         TypeCode contentType = orb.get_primitive_tc(TCKind.from_int(m_kind));
70         result.value_type = orb.create_sequence_tc(0, contentType);
71     }
72     else
73         result.value_type = orb.get_primitive_tc(TCKind.from_int(m_kind));
74
75     result.mode = PropertyMode.from_int(m_mode);
76
77     return result;
78     }
79
80
81     public int hashCode()
82     {
83     return m_name.hashCode();
84     }
85
86
87     public boolean equals(java.lang.Object JavaDoc o)
88     {
89     TypeProperty prop = (TypeProperty)o;
90     return m_name.equals(prop.getName());
91     }
92 }
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Popular Tags