1 2 3 package SOFA.SOFAnode.Util; 4 5 import java.util.Hashtable ; 6 import java.util.Iterator ; 7 8 17 18 public class ActionTokenArray { 19 20 public boolean tokens[]; 21 22 public int size; 23 24 32 public ActionTokenArray() { 33 tokens = new boolean[ EdgeFactory.getActionTokensNum() ]; 34 size = EdgeFactory.getActionTokensNum(); 35 } 36 37 45 public ActionTokenArray( Hashtable h ) { 46 this(); 47 Debug.println(3, "ActionTokenArray: This is hashtable copy constructor"); 48 for( Iterator i = h.values().iterator(); i.hasNext(); ) { 49 ActionToken t = (ActionToken)i.next() ; 50 if( t.isEvent() ) { 51 int j = EdgeFactory.getActionTokenIdx( new ActionToken( "?"+t.name) ); 52 this.tokens[j] = true; 53 } else tokens[ EdgeFactory.getActionTokenIdx( t )] = true; 55 } 56 Debug.println(3, "ActionTokenArray: Finished hashtable copy constructor"); 57 } 58 59 65 public ActionTokenArray( ActionTokenArray h ) { 66 this(); 67 for( int i = 0 ; i < h.size ; i ++ ) 68 tokens[i] = h.tokens[i]; 69 } 70 71 79 public ActionTokenArray( String [] tokens ) { 80 81 this.tokens = new boolean[ EdgeFactory.getActionTokensNum()]; 82 size = EdgeFactory.getActionTokensNum(); 83 84 for( int i=0; i<tokens.length ; i++ ) { 86 ActionToken a = new ActionToken(tokens[i]); 87 if( a.isSimpleCall() ) { 88 int j = EdgeFactory.getActionTokenIdx( new ActionToken(tokens[i]+"^") ); 89 this.tokens[j] = true; 90 j = EdgeFactory.getActionTokenIdx( new ActionToken(tokens[i]+"$").toInverseActionToken() ); 91 this.tokens[ j ] = true; 92 } else this.tokens[EdgeFactory.getActionTokenIdx( new ActionToken( tokens[i]))] = true; 93 } 94 } 95 96 109 public boolean containsWithEventName( int tran ) { 110 if( tran == -1 ) return false; 111 int inverse = EdgeFactory.inverseActionTokens[tran]; 112 if( inverse == -1 ) inverse = tran; 113 int tau = EdgeFactory.tauActionTokens[tran]; 114 if( tau == -1 ) tau = tran; 115 116 return ( tokens[ tran ] || tokens[ inverse ] || tokens[tau] ); 117 } 118 119 128 public String toList() { 129 String l = ""; 130 for( int i = 0 ; i<size ; i ++ ) 131 if( tokens[i] ) 132 l = l + "," + EdgeFactory.ActionTokens[i].name; 133 134 if( l != "" ) l = l.substring(1); Debug.println( 3, "List of tokens: "+l ); 136 return l; 137 } 138 } | Popular Tags |