public class JavaExtensionLibrary extends Object implements FunctionLibrary
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,
Class required)
Get the conversion preference from an XPath primitive atomic type to a Java class
|
Expression |
bind(SymbolicName symbolicName,
Expression[] staticArgs,
StaticContext env,
Container container)
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(String uri,
Class theClass)
Declare a mapping from a specific namespace URI to a Java class
|
JavaExtensionFunctionFactory |
getExtensionFunctionFactory()
Get the ExtensionFunctionFactory used by this extension library.
|
protected Class |
getExternalJavaClass(String uri,
String localName,
boolean debug)
Get an external Java class corresponding to a given namespace URI, if there is
one.
|
FunctionItem |
getFunctionItem(SymbolicName functionName,
StaticContext staticContext,
Container container)
Test whether a function with a given name and arity is available; if so, return a function
item that can be dynamically called.
|
protected String |
getMethodNameFromLocalName(String uri,
String localName,
boolean debug)
Get the Java method/field name from the local name used in the function call.
|
boolean |
isAvailable(SymbolicName 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(String uri, Class theClass)
uri
- the namespace URI of the function nametheClass
- the Java class that implements the functions in this namespacepublic FunctionItem getFunctionItem(SymbolicName functionName, StaticContext staticContext, Container container) 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 contextcontainer
- XPathException
- in the event of certain errors, for example attempting to get a function
that is privatepublic boolean isAvailable(SymbolicName 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 symbolicName, Expression[] staticArgs, StaticContext env, Container container) 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 contextcontainer
- XPathException
- 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, 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 Class getExternalJavaClass(String uri, 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 String getMethodNameFromLocalName(String uri, 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-2014 Saxonica Limited. All rights reserved.