FieldDescription.java
3.62 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceUtil
* org.apache.sling.api.resource.ValueMap
*/
package com.day.cq.wcm.foundation.forms;
import com.day.cq.wcm.foundation.forms.impl.FormsUtil;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.resource.ValueMap;
public class FieldDescription {
private String name;
private boolean required = false;
private String requiredMsg;
private String constraintType;
private String constraintMsg;
private boolean readOnly = false;
private boolean privateField = false;
private boolean multiValue = false;
private final Resource fieldResource;
public FieldDescription(Resource rsrc) {
this.fieldResource = rsrc;
}
public FieldDescription(Resource rsrc, String name) {
this.fieldResource = rsrc;
this.name = name;
}
public void update(Resource rsrc) {
ValueMap props = ResourceUtil.getValueMap((Resource)rsrc);
this.required = (Boolean)props.get("required", (Object)Boolean.FALSE);
this.readOnly = (Boolean)props.get("readOnly", (Object)Boolean.FALSE);
String name = (String)props.get("name", (Object)"");
if (name.length() == 0) {
name = ResourceUtil.getName((Resource)rsrc);
name = FormsUtil.filterElementName(name);
}
this.name = name;
String msg = (String)props.get("requiredMessage", (Object)"");
if (msg.length() == 0) {
msg = "This field is required";
}
this.requiredMsg = msg;
String constraint = (String)props.get("constraintType", (Object)"");
if (constraint.length() > 0) {
if (constraint.indexOf(47) == -1) {
constraint = "foundation/components/form/constraints/" + constraint;
}
} else {
constraint = null;
}
this.constraintType = constraint;
msg = (String)props.get("constraintMessage", (Object)"");
if (msg.length() == 0) {
msg = null;
}
this.constraintMsg = msg;
}
public Resource getFieldResource() {
return this.fieldResource;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public boolean isRequired() {
return this.required;
}
public void setRequired(boolean required) {
this.required = required;
}
public String getRequiredMessage() {
return this.requiredMsg;
}
public void setRequiredMessage(String requiredMsg) {
this.requiredMsg = requiredMsg;
}
public String getConstraintType() {
return this.constraintType;
}
public void setConstraintType(String constraintType) {
this.constraintType = constraintType;
}
public String getConstraintMessage() {
return this.constraintMsg;
}
public void setConstraintMessage(String constraintMsg) {
this.constraintMsg = constraintMsg;
}
public boolean isReadOnly() {
return this.readOnly;
}
public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}
public boolean isPrivate() {
return this.privateField;
}
public void setPrivateField(boolean flag) {
this.privateField = flag;
}
public boolean isMultiValue() {
return this.multiValue;
}
public void setMultiValue(boolean flag) {
this.multiValue = flag;
}
}