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 Type implements Serializable 21 { 22 private String m_name; 23 private String m_interfaceName; 24 private Vector m_properties; 25 private String [] m_superTypes; 26 private Incarnation m_incarnation; 27 private boolean m_masked; 28 private transient TypeStruct m_description; 29 30 static final long serialVersionUID = -4144073280876434847L; 31 32 public Type() 33 { 34 } 35 36 public Type( 37 String name, 38 String interfaceName, 39 PropStruct[] props, 40 String [] superTypes, 41 IncarnationNumber inc) 42 { 43 m_name = name; 44 m_interfaceName = interfaceName; 45 m_incarnation = new Incarnation(inc); 46 m_masked = false; 47 48 m_superTypes = new String [superTypes.length]; 49 for (int i = 0; i < superTypes.length; i++) 50 m_superTypes[i] = superTypes[i]; 51 52 m_properties = new Vector(); 53 for (int i = 0; i < props.length; i++) { 54 TypeProperty prop = new TypeProperty(props[i]); 55 m_properties.addElement(prop); 56 } 57 58 createDescription(); 59 } 60 61 62 public TypeStruct describe() 63 { 64 return m_description; 65 } 66 67 68 public PropStruct getPropertyInfo(String name) 69 { 70 PropStruct result = null; 71 72 for (int i = 0; i < m_description.props.length && result == null; i++) { 73 if (name.equals(m_description.props[i].name)) 74 result = m_description.props[i]; 75 } 76 77 return result; 78 } 79 80 81 public String getName() 82 { 83 return m_name; 84 } 85 86 87 public String getInterfaceName() 88 { 89 return m_interfaceName; 90 } 91 92 93 public boolean getMasked() 94 { 95 return m_masked; 96 } 97 98 99 public String [] getSuperTypes() 100 { 101 return m_description.super_types; 102 } 103 104 105 public void mask() 106 { 107 m_masked = true; 108 m_description.masked = true; 109 } 110 111 112 public void unmask() 113 { 114 m_masked = false; 115 m_description.masked = false; 116 } 117 118 119 public Incarnation getIncarnation() 120 { 121 return m_incarnation; 122 } 123 124 125 public int hashCode() 126 { 127 return m_name.hashCode(); 128 } 129 130 131 public boolean equals(java.lang.Object o) 132 { 133 Type impl = (Type)o; 134 return m_name.equals(impl.getName()); 135 } 136 137 138 private void readObject(ObjectInputStream in) 139 throws IOException, ClassNotFoundException 140 { 141 in.defaultReadObject(); 142 createDescription(); 143 } 144 145 146 private void createDescription() 147 { 148 m_description = new TypeStruct(); 149 m_description.if_name = m_interfaceName; 150 m_description.masked = m_masked; 151 m_description.incarnation = m_incarnation.getIncarnationNumber(); 152 153 Enumeration e; 154 int count; 155 156 m_description.props = new PropStruct[m_properties.size()]; 157 count = 0; 158 e = m_properties.elements(); 159 while (e.hasMoreElements()) { 160 TypeProperty prop = (TypeProperty)e.nextElement(); 161 m_description.props[count] = prop.describe(); 162 count++; 163 } 164 165 m_description.super_types = new String [m_superTypes.length]; 166 for (int i = 0; i < m_superTypes.length; i++) 167 m_description.super_types[i] = m_superTypes[i]; 168 } 169 } 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | Popular Tags |