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 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_HTML5 =
34 new FaceletsProcessingInstructions(
35 false, false, false, false, true, false, true, false, true);
36
37 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_XHTML =
38 new FaceletsProcessingInstructions(
39 false, false, false, false, true, false, true);
40
41 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_XML =
42 new FaceletsProcessingInstructions(
43 true, true, true, true, true, true, true);
44
45 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_JSPX =
46 new FaceletsProcessingInstructions(
47 true, true, true, true, false, true, false);
48
49 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_HTML5_COMPRESS_SPACES =
50 new FaceletsProcessingInstructions(
51 false, false, false, false, true, false, true, true, true);
52
53 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_XHTML_COMPRESS_SPACES =
54 new FaceletsProcessingInstructions(
55 false, false, false, false, true, false, true, true);
56
57 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_XML_COMPRESS_SPACES =
58 new FaceletsProcessingInstructions(
59 true, true, true, true, true, true, true, true);
60
61 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 if (processAs == null)
86 {
87 return FACELETS_PROCESSING_HTML5;
88 }
89 else if (PROCESS_AS_HTML5.equals(processAs))
90 {
91 return FACELETS_PROCESSING_HTML5;
92 }
93 else if (PROCESS_AS_XHTML.equals(processAs))
94 {
95 return FACELETS_PROCESSING_XHTML;
96 }
97 else if (PROCESS_AS_XML.equals(processAs))
98 {
99 return FACELETS_PROCESSING_XML;
100 }
101 else if (PROCESS_AS_JSPX.equals(processAs))
102 {
103 return FACELETS_PROCESSING_JSPX;
104 }
105 else
106 {
107 return FACELETS_PROCESSING_XHTML;
108 }
109 }
110
111 public static FaceletsProcessingInstructions getProcessingInstructions(
112 String processAs, boolean compressSpaces)
113 {
114 if (!compressSpaces)
115 {
116 return getProcessingInstructions(processAs);
117 }
118 if (processAs == null)
119 {
120 return FACELETS_PROCESSING_HTML5_COMPRESS_SPACES;
121 }
122 else if (PROCESS_AS_HTML5.equals(processAs))
123 {
124 return FACELETS_PROCESSING_HTML5_COMPRESS_SPACES;
125 }
126 else if (PROCESS_AS_XHTML.equals(processAs))
127 {
128 return FACELETS_PROCESSING_XHTML_COMPRESS_SPACES;
129 }
130 else if (PROCESS_AS_XML.equals(processAs))
131 {
132 return FACELETS_PROCESSING_XML_COMPRESS_SPACES;
133 }
134 else if (PROCESS_AS_JSPX.equals(processAs))
135 {
136 return FACELETS_PROCESSING_JSPX_COMPRESS_SPACES;
137 }
138 else
139 {
140 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 this(consumeXmlDocType,
154 consumeXmlDeclaration,
155 consumeProcessingInstructions,
156 consumeCDataSections,
157 escapeInlineText,
158 consumeXMLComments,
159 swallowCDataContent,
160 false);
161 }
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 this(consumeXmlDocType,
174 consumeXmlDeclaration,
175 consumeProcessingInstructions,
176 consumeCDataSections,
177 escapeInlineText,
178 consumeXMLComments,
179 swallowCDataContent,
180 compressSpaces,
181 false);
182 }
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 super();
196 this.consumeXmlDocType = consumeXmlDocType;
197 this.consumeXmlDeclaration = consumeXmlDeclaration;
198 this.consumeProcessingInstructions = consumeProcessingInstructions;
199 this.consumeCDataSections = consumeCDataSections;
200 this.escapeInlineText = escapeInlineText;
201 this.consumeXMLComments = consumeXMLComments;
202 this.swallowCDataContent = swallowCDataContent;
203 this.compressSpaces = compressSpaces;
204 this.html5Doctype = html5Doctype;
205 }
206
207 public boolean isConsumeXmlDocType()
208 {
209 return consumeXmlDocType;
210 }
211
212 public boolean isConsumeXmlDeclaration()
213 {
214 return consumeXmlDeclaration;
215 }
216
217 public boolean isConsumeProcessingInstructions()
218 {
219 return consumeProcessingInstructions;
220 }
221
222 public boolean isConsumeCDataSections()
223 {
224 return consumeCDataSections;
225 }
226
227 public boolean isEscapeInlineText()
228 {
229 return escapeInlineText;
230 }
231
232 public boolean isConsumeXMLComments()
233 {
234 return consumeXMLComments;
235 }
236
237 public boolean isSwallowCDataContent()
238 {
239 return swallowCDataContent;
240 }
241
242
243
244
245 public boolean isCompressSpaces()
246 {
247 return compressSpaces;
248 }
249
250 public boolean isHtml5Doctype()
251 {
252 return html5Doctype;
253 }
254 }