IntegerValue.java
3.48 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.content;
import com.adobe.xfa.AppModel;
import com.adobe.xfa.Element;
import com.adobe.xfa.Model;
import com.adobe.xfa.Node;
import com.adobe.xfa.ScriptTable;
import com.adobe.xfa.XFA;
import com.adobe.xfa.content.Content;
import com.adobe.xfa.content.IntegerScript;
import com.adobe.xfa.ut.ExFull;
import com.adobe.xfa.ut.MsgFormatPos;
import com.adobe.xfa.ut.ResId;
import com.adobe.xfa.ut.StringUtils;
import org.xml.sax.Attributes;
public final class IntegerValue
extends Content {
public IntegerValue(Element parent, Node prevSibling) {
super(parent, prevSibling, null, "integer", "integer", null, XFA.INTEGERTAG, "integer");
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
return super.equals(object) && this.getValue() == ((IntegerValue)object).getValue();
}
@Override
public int hashCode() {
return super.hashCode() ^ this.getValue();
}
@Override
public ScriptTable getScriptTable() {
return IntegerScript.getScriptTable();
}
public int getValue() {
String sValue = this.getStrValue();
if (StringUtils.isEmpty(sValue)) {
return 0;
}
try {
return Integer.parseInt(sValue);
}
catch (NumberFormatException e) {
MsgFormatPos oMessage = new MsgFormatPos(ResId.FoundBadElementValueException);
oMessage.format(sValue);
oMessage.format(this.getSOMExpression());
oMessage.format("0");
this.getModel().addErrorList(new ExFull(oMessage), 3, this);
return 0;
}
}
public void setValue(int newValue) {
this.setStrValue(Integer.toString(newValue), true, false);
}
public void setValue(String sValue, boolean bFromData) {
if (StringUtils.isEmpty(sValue)) {
this.setStrValue("", true, false);
} else {
boolean bTypeMismatch = false;
int nVal = 0;
try {
nVal = Integer.parseInt(sValue);
}
catch (NumberFormatException e) {
this.setStrValue("", true, false);
bTypeMismatch = true;
}
if (bTypeMismatch) {
if (!this.getAppModel().getLegacySetting(AppModel.XFA_LEGACY_V30_SCRIPTING)) {
MsgFormatPos oMessage = new MsgFormatPos(ResId.TypeMismatch);
oMessage.format(this.getSOMExpression());
oMessage.format(sValue);
this.getModel().addErrorList(new ExFull(oMessage), 3, this);
}
if (this.getAppModel().getLegacySetting(AppModel.XFA_LEGACY_V29_SCRIPTING)) {
this.setValue(nVal);
} else if (bFromData) {
this.setStrValue(sValue, true, false);
}
return;
}
this.setValue(nVal);
}
}
@Override
public String toString() {
if (this.getIsNull()) {
return "0";
}
return this.getStrValue();
}
public boolean valueHasTypeMismatch() {
String sValue = this.getStrValue();
if (StringUtils.isEmpty(sValue)) {
return false;
}
try {
Integer.parseInt(sValue);
return false;
}
catch (NumberFormatException ex) {
return true;
}
}
}