00001 package edu.ksu.cis.bandera.bir;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 import ca.mcgill.sable.util.*;
00036
00037 public class ThreadAction extends AbstractAction implements BirConstants {
00038
00039 BirThread threadArg;
00040 int operation;
00041 BirThread thread;
00042
00043 public ThreadAction(BirThread threadArg, int operation,
00044 BirThread thread) {
00045 this.threadArg = threadArg;
00046 this.operation = operation;
00047 this.thread = thread;
00048 }
00049 public void apply(Switch sw)
00050 {
00051 ((ExprSwitch) sw).caseThreadAction(this);
00052 }
00053 public int getOperation() { return operation; }
00054 public BirThread getThread() { return thread; }
00055 public BirThread getThreadArg() { return threadArg; }
00056 public boolean isExit() {
00057 return operation == EXIT;
00058 }
00059 public boolean isJoin() {
00060 return operation == JOIN;
00061 }
00062 public boolean isStart() {
00063 return operation == START;
00064 }
00065 public boolean isThreadAction(int operation) {
00066 return (operation & this.operation) != 0;
00067 }
00068 public static int operationCode(String methodName) {
00069 if (methodName.equals("start"))
00070 return START;
00071 if (methodName.equals("join"))
00072 return JOIN;
00073 if (methodName.equals("exit"))
00074 return EXIT;
00075 return INVALID;
00076 }
00077 public static String operationName(int operation) {
00078 switch (operation) {
00079 case START: return "start";
00080 case JOIN: return "join";
00081 case EXIT: return "exit";
00082 default: return "?";
00083 }
00084 }
00085 }