KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > config > schema > IncludeOnLoad


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.config.schema;
5
6 import com.tc.util.Assert;
7
8 /**
9  * Represents the on-load xs:choice element
10  */

11 public class IncludeOnLoad {
12
13   private static final int UNDEFINED = -1;
14
15   public static final int METHOD = 0; // String
16
public static final int CALL_CONSTRUCTOR = 1; // Boolean
17
public static final int EXECUTE = 2; // String
18

19   private int type;
20   private Object JavaDoc value;
21
22   public IncludeOnLoad() {
23     this(UNDEFINED, null);
24   }
25
26   public IncludeOnLoad(int type, Object JavaDoc 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 JavaDoc) value).booleanValue();
46   }
47
48   public String JavaDoc getExecuteScript() {
49     Assert.eval(isExecuteScriptOnLoadType());
50     return (String JavaDoc) value;
51   }
52
53   public String JavaDoc getMethod() {
54     Assert.eval(isCallMethodOnLoadType());
55     return (String JavaDoc) value;
56   }
57
58   public void setToCallConstructorOnLoad(boolean b) {
59     this.type = CALL_CONSTRUCTOR;
60     this.value = new Boolean JavaDoc(b);
61   }
62
63   public void setExecuteScriptOnLoad(String JavaDoc script) {
64     this.type = EXECUTE;
65     this.value = script;
66   }
67
68   public void setMethodCallOnLoad(String JavaDoc method) {
69     this.type = METHOD;
70     this.value = method;
71   }
72
73   public int type() {
74     return type;
75   }
76
77   public Object JavaDoc value() {
78     return value;
79   }
80
81   public String JavaDoc toString() {
82     return "type: " + type + " value=" + value;
83   }
84
85 }
86
Popular Tags