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