1 20 21 package org.jacorb.idl; 22 23 24 31 32 33 public abstract class VectorType 34 extends TemplateTypeSpec 35 { 36 TypeSpec type_spec; 37 38 public VectorType( int num ) 39 { 40 super( num ); 41 } 42 43 46 47 public TypeSpec elementTypeSpec() 48 { 49 TypeSpec t = type_spec.typeSpec(); 50 51 56 57 if( t instanceof ScopedName ) 58 { 59 t = ( (ScopedName)t ).resolvedTypeSpec().typeSpec(); 60 } 61 return t; 62 } 63 64 65 public void setTypeSpec( SimpleTypeSpec sts ) 66 { 67 type_spec = sts; 68 } 69 70 74 75 public String typeName() 76 { 77 String name; 78 79 if( type_spec.typeSpec() instanceof ScopedName ) 80 { 81 name = 82 ( (ScopedName)type_spec.typeSpec() ).resolvedTypeSpec().toString(); 83 } 84 else 85 { 86 name = type_spec.toString(); 87 } 88 89 return name + "[]"; 90 } 91 92 boolean typedefd() 93 { 94 return typedefd; 95 } 96 97 public String printReadExpression( String streamname ) 98 { 99 if( typedefd() ) 100 return helperName() + ".read(" + streamname + ")"; 101 else 102 return "*****"; 103 } 104 105 106 protected String elementTypeExpression() 107 { 108 TypeSpec ts = type_spec.typeSpec(); 109 110 if( ts instanceof AliasTypeSpec ) 111 { 112 return type_spec.full_name() + "Helper.type()"; 113 } 114 else if( ts instanceof BaseType || 115 ts instanceof TypeCodeTypeSpec || 116 ts instanceof ConstrTypeSpec || ts instanceof TemplateTypeSpec ) 118 { 119 return ts.getTypeCodeExpression(); 120 } 121 else 122 { 123 return ts.typeName() + "Helper.type()"; 124 } 125 } 126 127 public String elementTypeName() 128 { 129 TypeSpec ts = type_spec; 130 if( ts instanceof ScopedName ) 131 { 132 if( logger.isFatalErrorEnabled() ) 133 logger.fatalError( "elementTypeName is outer ScopedName" ); 134 ts = ( (ScopedName)type_spec.type_spec ).resolvedTypeSpec(); 135 136 while( ts instanceof ScopedName || ts instanceof AliasTypeSpec ) 137 { 138 if( ts instanceof ScopedName ) 139 { 140 if( logger.isFatalErrorEnabled() ) 141 logger.fatalError( "elementTypeName is inner Alias" ); 142 ts = ( (ScopedName)ts ).resolvedTypeSpec(); 143 } 144 if( ts instanceof AliasTypeSpec ) 145 { 146 if( logger.isFatalErrorEnabled() ) 147 logger.fatalError( "elementTypeName is inner Alias" ); 148 ts = ( (AliasTypeSpec)ts ).originalType(); 149 } 150 } 151 } 152 return ts.typeName(); 153 } 154 155 160 161 public abstract int length(); 162 163 public abstract String holderName(); 164 165 public abstract String helperName(); 166 167 168 public String toString() 169 { 170 return typeName(); 171 } 172 173 174 } 175 | Popular Tags |