|
static String | toWiki (String text) |
|
static void | processMacros (IConstructor constructor, PrintWriter out, String text) throws ServletException, IOException |
|
static String | processMacroString (IConstructor constructor, String macro) throws ServletException, IOException |
|
static void | processMacro (IConstructor constructor, PrintWriter out, String macro) throws ServletException, IOException |
|
static String | escapeGrouping (String sequence) |
|
static void | executeExternalParsers (IConstructor constructor, PrintWriter out, String[] tokens) |
|
- Author
- Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g
Definition at line 45 of file Parser.java.
◆ Parser() [1/2]
org.turro.elephant.impl.util.Parser.Parser |
( |
String |
text | ) |
|
◆ Parser() [2/2]
org.turro.elephant.impl.util.Parser.Parser |
( |
String |
text, |
|
|
String |
end |
|
) |
| |
Creates a new instance of Parser
- Parameters
-
Definition at line 60 of file Parser.java.
63 p = text.indexOf(end);
66 buffer =
new StringBuffer(text.substring(0, p));
69 buffer =
new StringBuffer(text);
72 if(text.startsWith(
"$wiki\n * ") || text.startsWith(
"$wiki\n 1 ")) {
73 buffer.insert(6,
"\n");
◆ escapeGrouping()
static String org.turro.elephant.impl.util.Parser.escapeGrouping |
( |
String |
sequence | ) |
|
|
static |
Definition at line 241 of file Parser.java.
242 if(sequence ==
null || !sequence.contains(
"$"))
return sequence;
243 StringBuilder sb =
new StringBuilder(sequence);
245 while((p = sb.indexOf(
"$", start)) > -1) {
249 return sb.toString();
◆ executeExternalParsers()
static void org.turro.elephant.impl.util.Parser.executeExternalParsers |
( |
IConstructor |
constructor, |
|
|
PrintWriter |
out, |
|
|
String[] |
tokens |
|
) |
| |
|
static |
Definition at line 254 of file Parser.java.
255 for(IParser iParser : Instances.cached().byAnnotation(ExternalParser.class, IParser.class)) {
256 if(iParser.execute(constructor, out, tokens)) {
◆ parse() [1/2]
String org.turro.elephant.impl.util.Parser.parse |
( |
| ) |
|
◆ parse() [2/2]
String org.turro.elephant.impl.util.Parser.parse |
( |
IConstructor |
constructor | ) |
|
Definition at line 90 of file Parser.java.
91 this.constructor = constructor;
92 WikiDef wikiDef =
new WikiDef();
93 if(resolver !=
null) wikiDef.addResolver(resolver);
94 wikiDef.addResolver(
this);
95 return wikiDef.parseBuffer(buffer);
◆ parseMacros()
String org.turro.elephant.impl.util.Parser.parseMacros |
( |
String |
line | ) |
|
Definition at line 132 of file Parser.java.
133 if(constructor ==
null || line.indexOf(
"macro") == -1)
return line;
134 Pattern pat = Pattern.compile(
"macro ?\\((.*?)\\)");
135 Matcher mat = pat.matcher(line);
136 StringBuffer result =
new StringBuffer();
139 tmp = I_.get(mat.group(1));
140 if(tmp ==
null) tmp = mat.group(1);
141 mat.appendReplacement(result, tmp);
143 mat.appendTail(result);
144 return result.toString();
◆ parseThumb()
String org.turro.elephant.impl.util.Parser.parseThumb |
( |
String |
line | ) |
|
Definition at line 103 of file Parser.java.
104 if(constructor ==
null || line.indexOf(
"[thumb") == -1)
return line;
105 Pattern pat = Pattern.compile(
"\\[thumb (.+?)\\:([0-9]+?)(\\:[RL])?\\]");
106 Matcher mat = pat.matcher(line);
107 StringBuffer result =
new StringBuffer();
111 dim = Integer.parseInt(mat.group(2));
112 }
catch(Exception ex) {}
113 mat.appendReplacement(
115 "<a target=\"_blank\" href=\"" + mat.group(1) +
"\">" +
116 "<img border=\"0\" src=\"" +
118 new Thumbs(constructor.
getRequest()).getThumb(
128 mat.appendTail(result);
129 return result.toString();
static String escapeGrouping(String sequence)
HttpServletRequest getRequest()
◆ processMacro()
static void org.turro.elephant.impl.util.Parser.processMacro |
( |
IConstructor |
constructor, |
|
|
PrintWriter |
out, |
|
|
String |
macro |
|
) |
| throws ServletException, IOException |
|
static |
Definition at line 236 of file Parser.java.
237 String tokens[] = macro.split(
"(?<!\\/)(\\:)");
static void executeExternalParsers(IConstructor constructor, PrintWriter out, String[] tokens)
◆ processMacros()
static void org.turro.elephant.impl.util.Parser.processMacros |
( |
IConstructor |
constructor, |
|
|
PrintWriter |
out, |
|
|
String |
text |
|
) |
| throws ServletException, IOException |
|
static |
Definition at line 200 of file Parser.java.
201 text = MacroProcessors.full().constructor(constructor).process(text);
202 if(text.indexOf(
"{@") > -1) {
203 text = processNestedMacros(constructor, text);
206 while((p = text.indexOf(
"{@")) > -1) {
207 e = text.indexOf(
'}', p + 2);
209 tmp = text.substring(p + 2, e);
210 out.write(text.substring(0, p));
211 Parser.processMacro(constructor, out, tmp);
212 text = text.substring(e + 1);
◆ processMacroString()
static String org.turro.elephant.impl.util.Parser.processMacroString |
( |
IConstructor |
constructor, |
|
|
String |
macro |
|
) |
| throws ServletException, IOException |
|
static |
Definition at line 229 of file Parser.java.
230 StringWriter sw =
new StringWriter();
231 PrintWriter pw =
new PrintWriter(sw);
233 return sw.toString();
static void processMacro(IConstructor constructor, PrintWriter out, String macro)
◆ resolve()
String org.turro.elephant.impl.util.Parser.resolve |
( |
String |
text | ) |
|
Definition at line 148 of file Parser.java.
149 if(!constructor.
isInRole(
"inc:new")) {
150 text = text.replaceAll(
"\\{\\@inc",
"{@---");
152 text = text.replaceAll(
153 "grepository ?\\((.*?)\\)",
154 ElephantContext.getRootResourcePath() +
155 "/_internal/repository$1"
158 text = text.replaceAll(
159 "repository ?\\((.*?)\\)",
160 ElephantContext.getRootResourcePath() +
162 "/_internal/repository$1"
165 text = text.replaceAll(
166 "pubimage ?\\((.*?)\\)",
167 ElephantContext.getRootResourcePath() +
168 "/_internal/UserFiles/Image$1"
170 text = text.replaceAll(
171 "pubflash ?\\((.*?)\\)",
172 ElephantContext.getRootResourcePath() +
173 "/_internal/UserFiles/Flash$1"
175 text = text.replaceAll(
176 "download ?\\((.*?)\\)",
177 ElephantContext.getRootWebPath() +
"/Download?down_path=$1"
179 text = text.replaceAll(
"<verbatim>",
"<pre>");
180 text = text.replaceAll(
"</verbatim>",
"</pre>");
183 text = text.replaceAll(
"\\[\\[(.*?)\\]\\[(.*?)\\]\\]",
"<a href='$1'>$2</a>");
184 text = text.replaceAll(
"\\[new\\[(.*?)\\]\\[(.*?)\\]\\]",
"<a class='newwindow' target='_blank' href='$1'>$2</a>");
185 text = text.replaceAll(
"\\[ext\\[(.*?)\\]\\[(.*?)\\]\\]",
"<a class='externallink' target='_blank' href='$1'>$2</a>");
186 text = text.replaceAll(
"\\[\\[(.*?)\\]\\]",
"<a href='$1'>$1</a>");
187 text = text.replaceAll(
"\\[\\[(.*?)\\](.*?)\\]",
"<a href='$1'>$2</a>");
188 text = text.replaceAll(
"\\[new\\[(.*?)\\](.*?)\\]",
"<a class='newwindow' target='_blank' href='$1'>$2</a>");
189 text = text.replaceAll(
"\\[new\\[(.*?)\\]\\]",
"<a class='newwindow' target='_blank' href='$1'>$1</a>");
190 text = text.replaceAll(
"\\[ext\\[(.*?)\\](.*?)\\]",
"<a class='externallink' target='_blank' href='$1'>$2</a>");
191 text = text.replaceAll(
"\\[ext\\[(.*?)\\]\\]",
"<a class='externallink' target='_blank' href='$1'>$1</a>");
192 text = text.replaceAll(
"\\[color\\((.*?)\\) (.*?)\\]",
"<span style='color:$1'>$2</span>");
194 text = text.replaceAll(
"\\[frame ([^,]*?),([^,]*?),(.*?)\\]",
"<iframe src='$1' style='width:$2;height:$3;border:0px solid gray'></iframe>");
195 text = text.replaceAll(
"\\%BR\\%",
"<br/>\n");
196 text = Emoticons.replaceEmoticons(constructor, text);
String parseThumb(String line)
String getParameter(String param)
boolean isInRole(String role)
◆ setResolver()
void org.turro.elephant.impl.util.Parser.setResolver |
( |
ExternalResolver |
resolver | ) |
|
Definition at line 82 of file Parser.java.
83 this.resolver = resolver;
◆ simpleParse()
String org.turro.elephant.impl.util.Parser.simpleParse |
( |
| ) |
|
Definition at line 98 of file Parser.java.
99 WikiDef wikiDef =
new WikiDef();
100 return wikiDef.parseBuffer(buffer);
◆ toWiki()
static String org.turro.elephant.impl.util.Parser.toWiki |
( |
String |
text | ) |
|
|
static |
Definition at line 77 of file Parser.java.
78 text = Jsoup.clean(text, HtmlWhitelist.wikiSafe());
79 return new HtmlParser(text).parse();
The documentation for this class was generated from the following file: