Class XPathException
java.lang.Object
java.lang.Throwable
java.lang.Exception
org.libxmq.imp.xml.XPathException
- All Implemented Interfaces:
Serializable
Thrown when an xpath expression cannot be compiled or evaluated.
The error codes and messages are the same as the libxml2 xmlXPathError
codes, since the semantics of the xpath engine are ported from libxml2
xpath.c (Copyright (C) 1998-2012 Daniel Veillard, MIT license).
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intInvalid expression.static final intA variable reference where variables are not allowed.static final intInvalid number of arguments.static final intInvalid context position, ie position() used outside of a predicate.static final intInvalid context size, ie last() used outside of a predicate.static final intInvalid operand.static final intInvalid predicate.static final intInvalid type.static final intMemory error, used when a traversal would grow a node-set without limit.static final intNumber encoding error.static final intRecursion limit exceeded.static final intStart of literal expected.static final intMissing closing parenthesis/brace.static final intUndefined namespace prefix.static final intUndefined variable.static final intUnfinished literal.static final intUnregistered function.static final intExpected $ for variable reference. -
Constructor Summary
ConstructorsConstructorDescriptionXPathException(int code, String expr, int offset) Create an xpath exception. -
Method Summary
Modifier and TypeMethodDescriptionintThe offset of the error as a byte offset in the utf8 encoded expression, like the C version.intcode()Returns the libxml2 compatible error code.detail()The message with details (libxml2 xmlXPathErrFmt), eg "Unregistered function: f", or "".booleanTrue if the error happened while evaluating a compiled expression (libxml2 has no expression context for such errors).Returns the expression that failed.static StringmessageFor(int code) Returns the libxml2 message for an error code.intoffset()Returns the offset into the expression where the error was detected.booleanquiet()True if an extension function failed without a message (like setting ctxt->error in libxml2), nothing should be reported.The static libxml2 message of the code, eg "Invalid expression".Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
NUMBER_ERROR
public static final int NUMBER_ERRORNumber encoding error.- See Also:
-
UNFINISHED_LITERAL_ERROR
public static final int UNFINISHED_LITERAL_ERRORUnfinished literal.- See Also:
-
START_LITERAL_ERROR
public static final int START_LITERAL_ERRORStart of literal expected.- See Also:
-
VARIABLE_REF_ERROR
public static final int VARIABLE_REF_ERRORExpected $ for variable reference.- See Also:
-
UNDEF_VARIABLE_ERROR
public static final int UNDEF_VARIABLE_ERRORUndefined variable.- See Also:
-
INVALID_PREDICATE_ERROR
public static final int INVALID_PREDICATE_ERRORInvalid predicate.- See Also:
-
EXPR_ERROR
public static final int EXPR_ERRORInvalid expression.- See Also:
-
UNCLOSED_ERROR
public static final int UNCLOSED_ERRORMissing closing parenthesis/brace.- See Also:
-
UNKNOWN_FUNC_ERROR
public static final int UNKNOWN_FUNC_ERRORUnregistered function.- See Also:
-
INVALID_OPERAND
public static final int INVALID_OPERANDInvalid operand.- See Also:
-
INVALID_TYPE
public static final int INVALID_TYPEInvalid type.- See Also:
-
INVALID_ARITY
public static final int INVALID_ARITYInvalid number of arguments.- See Also:
-
INVALID_CTXT_SIZE
public static final int INVALID_CTXT_SIZEInvalid context size, ie last() used outside of a predicate.- See Also:
-
INVALID_CTXT_POSITION
public static final int INVALID_CTXT_POSITIONInvalid context position, ie position() used outside of a predicate.- See Also:
-
MEMORY_ERROR
public static final int MEMORY_ERRORMemory error, used when a traversal would grow a node-set without limit.- See Also:
-
UNDEF_PREFIX_ERROR
public static final int UNDEF_PREFIX_ERRORUndefined namespace prefix.- See Also:
-
FORBID_VARIABLE_ERROR
public static final int FORBID_VARIABLE_ERRORA variable reference where variables are not allowed.- See Also:
-
RECURSION_LIMIT_EXCEEDED
public static final int RECURSION_LIMIT_EXCEEDEDRecursion limit exceeded.- See Also:
-
-
Constructor Details
-
XPathException
Create an xpath exception.- Parameters:
code- The libxml2 compatible error code, egEXPR_ERROR.expr- The expression that failed, or null.offset- The offset in the expression where the error was detected, or -1.
-
-
Method Details
-
detail
The message with details (libxml2 xmlXPathErrFmt), eg "Unregistered function: f", or "".- Returns:
- The detailed message or "".
-
evaluating
public boolean evaluating()True if the error happened while evaluating a compiled expression (libxml2 has no expression context for such errors).- Returns:
- True when evaluating.
-
quiet
public boolean quiet()True if an extension function failed without a message (like setting ctxt->error in libxml2), nothing should be reported.- Returns:
- True if quiet.
-
byteOffset
public int byteOffset()The offset of the error as a byte offset in the utf8 encoded expression, like the C version.- Returns:
- The byte offset, or -1.
-
staticMessage
The static libxml2 message of the code, eg "Invalid expression".- Returns:
- The message.
-
code
public int code()Returns the libxml2 compatible error code.- Returns:
- The error code.
-
expression
-
offset
public int offset()Returns the offset into the expression where the error was detected.- Returns:
- The offset or -1 if unknown.
-
messageFor
Returns the libxml2 message for an error code.- Parameters:
code- The error code.- Returns:
- The message, eg "Invalid expression".
-