01: package net.sf.jdec.jvminstructions.commandholders;
02:
03: import net.sf.jdec.jvminstructions.commands.AbstractInstructionCommand;
04: import net.sf.jdec.jvminstructions.commands.IInstructionCommand;
05: import net.sf.jdec.reflection.Behaviour;
06: import net.sf.jdec.util.ExecutionState;
07:
08: public abstract class AbstractInstructionCommandHolder implements
09: IInstructionCommandHolder {
10:
11: private IInstructionCommand command;
12:
13: public AbstractInstructionCommandHolder() {
14: registerCommand();
15: }
16:
17: public IInstructionCommand getCommand() {
18: return command;
19: }
20:
21: public void setCommand(IInstructionCommand command) {
22: this .command = command;
23: }
24:
25: public String toString() {
26: StringBuffer string = new StringBuffer();
27: string.append("[ " + getName() + " -Instruction Code Pos : "
28: + ExecutionState.getCurrentInstructionPosition() + "]");
29: string.append(System.getProperty("line.separator")
30: + "[Method Name : "
31: + ((AbstractInstructionCommand) getCommand())
32: .getContext().getBehaviourName() + "]");
33: return string.toString();
34: }
35:
36: public Behaviour getContext() {
37: return ExecutionState.getMethodContext();
38: }
39:
40: protected String getName() {
41: return getClass().getName();
42: }
43:
44: protected abstract void registerCommand();
45:
46: }
|