|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cocoon.components.language.markup.xsp.XSPExpressionParser
public class XSPExpressionParser
Parse XSP expressions. Expressions are embedded in attribute="value" and text elements and are
expanded by the
PreProcessFilter
and have the form {#expression}. To prevent interpolation, use {##quote}, which results in the
text {#quote}.
An exception is thrown if the closing brace is missing.
The parser has a rudimentary understanding of expressions concerning nested braces and braces inside quoted strings and character constants. All valid Java, Javascript, and Python expressions can be used.
Example: <h1>Hello {#user.getName()}</h1> <img or src="image_{#image.getId()}"/>
Nested Class Summary | |
---|---|
static interface |
XSPExpressionParser.Handler
Handler interface for parsed expressions and text fragments. |
protected static class |
XSPExpressionParser.QuotedState
Parser state in a quoted string. |
protected static class |
XSPExpressionParser.State
Parser state. |
Field Summary | |
---|---|
protected static XSPExpressionParser.State |
EXPRESSION_CHAR_STATE
The parser has encountered '\'' in
to start a character constant. |
protected static XSPExpressionParser.State |
EXPRESSION_SHELL_STATE
The parser has encountered '`' (Backtick, ASCII 0x60) in to start a Python string constant. |
protected static XSPExpressionParser.State |
EXPRESSION_STATE
The parser is parsing an expression. |
protected static XSPExpressionParser.State |
EXPRESSION_STRING_STATE
The parser has encountered '"' in
to start a string constant. |
protected static XSPExpressionParser.State |
LBRACE_STATE
The parser has encountered '{' in . |
protected static XSPExpressionParser.State |
TEXT_HASH_STATE
The parser has encountered '#' in . |
protected static XSPExpressionParser.State |
TEXT_STATE
The parser is parsing text. |
Constructor Summary | |
---|---|
XSPExpressionParser(XSPExpressionParser.Handler handler)
Create a new . |
Method Summary | |
---|---|
protected void |
append(char ch)
|
void |
consume(char[] chars,
int start,
int length)
Parses part of a character array. |
void |
consume(String chars)
Parses a character sequence. |
protected int |
decrNesting()
|
void |
flush(Locator locator,
String description)
Flushes the parser |
protected String |
getExpression()
|
protected XSPExpressionParser.State |
getState()
|
protected void |
handleExpression()
|
protected void |
handleText()
|
protected void |
incrNesting()
|
protected void |
initExpression()
|
protected boolean |
isEscaped()
|
protected void |
setEscaped(boolean escaped)
|
protected void |
setState(XSPExpressionParser.State state)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final XSPExpressionParser.State TEXT_STATE
protected static final XSPExpressionParser.State LBRACE_STATE
TEXT_STATE
.
protected static final XSPExpressionParser.State TEXT_HASH_STATE
LBRACE_STATE
.
protected static final XSPExpressionParser.State EXPRESSION_STATE
protected static final XSPExpressionParser.State EXPRESSION_STRING_STATE
EXPRESSION_STATE
to start a string constant.
protected static final XSPExpressionParser.State EXPRESSION_CHAR_STATE
EXPRESSION_STATE
to start a character constant.
protected static final XSPExpressionParser.State EXPRESSION_SHELL_STATE
EXPRESSION_STATE
to start a Python string constant.
Constructor Detail |
---|
public XSPExpressionParser(XSPExpressionParser.Handler handler)
XSPExpressionParser
.
handler
- The handler for parsed text and expression fragments.Method Detail |
---|
public void consume(String chars) throws SAXException
chars
- The character sequence to parse
SAXException
- If there is an error in the sequence.public void consume(char[] chars, int start, int length) throws SAXException
chars
- The charactersstart
- The start position in the character arraylength
- The number of characters to parse
SAXException
- If there is an error in the sequence.public void flush(Locator locator, String description) throws SAXException
locator
- The SAX locator to determine the current parse positiondescription
- The description of the current parse context
SAXException
- If there is an error in the parsed text.
A wrapped LocatedException contains the location of the parse error.protected XSPExpressionParser.State getState()
protected void setState(XSPExpressionParser.State state)
protected void initExpression()
protected void incrNesting()
protected int decrNesting()
protected void setEscaped(boolean escaped)
protected boolean isEscaped()
protected String getExpression()
protected void handleText() throws SAXException
SAXException
protected void handleExpression() throws SAXException
SAXException
protected void append(char ch)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |