1 package org.jacorb.idl; 2 3 22 23 import java.io.PrintWriter ; 24 import java.util.*; 25 26 30 31 class RaisesExpr 32 extends IdlSymbol 33 { 34 35 public Vector nameList; 36 37 public RaisesExpr( int num ) 38 { 39 super( num ); 40 nameList = new Vector(); 41 } 42 43 public void setPackage( String s ) 44 { 45 s = parser.pack_replace( s ); 46 for( Enumeration e = nameList.elements(); 47 e.hasMoreElements(); 48 ( (ScopedName)e.nextElement() ).setPackage( s ) ) 49 ; 50 } 51 52 public boolean empty() 53 { 54 return ( nameList.size() == 0 ); 55 } 56 57 public String [] getExceptionNames() 58 { 59 String [] result = new String [ nameList.size() ]; 60 Enumeration e = nameList.elements(); 61 for( int i = 0; i < result.length; i++ ) 62 { 63 result[ i ] = ( (ScopedName)e.nextElement() ).toString(); 64 } 65 return result; 66 } 67 68 public String [] getExceptionIds() 69 { 70 String [] result = new String [ nameList.size() ]; 71 Enumeration e = nameList.elements(); 72 for( int i = 0; i < result.length; i++ ) 73 { 74 result[ i ] = ( (ScopedName)e.nextElement() ).id(); 75 } 76 return result; 77 } 78 79 public String [] getExceptionClassNames() 80 { 81 String [] result = new String [ nameList.size() ]; 82 Enumeration e = nameList.elements(); 83 for( int i = 0; i < result.length; i++ ) 84 { 85 result[ i ] = ( (ScopedName)e.nextElement() ).toString(); 86 } 87 return result; 88 } 89 90 public void parse() 91 { 92 Hashtable h = new Hashtable(); for( Enumeration e = nameList.elements(); e.hasMoreElements(); ) 94 { 95 ScopedName name = null; 96 try 97 { 98 name = (ScopedName)e.nextElement(); 99 TypeSpec ts = name.resolvedTypeSpec(); 100 if( ( (StructType)( (ConstrTypeSpec)ts ).declaration() ).isException() ) 101 { 102 h.put( name.resolvedName(), name ); 103 continue; } 105 } 107 catch( Exception ex ) 108 { 109 } 111 parser.fatal_error( "Illegal type in raises clause: " + 112 name.toString(), token ); 113 } 114 nameList = new Vector(); 117 for( Enumeration e = h.keys(); e.hasMoreElements(); ) 118 { 119 nameList.addElement( h.get( (String )e.nextElement() ) ); 120 } 121 h.clear(); 122 String [] classes = getExceptionClassNames(); 123 124 IdlSymbol myInterface = enclosing_symbol; 125 126 for( int i = 0; i < classes.length; i++ ) 127 { 128 myInterface.addImportedName( classes[ i ] ); 129 } 130 } 131 132 133 public void print( PrintWriter ps ) 134 { 135 Enumeration e = nameList.elements(); 136 if( e.hasMoreElements() ) 137 { 138 ps.print( " throws " + ( (ScopedName)e.nextElement() ) ); 139 } 140 for( ; e.hasMoreElements(); ) 141 { 142 ps.print( "," + ( (ScopedName)e.nextElement() ) ); 143 } 144 } 145 } 146 | Popular Tags |