1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.view.facelets.compiler; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public final class FaceletsProcessingInstructions |
27 | |
{ |
28 | |
public static final String PROCESS_AS_HTML5 = "html5"; |
29 | |
public static final String PROCESS_AS_JSPX = "jspx"; |
30 | |
public static final String PROCESS_AS_XHTML = "xhtml"; |
31 | |
public static final String PROCESS_AS_XML = "xml"; |
32 | |
|
33 | 0 | private static final FaceletsProcessingInstructions FACELETS_PROCESSING_HTML5 = |
34 | |
new FaceletsProcessingInstructions( |
35 | |
false, false, false, false, true, false, true, false, true); |
36 | |
|
37 | 0 | private static final FaceletsProcessingInstructions FACELETS_PROCESSING_XHTML = |
38 | |
new FaceletsProcessingInstructions( |
39 | |
false, false, false, false, true, false, true); |
40 | |
|
41 | 0 | private static final FaceletsProcessingInstructions FACELETS_PROCESSING_XML = |
42 | |
new FaceletsProcessingInstructions( |
43 | |
true, true, true, true, true, true, true); |
44 | |
|
45 | 0 | private static final FaceletsProcessingInstructions FACELETS_PROCESSING_JSPX = |
46 | |
new FaceletsProcessingInstructions( |
47 | |
true, true, true, true, false, true, false); |
48 | |
|
49 | 0 | private static final FaceletsProcessingInstructions FACELETS_PROCESSING_HTML5_COMPRESS_SPACES = |
50 | |
new FaceletsProcessingInstructions( |
51 | |
false, false, false, false, true, false, true, true, true); |
52 | |
|
53 | 0 | private static final FaceletsProcessingInstructions FACELETS_PROCESSING_XHTML_COMPRESS_SPACES = |
54 | |
new FaceletsProcessingInstructions( |
55 | |
false, false, false, false, true, false, true, true); |
56 | |
|
57 | 0 | private static final FaceletsProcessingInstructions FACELETS_PROCESSING_XML_COMPRESS_SPACES = |
58 | |
new FaceletsProcessingInstructions( |
59 | |
true, true, true, true, true, true, true, true); |
60 | |
|
61 | 0 | private static final FaceletsProcessingInstructions FACELETS_PROCESSING_JSPX_COMPRESS_SPACES = |
62 | |
new FaceletsProcessingInstructions( |
63 | |
true, true, true, true, false, true, false, true); |
64 | |
|
65 | |
private final boolean consumeXmlDocType; |
66 | |
|
67 | |
private final boolean consumeXmlDeclaration; |
68 | |
|
69 | |
private final boolean consumeProcessingInstructions; |
70 | |
|
71 | |
private final boolean consumeCDataSections; |
72 | |
|
73 | |
private final boolean escapeInlineText; |
74 | |
|
75 | |
private final boolean consumeXMLComments; |
76 | |
|
77 | |
private final boolean swallowCDataContent; |
78 | |
|
79 | |
private final boolean compressSpaces; |
80 | |
|
81 | |
private final boolean html5Doctype; |
82 | |
|
83 | |
public static FaceletsProcessingInstructions getProcessingInstructions(String processAs) |
84 | |
{ |
85 | 0 | if (processAs == null) |
86 | |
{ |
87 | 0 | return FACELETS_PROCESSING_HTML5; |
88 | |
} |
89 | 0 | else if (PROCESS_AS_HTML5.equals(processAs)) |
90 | |
{ |
91 | 0 | return FACELETS_PROCESSING_HTML5; |
92 | |
} |
93 | 0 | else if (PROCESS_AS_XHTML.equals(processAs)) |
94 | |
{ |
95 | 0 | return FACELETS_PROCESSING_XHTML; |
96 | |
} |
97 | 0 | else if (PROCESS_AS_XML.equals(processAs)) |
98 | |
{ |
99 | 0 | return FACELETS_PROCESSING_XML; |
100 | |
} |
101 | 0 | else if (PROCESS_AS_JSPX.equals(processAs)) |
102 | |
{ |
103 | 0 | return FACELETS_PROCESSING_JSPX; |
104 | |
} |
105 | |
else |
106 | |
{ |
107 | 0 | return FACELETS_PROCESSING_XHTML; |
108 | |
} |
109 | |
} |
110 | |
|
111 | |
public static FaceletsProcessingInstructions getProcessingInstructions( |
112 | |
String processAs, boolean compressSpaces) |
113 | |
{ |
114 | 0 | if (!compressSpaces) |
115 | |
{ |
116 | 0 | return getProcessingInstructions(processAs); |
117 | |
} |
118 | 0 | if (processAs == null) |
119 | |
{ |
120 | 0 | return FACELETS_PROCESSING_HTML5_COMPRESS_SPACES; |
121 | |
} |
122 | 0 | else if (PROCESS_AS_HTML5.equals(processAs)) |
123 | |
{ |
124 | 0 | return FACELETS_PROCESSING_HTML5_COMPRESS_SPACES; |
125 | |
} |
126 | 0 | else if (PROCESS_AS_XHTML.equals(processAs)) |
127 | |
{ |
128 | 0 | return FACELETS_PROCESSING_XHTML_COMPRESS_SPACES; |
129 | |
} |
130 | 0 | else if (PROCESS_AS_XML.equals(processAs)) |
131 | |
{ |
132 | 0 | return FACELETS_PROCESSING_XML_COMPRESS_SPACES; |
133 | |
} |
134 | 0 | else if (PROCESS_AS_JSPX.equals(processAs)) |
135 | |
{ |
136 | 0 | return FACELETS_PROCESSING_JSPX_COMPRESS_SPACES; |
137 | |
} |
138 | |
else |
139 | |
{ |
140 | 0 | return FACELETS_PROCESSING_XHTML_COMPRESS_SPACES; |
141 | |
} |
142 | |
} |
143 | |
|
144 | |
public FaceletsProcessingInstructions( |
145 | |
boolean consumeXmlDocType, |
146 | |
boolean consumeXmlDeclaration, |
147 | |
boolean consumeProcessingInstructions, |
148 | |
boolean consumeCDataSections, |
149 | |
boolean escapeInlineText, |
150 | |
boolean consumeXMLComments, |
151 | |
boolean swallowCDataContent) |
152 | |
{ |
153 | 0 | this(consumeXmlDocType, |
154 | |
consumeXmlDeclaration, |
155 | |
consumeProcessingInstructions, |
156 | |
consumeCDataSections, |
157 | |
escapeInlineText, |
158 | |
consumeXMLComments, |
159 | |
swallowCDataContent, |
160 | |
false); |
161 | 0 | } |
162 | |
|
163 | |
public FaceletsProcessingInstructions( |
164 | |
boolean consumeXmlDocType, |
165 | |
boolean consumeXmlDeclaration, |
166 | |
boolean consumeProcessingInstructions, |
167 | |
boolean consumeCDataSections, |
168 | |
boolean escapeInlineText, |
169 | |
boolean consumeXMLComments, |
170 | |
boolean swallowCDataContent, |
171 | |
boolean compressSpaces) |
172 | |
{ |
173 | 0 | this(consumeXmlDocType, |
174 | |
consumeXmlDeclaration, |
175 | |
consumeProcessingInstructions, |
176 | |
consumeCDataSections, |
177 | |
escapeInlineText, |
178 | |
consumeXMLComments, |
179 | |
swallowCDataContent, |
180 | |
compressSpaces, |
181 | |
false); |
182 | 0 | } |
183 | |
|
184 | |
public FaceletsProcessingInstructions( |
185 | |
boolean consumeXmlDocType, |
186 | |
boolean consumeXmlDeclaration, |
187 | |
boolean consumeProcessingInstructions, |
188 | |
boolean consumeCDataSections, |
189 | |
boolean escapeInlineText, |
190 | |
boolean consumeXMLComments, |
191 | |
boolean swallowCDataContent, |
192 | |
boolean compressSpaces, |
193 | |
boolean html5Doctype) |
194 | |
{ |
195 | 0 | super(); |
196 | 0 | this.consumeXmlDocType = consumeXmlDocType; |
197 | 0 | this.consumeXmlDeclaration = consumeXmlDeclaration; |
198 | 0 | this.consumeProcessingInstructions = consumeProcessingInstructions; |
199 | 0 | this.consumeCDataSections = consumeCDataSections; |
200 | 0 | this.escapeInlineText = escapeInlineText; |
201 | 0 | this.consumeXMLComments = consumeXMLComments; |
202 | 0 | this.swallowCDataContent = swallowCDataContent; |
203 | 0 | this.compressSpaces = compressSpaces; |
204 | 0 | this.html5Doctype = html5Doctype; |
205 | 0 | } |
206 | |
|
207 | |
public boolean isConsumeXmlDocType() |
208 | |
{ |
209 | 0 | return consumeXmlDocType; |
210 | |
} |
211 | |
|
212 | |
public boolean isConsumeXmlDeclaration() |
213 | |
{ |
214 | 0 | return consumeXmlDeclaration; |
215 | |
} |
216 | |
|
217 | |
public boolean isConsumeProcessingInstructions() |
218 | |
{ |
219 | 0 | return consumeProcessingInstructions; |
220 | |
} |
221 | |
|
222 | |
public boolean isConsumeCDataSections() |
223 | |
{ |
224 | 0 | return consumeCDataSections; |
225 | |
} |
226 | |
|
227 | |
public boolean isEscapeInlineText() |
228 | |
{ |
229 | 0 | return escapeInlineText; |
230 | |
} |
231 | |
|
232 | |
public boolean isConsumeXMLComments() |
233 | |
{ |
234 | 0 | return consumeXMLComments; |
235 | |
} |
236 | |
|
237 | |
public boolean isSwallowCDataContent() |
238 | |
{ |
239 | 0 | return swallowCDataContent; |
240 | |
} |
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
public boolean isCompressSpaces() |
246 | |
{ |
247 | 0 | return compressSpaces; |
248 | |
} |
249 | |
|
250 | |
public boolean isHtml5Doctype() |
251 | |
{ |
252 | 0 | return html5Doctype; |
253 | |
} |
254 | |
} |