/** * Create a new XPathSyntaxException wrapping an existing * <code>org.jaxen.saxpath.XPathSyntaxException</code>. * * @param e the exception that caused this exception */ public XPathSyntaxException(org.jaxen.saxpath.XPathSyntaxException e) { super( e ); this.xpath = e.getXPath(); this.position = e.getPosition(); }
/** * Create a new SAXPathException with the specified detail message * and root cause. * * @param message the detail message * @param cause the cause of this exception */ public SAXPathException(String message, Throwable cause) { super( message ); initCause(cause); }
void predicate() throws SAXPathException { getXPathHandler().startPredicate(); match( TokenTypes.LEFT_BRACKET ); predicateExpr(); match( TokenTypes.RIGHT_BRACKET ); getXPathHandler().endPredicate(); }
public void parse(String xpath) throws SAXPathException { setUpParse( xpath ); getXPathHandler().startXPath(); expr(); getXPathHandler().endXPath(); if ( LA(1) != TokenTypes.EOF ) { XPathSyntaxException ex = createSyntaxException( "Unexpected '" + LT(1).getTokenText() + "'" ); throw ex; } lexer = null; tokens = null; }
private void relativeLocationPath() throws SAXPathException { getXPathHandler().startRelativeLocationPath(); switch ( LA(1) ) { case TokenTypes.SLASH: { match( TokenTypes.SLASH ); break; } case TokenTypes.DOUBLE_SLASH: { getXPathHandler().startAllNodeStep( Axis.DESCENDANT_OR_SELF ); getXPathHandler().endAllNodeStep(); match( TokenTypes.DOUBLE_SLASH ); break; } } steps(); getXPathHandler().endRelativeLocationPath(); }
private void orExpr() throws SAXPathException { getXPathHandler().startOrExpr(); andExpr(); boolean create = false; switch ( LA(1) ) { case TokenTypes.OR: { create = true; match( TokenTypes.OR ); orExpr(); break; } } getXPathHandler().endOrExpr( create ); }
private void andExpr() throws SAXPathException { getXPathHandler().startAndExpr(); equalityExpr(); boolean create = false; switch ( LA(1) ) { case TokenTypes.AND: { create = true; match( TokenTypes.AND ); andExpr(); break; } } getXPathHandler().endAndExpr( create ); }
private void unionExpr() throws SAXPathException { getXPathHandler().startUnionExpr(); pathExpr(); boolean create = false; switch ( LA(1) ) { case TokenTypes.PIPE: { match( TokenTypes.PIPE ); create = true; expr(); break; } } getXPathHandler().endUnionExpr( create ); }
private void unaryExpr() throws SAXPathException { switch ( LA(1) ) { case TokenTypes.MINUS: { getXPathHandler().startUnaryExpr(); match( TokenTypes.MINUS ); unaryExpr(); getXPathHandler().endUnaryExpr( Operator.NEGATIVE ); break; } default: { unionExpr(); break; } } }
private void abbrStep() throws SAXPathException { switch ( LA(1) ) { case TokenTypes.DOT: { match( TokenTypes.DOT ); getXPathHandler().startAllNodeStep( Axis.SELF ); predicates(); getXPathHandler().endAllNodeStep(); break; } case TokenTypes.DOT_DOT: { match( TokenTypes.DOT_DOT ); getXPathHandler().startAllNodeStep( Axis.PARENT ); predicates(); getXPathHandler().endAllNodeStep(); break; } } }
private void throwInvalidAxis(String invalidAxis) throws SAXPathException { String xpath = this.lexer.getXPath(); int position = LT(1).getTokenBegin(); String message = "Expected valid axis name instead of [" + invalidAxis + "]"; throw new XPathSyntaxException( xpath, position, message ); } }
private void literal() throws SAXPathException { Token token = match( TokenTypes.LITERAL ); getXPathHandler().literal( token.getTokenText() ); }
public String toString() { return getClass() + ": " + getXPath() + ": " + getPosition() + ": " + getMessage(); }
/** * <p> * Returns a long formatted description of the error, * including line breaks. * </p> * * @return a longer description of the error on multiple lines */ public String getMultilineMessage() { StringBuffer buf = new StringBuffer(); buf.append( getMessage() ); buf.append( lineSeparator ); buf.append( getXPath() ); buf.append( lineSeparator ); buf.append( getPositionMarker() ); return buf.toString(); }
public String getAxisName() { return Axis.lookup(getAxis()); }
/** Print this exception's stack trace, followed by the * source exception's stack trace, if any. * * @param s the writer on which to print the stack trace */ public void printStackTrace ( PrintWriter s ) { super.printStackTrace( s ); if (javaVersion < 1.4 && getCause() != null) { s.print( "Caused by: " ); getCause().printStackTrace( s ); } }
/** * <p> * Returns a string in the form <code>" ^"</code> which, when placed on the line * below the XPath expression in a monospaced font, should point to the * location of the error. * </p> * * @return the position marker */ private String getPositionMarker() { int pos = getPosition(); StringBuffer buf = new StringBuffer(pos+1); for ( int i = 0 ; i < pos ; ++i ) { buf.append(" "); } buf.append("^"); return buf.toString(); }
private XPathSyntaxException createSyntaxException(String message) { String xpath = this.lexer.getXPath(); int position = LT(1).getTokenBegin(); return new XPathSyntaxException( xpath, position, message ); }
/** Create a new SAXPathException based on another exception * * @param cause the error source */ public SAXPathException(Throwable cause) { super ( cause.getMessage() ); initCause(cause); }
/** Print this exception's stack trace, followed by the * source exception's trace, if any. * * @param s the stream on which to print the stack trace */ public void printStackTrace ( PrintStream s ) { super.printStackTrace ( s ); if (javaVersion < 1.4 && getCause() != null) { s.print( "Caused by: " ); getCause().printStackTrace( s ); } }