1 4 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 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 e) { 44 throw new RuntimeException (); 45 } 46 } 47 else { 48 m_sequence = false; 49 m_kind = kind.value(); 50 } 51 } 52 53 54 public String 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 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 |