1 7 8 package com.sun.corba.se.impl.orbutil.fsm ; 9 10 import com.sun.corba.se.spi.orbutil.fsm.Action ; 11 import com.sun.corba.se.spi.orbutil.fsm.State ; 12 import com.sun.corba.se.spi.orbutil.fsm.Guard ; 13 import com.sun.corba.se.spi.orbutil.fsm.Input ; 14 15 import java.util.StringTokenizer ; 16 17 public class NameBase { 18 private String name ; 19 private String toStringName ; 20 21 private String getClassName() 23 { 24 String fqn = this.getClass().getName() ; 25 StringTokenizer st = new StringTokenizer ( fqn, "." ) ; 26 String token = st.nextToken() ; 27 while (st.hasMoreTokens()) 28 token = st.nextToken() ; 29 return token ; 30 } 31 32 private String getPreferredClassName() 33 { 34 if (this instanceof Action) 35 return "Action" ; 36 if (this instanceof State) 37 return "State" ; 38 if (this instanceof Guard) 39 return "Guard" ; 40 if (this instanceof Input) 41 return "Input" ; 42 return getClassName() ; 43 } 44 45 public NameBase( String name ) 46 { 47 this.name = name ; 48 toStringName = getPreferredClassName() + "[" + name + "]" ; 49 } 50 51 public String getName() 52 { 53 return name ; 54 } 55 56 public String toString() { 57 return toStringName ; 58 } 59 } 60 61 | Popular Tags |