Package com.saxonica.ee.bytecode.util
Class Callback
- java.lang.Object
-
- com.saxonica.ee.bytecode.util.Callback
-
public class Callback extends java.lang.Object
A convenient place to put static methods that will be called from generated byte code
-
-
Constructor Summary
Constructors Constructor Description Callback()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
booleanFromString(UnicodeString s)
Convert a string to a boolean value, using the XML Schema rules (including whitespace trimming)static long
doubleToIntegerOrError(double value)
Convert a double to a integer number, throwing an exception if value is equal to NaN or infinitystatic XPathException
makeJavaInvocationException(java.lang.Exception err, JavaExtensionFunctionCall call)
Construct (but do not throw) an exception wrapping an exception thrown by a Java extension functionstatic java.lang.String
makeMessageFromTemplate(java.lang.String messageTemplate, java.lang.Object param0)
Expand a message template containing one variable stringstatic XPathException
makeMultipleItemsException(CardinalityChecker expression, XPathContext context)
Construct an exception reporting that a sequence of more than item was found where a single item was expectedstatic XPathException
makeNonComparableException(AtomicValue av0, AtomicValue av1, java.lang.String systemId, int lineNumber)
Construct (but don't throw) an exception reporting that two atomic values are not comparablestatic XPathException
makeXmlNamespaceException(java.lang.String prefix, java.lang.String namespace, boolean isXSLT, java.lang.String systemId, int lineNumber)
Construct (but do not throw) an exception reporting that the namespace prefix "xml" and the XML namespace URI can only be used as a pairstatic XPathException
makeXPathException(java.lang.String message, java.lang.String errorCode, java.lang.String systemId, int lineNumber, boolean isTypeError)
Construct (but do not throw) an XPath exception.static StructuredQName
sqNameFromValidatedEQName(java.lang.String eqName, java.lang.String errorCode)
static double
stringToNumberOrNaN(StringToDouble s2d, UnicodeString str)
Convert a string to a double number, returning NaN if the string is not numeric
-
-
-
Method Detail
-
makeMessageFromTemplate
public static java.lang.String makeMessageFromTemplate(java.lang.String messageTemplate, java.lang.Object param0)
Expand a message template containing one variable string- Parameters:
messageTemplate
- the message template in which a placeholder for the inserted string is indicated by the characters "{$1}"param0
- the variable string to be inserted into the message- Returns:
- the expanded message
-
makeNonComparableException
public static XPathException makeNonComparableException(AtomicValue av0, AtomicValue av1, java.lang.String systemId, int lineNumber)
Construct (but don't throw) an exception reporting that two atomic values are not comparable- Parameters:
av0
- the first atomic valueav1
- the second atomic valuesystemId
- the module containing the comparisonlineNumber
- the line number of the comparison within this module- Returns:
- the exception reporting the error
-
makeXmlNamespaceException
public static XPathException makeXmlNamespaceException(java.lang.String prefix, java.lang.String namespace, boolean isXSLT, java.lang.String systemId, int lineNumber)
Construct (but do not throw) an exception reporting that the namespace prefix "xml" and the XML namespace URI can only be used as a pair- Parameters:
prefix
- the prefix that was actually usednamespace
- the namespace URI that was actually usedisXSLT
- true if this is XSLT code, false if XQuery (affects the error code produced)systemId
- the module in which the error occurredlineNumber
- the line number where the error occurred- Returns:
- the exception reporting the error condition
-
makeJavaInvocationException
public static XPathException makeJavaInvocationException(java.lang.Exception err, JavaExtensionFunctionCall call)
Construct (but do not throw) an exception wrapping an exception thrown by a Java extension function- Parameters:
err
- the exception thrown by the called extension functioncall
- the extension function call in which the error occurred- Returns:
- the exception reporting the error condition
-
makeMultipleItemsException
public static XPathException makeMultipleItemsException(CardinalityChecker expression, XPathContext context)
Construct an exception reporting that a sequence of more than item was found where a single item was expected- Parameters:
expression
- the cardinality checker that detects the error. This is re-evaluated to include the first few items of the sequence in the error messagecontext
- the dynamic context- Returns:
- the exception object that reports the error
-
makeXPathException
public static XPathException makeXPathException(java.lang.String message, java.lang.String errorCode, java.lang.String systemId, int lineNumber, boolean isTypeError)
Construct (but do not throw) an XPath exception.- Parameters:
message
- the error messageerrorCode
- the local part of the error codesystemId
- the URI of the module in which the error occurslineNumber
- the line within the module where the error occursisTypeError
- true if this is a type error- Returns:
- the XPath exception
-
stringToNumberOrNaN
public static double stringToNumberOrNaN(StringToDouble s2d, UnicodeString str)
Convert a string to a double number, returning NaN if the string is not numeric- Parameters:
s2d
- the string to double converter to be usedstr
- the string to be converted- Returns:
- the returned number
-
doubleToIntegerOrError
public static long doubleToIntegerOrError(double value) throws XPathException
Convert a double to a integer number, throwing an exception if value is equal to NaN or infinity- Parameters:
value
- - The double type that is required to convert- Returns:
- the returned integer number
- Throws:
XPathException
- if the supplied value is NaN or infinity
-
booleanFromString
public static int booleanFromString(UnicodeString s)
Convert a string to a boolean value, using the XML Schema rules (including whitespace trimming)- Parameters:
s
- the input string- Returns:
- the relevant BooleanValue if validation succeeds; or a ValidationFailure if not.
-
sqNameFromValidatedEQName
public static StructuredQName sqNameFromValidatedEQName(java.lang.String eqName, java.lang.String errorCode) throws XPathException
- Throws:
XPathException
-
-