public class JavaExtensionLibrary extends java.lang.Object implements FunctionLibrary
Modifier and Type | Class and Description |
---|---|
class |
JavaExtensionLibrary.UnresolvedExtensionFunctionCall
Inner class representing an unresolved extension function call.
|
Constructor and Description |
---|
JavaExtensionLibrary(ProfessionalConfiguration config)
Construct a JavaExtensionLibrary and establish the default uri->class mappings.
|
Modifier and Type | Method and Description |
---|---|
protected int |
atomicConversionPreference(int primitiveType,
java.lang.Class required)
Get the conversion preference from an XPath primitive atomic type to a Java class
|
Expression |
bind(SymbolicName.F symbolicName,
Expression[] staticArgs,
StaticContext env)
Bind an extension function, given the URI and local parts of the function name,
and the list of expressions supplied as arguments.
|
FunctionLibrary |
copy()
This method creates a copy of a FunctionLibrary: if the original FunctionLibrary allows
new functions to be added, then additions to this copy will not affect the original, or
vice versa.
|
void |
declareJavaClass(java.lang.String uri,
java.lang.Class theClass)
Declare a mapping from a specific namespace URI to a Java class
|
void |
declareJavaClass(java.lang.String uri,
java.lang.String className)
Declare a mapping from a specific namespace URI to a Java class.
|
JavaExtensionFunctionFactory |
getExtensionFunctionFactory()
Get the ExtensionFunctionFactory used by this extension library.
|
protected java.lang.Class |
getExternalJavaClass(java.lang.String uri,
java.lang.String localName,
boolean debug)
Get an external Java class corresponding to a given namespace URI, if there is
one.
|
Function |
getFunctionItem(SymbolicName.F functionName,
StaticContext staticContext)
Test whether a function with a given name and arity is available; if so, return a function
item that can be dynamically called.
|
protected java.lang.String |
getMethodNameFromLocalName(java.lang.String uri,
java.lang.String localName,
boolean debug)
Get the Java method/field name from the local name used in the function call.
|
boolean |
isAvailable(SymbolicName.F functionName)
Test whether a function with a given name and arity is available
|
boolean |
isStrictJavaUriFormat()
Ask whether only the strict "java:" URI format is to be recognized.
|
void |
setExtensionFunctionFactory(JavaExtensionFunctionFactory factory)
Set the ExtensionFunctionFactory to be used by this extension library.
|
void |
setStrictJavaUriFormat(boolean strict)
Say that only the strict "java:" URI format is to be recognized.
|
public JavaExtensionLibrary(ProfessionalConfiguration config)
config
- The Saxon configurationpublic void setExtensionFunctionFactory(JavaExtensionFunctionFactory factory)
factory
- This must be an instanceof JavaExtensionFunctionFactorypublic JavaExtensionFunctionFactory getExtensionFunctionFactory()
public boolean isStrictJavaUriFormat()
public void setStrictJavaUriFormat(boolean strict)
strict
- true if only the strict format is recognizedpublic void declareJavaClass(java.lang.String uri, java.lang.Class theClass)
uri
- the namespace URI of the function nametheClass
- the Java class that implements the functions in this namespacepublic void declareJavaClass(java.lang.String uri, java.lang.String className)
uri
- the namespace URI of the function nameclassName
- the name of the Java class that implements the functions in this namespacepublic Function getFunctionItem(SymbolicName.F functionName, StaticContext staticContext) throws XPathException
This supports the function-lookup() function in XPath 3.0.
getFunctionItem
in interface FunctionLibrary
functionName
- the qualified name of the function being calledstaticContext
- the static context to be used by the function, in the event that
it is a system function with dependencies on the static contextXPathException
- in the event of certain errors, for example attempting to get a function
that is privatepublic boolean isAvailable(SymbolicName.F functionName)
This supports the function-available() function in XSLT.
isAvailable
in interface FunctionLibrary
functionName
- the qualified name of the function being calledpublic Expression bind(SymbolicName.F symbolicName, Expression[] staticArgs, StaticContext env) throws XPathException
bind
in interface FunctionLibrary
symbolicName
- the qualified name and arity of the function being calledstaticArgs
- The expressions supplied statically in the function call. The intention is
that the static type of the arguments (obtainable via getItemType() and getCardinality()) may
be used as part of the binding algorithm.env
- the static contextXPathException
- if a function is found with the required name and arity, but
the implementation of the function cannot be loaded or used; or if an error occurs
while searching for the function.protected int atomicConversionPreference(int primitiveType, java.lang.Class required)
primitiveType
- integer code identifying the XPath primitive type, for example
StandardNames.XS_STRING
or StandardNames.XS_STRING
required
- The Java Class named in the method signatureStringValue
is 50, while
XPath String to String
is 51. The value -1 indicates that the conversion is not allowed.protected java.lang.Class getExternalJavaClass(java.lang.String uri, java.lang.String localName, boolean debug)
uri
- The namespace URI corresponding to the prefix used in the function call.localName
- The local name of the function, in case this contributes to determining the classdebug
- true if tracing information should be outputprotected java.lang.String getMethodNameFromLocalName(java.lang.String uri, java.lang.String localName, boolean debug)
uri
- the namespace URI used in the function calllocalName
- the local name used in the function calldebug
- true if tracing is requestedpublic FunctionLibrary copy()
copy
in interface FunctionLibrary
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.