1 2 3 package SOFA.SOFAnode.Util; 4 5 6 13 class ActionToken implements Printer { 14 15 18 public String name; 19 20 26 public ActionToken( String s ) { 27 name = s; 28 } 29 30 39 public ActionToken toTauActionToken() { 40 if( name.startsWith("?") || name.startsWith( "!" ) ) 41 return new ActionToken((new String ("#")).concat(name.substring(1))); 42 else return new ActionToken("#" + name ); 43 } 44 45 54 public ActionToken toInverseActionToken() { 55 String e; 56 if( name.startsWith( "!" ) ) 57 e = (new String ( "?" )).concat(name.substring(1)); 58 else if( name.startsWith( "?" ) ) 59 e = (new String ( "!" )).concat(name.substring(1)); 60 else e = name; 61 return new ActionToken(e); 62 } 63 64 71 public ActionToken toEvent() { 72 String e = name; 73 if( name.startsWith( "!" ) || name.startsWith( "?" ) || name.startsWith( "#" ) ) 74 e = name.substring(1); 75 return new ActionToken(e); 76 } 77 78 85 public boolean isRequest() { 86 return name.endsWith( "^" ); 87 } 88 89 96 public boolean isResponse() { 97 return name.endsWith( "$" ); 98 } 99 100 107 public boolean isGeneralEvent() { 108 return name.endsWith( "~" ); 109 } 110 111 public boolean isEvent() { 112 return ! ( name.startsWith("?") || name.startsWith("!") || name.startsWith( "#" )); 113 } 114 115 122 public boolean isSpecial() { 123 return name.startsWith( "[" ); 124 } 125 126 134 public boolean isSimpleCall() { 135 return ! ( this.isResponse() || this.isRequest() || this.isGeneralEvent() || this.isSpecial() ); 136 } 137 138 public String getHashKey() { 139 return name.intern(); 140 } 141 142 public void Print( int level ) { 143 Debug.println( level, name ); 144 } 145 146 public void Print( ) { 147 this.Print( 1 ); 148 } 149 } | Popular Tags |