1 package org.jacorb.notification.filter.etcl; 2 3 23 24 import antlr.collections.AST; 25 26 32 33 public class TCLCleanUp extends AbstractTCLVisitor implements TCLParserTokenTypes 34 { 35 public void fix( AbstractTCLNode node ) 36 { 37 try 38 { 39 node.acceptPostOrder( this ); 40 } 41 catch ( VisitorException e ) 42 { 43 throw new RuntimeException (e.getMessage()); 44 } 45 } 46 47 public void visitComponent( ETCLComponentName component ) 48 throws VisitorException 49 { 50 insertComponentName( component ); 51 } 52 53 public void visitUnionPosition( UnionPositionOperator op ) 54 throws VisitorException 55 { 56 fixUnionPosition( op ); 57 } 58 59 63 void insertComponentName( ETCLComponentName comp ) 64 { 65 StringBuffer _name = 66 new StringBuffer ( comp.toString() ); 67 68 AbstractTCLNode _cursor = 69 comp.left(); 70 71 while ( _cursor != null ) 72 { 73 _name.append( _cursor.toString() ); 74 _cursor = ( AbstractTCLNode ) _cursor.getNextSibling(); 75 } 76 77 comp.setComponentName( _name.toString() ); 78 } 79 80 private void fixUnionPosition( UnionPositionOperator node ) 81 { 82 AST _nextSibling = node.getNextSibling(); 83 84 if ( _nextSibling == null ) 85 { 86 node.setDefault(); 87 } 88 else 89 { 90 switch ( _nextSibling.getType() ) 91 { 92 case NUMBER: 93 Double _position = ( ( NumberValue ) _nextSibling ).getNumber(); 94 node.setPosition( _position ); 95 node.setNextSibling( _nextSibling.getNextSibling() ); 96 97 case PLUS: 99 case MINUS: 101 case STRING: 103 break; 104 105 default: 106 node.setDefault(); 107 break; 108 } 109 } 110 } 111 } 112 | Popular Tags |