Compile a XSQL-Script function and catalog it in the map of available functions to be used from the program. Allows to:
- Patch a function already existing, so that overwrite a function which exist with the same name.
- Declarar una función para un caso concreto.
Notas
It is recommended to use the function.declare function because it allows the creation of the functionality in execution time without the need to have a file installed on the server with the content of the class.
1 function.loadExternalFunction
Compile a 'XSQL-Script' function and catalog it in the map of available functions to be used from the program.
<function.loadExternalFunction
name='name'
dir='dir'
/>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Aname | string | Name of the function | |||
Adir | string | Directory where the file is stored. |
Returns | |
---|---|
Type | Description |
Object | Returns type object or null if the process has finished successfully. |
Example
Compile and declare a new class to pass a given text to UpperCase. The class is as follows and is stored in $HOMEJAS\conf\functions\xsql_cust_uppercase:
Copy
import deister.webstudio.core.xsql.script.XSQLScriptRunner; import deister.webstudio.core.xsql.script.XSQLScriptFunction; import deister.webstudio.core.xsql.script.XSQLScriptException; // dom import org.w3c.dom.Element; public final class xsql_cust_sample extends XSQLScriptFunction { protected final static String[] ATTRIBUTES = null; @Override protected final boolean isTerminal() { return false; } @Override protected final String[] getAttributes() { return ATTRIBUTES; } @Override protected final Object process(XSQLScriptRunner program, Element el, int deep) throws XSQLScriptException { Object data = program.__get1EvaluatedArguments(el, deep); if (data == null) return null; String text = __object2String(program, el, data); return text.toUpperCase(); } }
And the XSQL-SCRIPT code is shown below.
Copy
<xsql-script name='function_loadExternalFunction'> <body> <function.loadExternalFunction dir='conf\functions' name='xsql_cust_uppercase' /> <set name='text'>my text is convert to uppercase</set> <println> The text converto to uppercase is = "<text/>"</multiply> </println> </body> </xsql-script>