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_JSPX = "jspx";
29 public static final String PROCESS_AS_XHTML = "xhtml";
30 public static final String PROCESS_AS_XML = "xml";
31
32 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_XHTML =
33 new FaceletsProcessingInstructions(
34 false, false, false, false, true, false, true);
35
36 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_XML =
37 new FaceletsProcessingInstructions(
38 true, true, true, true, true, true, true);
39
40 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_JSPX =
41 new FaceletsProcessingInstructions(
42 true, true, true, true, false, true, false);
43
44 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_XHTML_COMPRESS_SPACES =
45 new FaceletsProcessingInstructions(
46 false, false, false, false, true, false, true, true);
47
48 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_XML_COMPRESS_SPACES =
49 new FaceletsProcessingInstructions(
50 true, true, true, true, true, true, true, true);
51
52 private static final FaceletsProcessingInstructions FACELETS_PROCESSING_JSPX_COMPRESS_SPACES =
53 new FaceletsProcessingInstructions(
54 true, true, true, true, false, true, false, true);
55
56 private final boolean consumeXmlDocType;
57
58 private final boolean consumeXmlDeclaration;
59
60 private final boolean consumeProcessingInstructions;
61
62 private final boolean consumeCDataSections;
63
64 private final boolean escapeInlineText;
65
66 private final boolean consumeXMLComments;
67
68 private final boolean swallowCDataContent;
69
70 private final boolean compressSpaces;
71
72 public final static FaceletsProcessingInstructions getProcessingInstructions(String processAs)
73 {
74 if (processAs == null)
75 {
76 return FACELETS_PROCESSING_XHTML;
77 }
78 else if (PROCESS_AS_XHTML.equals(processAs))
79 {
80 return FACELETS_PROCESSING_XHTML;
81 }
82 else if (PROCESS_AS_XML.equals(processAs))
83 {
84 return FACELETS_PROCESSING_XML;
85 }
86 else if (PROCESS_AS_JSPX.equals(processAs))
87 {
88 return FACELETS_PROCESSING_JSPX;
89 }
90 else
91 {
92 return FACELETS_PROCESSING_XHTML;
93 }
94 }
95
96 public final static FaceletsProcessingInstructions getProcessingInstructions(
97 String processAs, boolean compressSpaces)
98 {
99 if (!compressSpaces)
100 {
101 return getProcessingInstructions(processAs);
102 }
103 if (processAs == null)
104 {
105 return FACELETS_PROCESSING_XHTML_COMPRESS_SPACES;
106 }
107 else if (PROCESS_AS_XHTML.equals(processAs))
108 {
109 return FACELETS_PROCESSING_XHTML_COMPRESS_SPACES;
110 }
111 else if (PROCESS_AS_XML.equals(processAs))
112 {
113 return FACELETS_PROCESSING_XML_COMPRESS_SPACES;
114 }
115 else if (PROCESS_AS_JSPX.equals(processAs))
116 {
117 return FACELETS_PROCESSING_JSPX_COMPRESS_SPACES;
118 }
119 else
120 {
121 return FACELETS_PROCESSING_XHTML_COMPRESS_SPACES;
122 }
123 }
124
125 public FaceletsProcessingInstructions(
126 boolean consumeXmlDocType,
127 boolean consumeXmlDeclaration,
128 boolean consumeProcessingInstructions,
129 boolean consumeCDataSections,
130 boolean escapeInlineText,
131 boolean consumeXMLComments,
132 boolean swallowCDataContent)
133 {
134 super();
135 this.consumeXmlDocType = consumeXmlDocType;
136 this.consumeXmlDeclaration = consumeXmlDeclaration;
137 this.consumeProcessingInstructions = consumeProcessingInstructions;
138 this.consumeCDataSections = consumeCDataSections;
139 this.escapeInlineText = escapeInlineText;
140 this.consumeXMLComments = consumeXMLComments;
141 this.swallowCDataContent = swallowCDataContent;
142 this.compressSpaces = false;
143 }
144
145
146 public FaceletsProcessingInstructions(
147 boolean consumeXmlDocType,
148 boolean consumeXmlDeclaration,
149 boolean consumeProcessingInstructions,
150 boolean consumeCDataSections,
151 boolean escapeInlineText,
152 boolean consumeXMLComments,
153 boolean swallowCDataContent,
154 boolean compressSpaces)
155 {
156 super();
157 this.consumeXmlDocType = consumeXmlDocType;
158 this.consumeXmlDeclaration = consumeXmlDeclaration;
159 this.consumeProcessingInstructions = consumeProcessingInstructions;
160 this.consumeCDataSections = consumeCDataSections;
161 this.escapeInlineText = escapeInlineText;
162 this.consumeXMLComments = consumeXMLComments;
163 this.swallowCDataContent = swallowCDataContent;
164 this.compressSpaces = compressSpaces;
165 }
166
167 public boolean isConsumeXmlDocType()
168 {
169 return consumeXmlDocType;
170 }
171
172 public boolean isConsumeXmlDeclaration()
173 {
174 return consumeXmlDeclaration;
175 }
176
177 public boolean isConsumeProcessingInstructions()
178 {
179 return consumeProcessingInstructions;
180 }
181
182 public boolean isConsumeCDataSections()
183 {
184 return consumeCDataSections;
185 }
186
187 public boolean isEscapeInlineText()
188 {
189 return escapeInlineText;
190 }
191
192 public boolean isConsumeXMLComments()
193 {
194 return consumeXMLComments;
195 }
196
197 public boolean isSwallowCDataContent()
198 {
199 return swallowCDataContent;
200 }
201
202
203
204
205 public boolean isCompressSpaces()
206 {
207 return compressSpaces;
208 }
209
210 }