ConfigurationElement.java
4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.configuration;
import com.adobe.xfa.Arg;
import com.adobe.xfa.Attribute;
import com.adobe.xfa.Element;
import com.adobe.xfa.GenericAttribute;
import com.adobe.xfa.Model;
import com.adobe.xfa.Node;
import com.adobe.xfa.Obj;
import com.adobe.xfa.ScriptDynamicPropObj;
import com.adobe.xfa.ScriptTable;
import com.adobe.xfa.XFA;
import com.adobe.xfa.configuration.ConfigurationElementScript;
import com.adobe.xfa.ut.StringUtils;
import org.xml.sax.Attributes;
public class ConfigurationElement
extends Element {
private static final ScriptDynamicPropObj attributeFuncScriptObj = new ScriptDynamicPropObj(10, 63){
@Override
public boolean invokeGetProp(Obj scriptThis, Arg retValue, String sPropertyName) {
return ConfigurationElement.getAttributeFunc(scriptThis, retValue, sPropertyName);
}
@Override
public boolean invokeSetProp(Obj scriptThis, Arg retValue, String sPropertyName) {
return ConfigurationElement.setAttributeFunc(scriptThis, retValue, sPropertyName);
}
@Override
public boolean hasSetter() {
return true;
}
};
public ConfigurationElement(Element parent, Node prevSibling, String uri, String lname, String qname, Attributes attr, int classTag, String className) {
super(parent, prevSibling, uri, lname, qname, attr, classTag, className);
}
@Override
protected boolean canCreateChild(boolean bIsLeaf, String aName) {
assert (aName != null);
int eClassTag = XFA.getTag(aName);
if (eClassTag >= 0 && this.isValidElement(eClassTag, false)) {
return true;
}
if (bIsLeaf && this.isValidElement(XFA.CONFIGURATIONVALUETAG, false)) {
return true;
}
if (!bIsLeaf && this.isValidElement(XFA.CONFIGURATIONKEYTAG, false)) {
return true;
}
return false;
}
@Override
protected Node createChild(boolean bIsLeaf, String aName) {
int eClassTag = XFA.getTag(aName);
Element oNode = eClassTag >= 0 && this.isValidElement(eClassTag, false) ? this.getModel().createElement(this, null, null, aName, aName, null, 0, null) : (bIsLeaf ? this.getModel().createElement(XFA.CONFIGURATIONVALUETAG, aName) : this.getModel().createElement(XFA.CONFIGURATIONKEYTAG, aName));
return oNode;
}
@Override
protected void setClass(Element parent, int eTag) {
if (parent != null && parent.isValidChild(eTag, 0, false, false)) {
super.setClass(XFA.getAtom(eTag), eTag);
}
}
@Override
public String getName() {
String sName = super.getName();
if (StringUtils.isEmpty(sName)) {
sName = super.getLocalName();
}
return sName;
}
@Override
public boolean isValidAttr(int eTag, boolean bReport, String value) {
if (super.isValidAttr(eTag, bReport, value)) {
return true;
}
if (this.getClassTag() == XFA.CONFIGURATIONKEYTAG || this.getClassTag() == XFA.CONFIGURATIONVALUETAG) {
return true;
}
return false;
}
@Override
protected ScriptDynamicPropObj getDynamicScriptProp(String sPropertyName, boolean bPropertyOverride, boolean bPeek) {
if (this.getClassTag() == XFA.CONFIGURATIONKEYTAG || this.getClassTag() == XFA.CONFIGURATIONVALUETAG) {
ScriptDynamicPropObj scriptDynamicPropObj = super.getDynamicScriptProp(sPropertyName, bPropertyOverride, bPeek);
if (scriptDynamicPropObj != null) {
return scriptDynamicPropObj;
}
int nAttrIdx = this.findAttr(null, sPropertyName.intern());
if (nAttrIdx >= 0) {
return attributeFuncScriptObj;
}
} else {
return super.getDynamicScriptProp(sPropertyName, bPropertyOverride, bPeek);
}
return null;
}
private static boolean getAttributeFunc(Obj scriptThis, Arg retVal, String sProp) {
if (StringUtils.isEmpty(sProp)) {
return false;
}
ConfigurationElement element = (ConfigurationElement)scriptThis;
int index = element.findAttr(null, sProp.intern());
if (index == -1) {
return false;
}
retVal.setString(element.getAttrVal(index));
return true;
}
private static boolean setAttributeFunc(Obj scriptThis, Arg value, String sProp) {
if (StringUtils.isEmpty(sProp)) {
return false;
}
ConfigurationElement element = (ConfigurationElement)scriptThis;
element.updateAttribute(new GenericAttribute(null, sProp, sProp, value.toString()));
return true;
}
@Override
public ScriptTable getScriptTable() {
return ConfigurationElementScript.getScriptTable();
}
}