1 4 package com.tc.object.config.schema; 5 6 import com.tc.util.Assert; 7 8 11 public class IncludeOnLoad { 12 13 private static final int UNDEFINED = -1; 14 15 public static final int METHOD = 0; public static final int CALL_CONSTRUCTOR = 1; public static final int EXECUTE = 2; 19 private int type; 20 private Object value; 21 22 public IncludeOnLoad() { 23 this(UNDEFINED, null); 24 } 25 26 public IncludeOnLoad(int type, Object value) { 27 this.type = type; 28 this.value = value; 29 } 30 31 public boolean isCallConstructorOnLoadType() { 32 return type == CALL_CONSTRUCTOR; 33 } 34 35 public boolean isExecuteScriptOnLoadType() { 36 return type == EXECUTE; 37 } 38 39 public boolean isCallMethodOnLoadType() { 40 return type == METHOD; 41 } 42 43 public boolean isCallConstructorOnLoad() { 44 if (!isCallConstructorOnLoadType()) { return false; } 45 return ((Boolean ) value).booleanValue(); 46 } 47 48 public String getExecuteScript() { 49 Assert.eval(isExecuteScriptOnLoadType()); 50 return (String ) value; 51 } 52 53 public String getMethod() { 54 Assert.eval(isCallMethodOnLoadType()); 55 return (String ) value; 56 } 57 58 public void setToCallConstructorOnLoad(boolean b) { 59 this.type = CALL_CONSTRUCTOR; 60 this.value = new Boolean (b); 61 } 62 63 public void setExecuteScriptOnLoad(String script) { 64 this.type = EXECUTE; 65 this.value = script; 66 } 67 68 public void setMethodCallOnLoad(String method) { 69 this.type = METHOD; 70 this.value = method; 71 } 72 73 public int type() { 74 return type; 75 } 76 77 public Object value() { 78 return value; 79 } 80 81 public String toString() { 82 return "type: " + type + " value=" + value; 83 } 84 85 } 86 | Popular Tags |