forked from liferay/alloy-taglibs
/
Component.java
187 lines (140 loc) · 3.9 KB
/
Component.java
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
package com.liferay.alloy.tools.model;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.TextFormatter;
import com.liferay.portal.kernel.util.Validator;
import java.util.ArrayList;
import java.util.List;
public class Component extends BaseModel {
public String getAttributeNamespace() {
StringBuilder sb = new StringBuilder();
sb.append(_package);
sb.append(StringPool.COLON);
sb.append(getUncamelizedName());
sb.append(StringPool.COLON);
return StringUtil.toLowerCase(sb.toString());
}
public List<Attribute> getAttributes() {
return _attributes;
}
public List<Attribute> getAttributesAndEvents() {
ArrayList<Attribute> attributes = new ArrayList<Attribute>();
attributes.addAll(_attributes);
attributes.addAll(_events);
return attributes;
}
public String[] getAuthors() {
return _authors;
}
public String getCamelizedName() {
return TextFormatter.format(getName(), TextFormatter.M);
}
public String getClassName() {
String className = _className;
if (Validator.isNull(className)) {
className = getSafeName().concat(_CLASS_NAME_SUFFIX);
}
return className;
}
public String getDescription() {
return _description;
}
public List<Attribute> getEvents() {
return _events;
}
public String getModule() {
return _module;
}
public String getPackage() {
return _package;
}
public String getParentClass() {
return _parentClass;
}
public String getSafeName() {
return StringUtil.replace(
getName(), StringPool.PERIOD, StringPool.BLANK);
}
public String getUncamelizedName() {
String name = getName().replaceAll("\\.", StringPool.DASH);
return TextFormatter.format(name, TextFormatter.Q);
}
public String getUncamelizedName(String delimiter) {
return getUncamelizedName().replaceAll("\\-", delimiter);
}
public boolean getWriteJSP() {
return _writeJSP;
}
public boolean isAlloyComponent() {
return _alloyComponent;
}
public boolean isBodyContent() {
return _bodyContent;
}
public boolean isComponentTaglibOSGIModule() {
return _componentTaglibOSGIModule;
}
public boolean isDynamicAttributes() {
return _dynamicAttributes;
}
public void setAlloyComponent(boolean alloyComponent) {
_alloyComponent = alloyComponent;
}
public void setAttributes(List<Attribute> attributes) {
_attributes = attributes;
for (Attribute attribute : attributes) {
attribute.setComponent(this);
}
}
public void setAuthors(String[] authors) {
_authors = authors;
}
public void setBodyContent(boolean bodyContent) {
_bodyContent = bodyContent;
}
public void setClassName(String className) {
_className = className;
}
public void setDescription(String description) {
_description = description;
}
public void setDynamicAttributes(boolean dynamicAttributes) {
_dynamicAttributes = dynamicAttributes;
}
public void setEvents(List<Attribute> events) {
_events = events;
for (Attribute event : events) {
event.setComponent(this);
}
}
public void setComponentTaglibOSGIModule(
boolean componentTaglibOSGIModule) {
_componentTaglibOSGIModule = componentTaglibOSGIModule;
}
public void setModule(String type) {
_module = type;
}
public void setPackage(String componentPackage) {
_package = componentPackage;
}
public void setParentClass(String parentClass) {
_parentClass = parentClass;
}
public void setWriteJSP(boolean writeJSP) {
_writeJSP = writeJSP;
}
private static final String _CLASS_NAME_SUFFIX = "Tag";
private boolean _alloyComponent;
private List<Attribute> _attributes;
private String[] _authors;
private boolean _bodyContent;
private String _className;
private String _description;
private boolean _dynamicAttributes;
private List<Attribute> _events;
private boolean _componentTaglibOSGIModule;
private String _module;
private String _package;
private String _parentClass;
private boolean _writeJSP;
}