KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > xpdl > elements > Condition


1 package org.enhydra.shark.xpdl.elements;
2
3 import org.enhydra.shark.xpdl.XMLAttribute;
4 import org.enhydra.shark.xpdl.XMLComplexElement;
5 import org.enhydra.shark.xpdl.XPDLConstants;
6
7 /**
8  * Represents coresponding element from XPDL schema.
9  *
10  * @author Sasa Bojanic
11  */

12 public class Condition extends XMLComplexElement {
13    
14    public Condition (Transition parent) {
15       super(parent, false);
16    }
17
18    protected void fillStructure () {
19       XMLAttribute attrType=new XMLAttribute(this,"Type",
20             false,new String JavaDoc[] {
21                "",
22                XPDLConstants.CONDITION_TYPE_CONDITION,
23                XPDLConstants.CONDITION_TYPE_OTHERWISE,
24                XPDLConstants.CONDITION_TYPE_EXCEPTION,
25                XPDLConstants.CONDITION_TYPE_DEFAULTEXCEPTION
26             }, 0);
27
28       add(attrType);
29    }
30
31    public void setValue(String JavaDoc v) {
32       if (isReadOnly) {
33          throw new RuntimeException JavaDoc("Can't set the value of read only element!");
34       }
35       this.value = v;
36    }
37    
38    public XMLAttribute getTypeAttribute() {
39       return (XMLAttribute)get("Type");
40    }
41    
42    public String JavaDoc getType () {
43       return getTypeAttribute().toValue();
44    }
45    public void setTypeNONE () {
46       getTypeAttribute().setValue("");
47    }
48    public void setTypeCONDITION () {
49       getTypeAttribute().setValue(XPDLConstants.CONDITION_TYPE_CONDITION);
50    }
51    public void setTypeOTHERWISE () {
52       getTypeAttribute().setValue(XPDLConstants.CONDITION_TYPE_OTHERWISE);
53    }
54    public void setTypeEXCEPTION () {
55       getTypeAttribute().setValue(XPDLConstants.CONDITION_TYPE_EXCEPTION);
56    }
57    public void setTypeDEFAULTEXCEPTION () {
58       getTypeAttribute().setValue(XPDLConstants.CONDITION_TYPE_DEFAULTEXCEPTION);
59    }
60
61 }
62
Popular Tags