01: package org.enhydra.shark.xpdl.elements;
02:
03: import org.enhydra.shark.xpdl.XMLAttribute;
04: import org.enhydra.shark.xpdl.XMLComplexElement;
05: import org.enhydra.shark.xpdl.XMLElement;
06: import org.enhydra.shark.xpdl.XMLElementChangeInfo;
07:
08: /**
09: * Represents coresponding element from XPDL schema.
10: *
11: * @author Sasa Bojanic
12: */
13: public class ExtendedAttribute extends XMLComplexElement {
14:
15: public ExtendedAttribute(ExtendedAttributes parent) {
16: super (parent, true);
17: }
18:
19: protected void fillStructure() {
20: XMLAttribute attrName = new XMLAttribute(this , "Name", true); // required
21: XMLAttribute attrValue = new XMLAttribute(this , "Value", false);
22:
23: add(attrName);
24: add(attrValue);
25: }
26:
27: public void makeAs(XMLElement el) {
28: super .makeAs(el);
29: setValue(el.toValue());
30: }
31:
32: public void setValue(String v) {
33: if (isReadOnly) {
34: throw new RuntimeException(
35: "Can't set the value of read only element!");
36: }
37: boolean notify = false;
38: String oldValue = value;
39: if (!this .value.equals(v)) {
40: notify = true;
41: }
42:
43: this .value = v;
44:
45: if (notify && (notifyMainListeners || notifyListeners)) {
46: XMLElementChangeInfo info = createInfo(oldValue, value,
47: null, XMLElementChangeInfo.UPDATED);
48: if (notifyListeners) {
49: notifyListeners(info);
50: }
51: if (notifyMainListeners) {
52: notifyMainListeners(info);
53: }
54: }
55: }
56:
57: public String getName() {
58: return get("Name").toValue();
59: }
60:
61: public void setName(String name) {
62: set("Name", name);
63: }
64:
65: public String getVValue() {
66: return get("Value").toValue();
67: }
68:
69: public void setVValue(String value) {
70: set("Value", value);
71: }
72:
73: }
|