Package org.basex.http.web
Class WebFunction
- java.lang.Object
-
- org.basex.http.web.WebFunction
-
- All Implemented Interfaces:
Comparable<WebFunction>
- Direct Known Subclasses:
RestXqFunction,WsFunction
public abstract class WebFunction extends Object implements Comparable<WebFunction>
This abstract class defines common methods of Web functions.- Author:
- BaseX Team 2005-23, BSD License, Johannes Finckh
-
-
Field Summary
Fields Modifier and Type Field Description StaticFuncfunctionUser-defined function.ArrayList<WebParam>headerParamsHeader Parameters.WebModulemoduleWeb module.SerializerOptionssoptsSerialization parameters.
-
Constructor Summary
Constructors Modifier Constructor Description protectedWebFunction(StaticFunc function, WebModule module, QueryContext qc)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidbind(QNm name, Expr[] args, Value value, QueryContext qc, String info)Binds a value to a function argument.protected booleancheckParsed(boolean found, AnnList list, boolean[] declared)Checks parsed meta data.protected QNmcheckVariable(String tmp, boolean... declared)Checks the specified template and adds a variable.protected QNmcheckVariable(QNm name, boolean[] declared)Checks if the specified variable exists in the current function.protected abstract QueryExceptionerror(String msg, Object... ext)Creates an exception with the specified message.abstract booleanparseAnnotations(Context ctx)Checks a function for REST and permission annotations.StringtoString()protected static StringtoString(Item item)Returns the specified item as a string.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Field Detail
-
function
public final StaticFunc function
User-defined function.
-
module
public final WebModule module
Web module. Only required if used as function template
-
sopts
public final SerializerOptions sopts
Serialization parameters.
-
-
Constructor Detail
-
WebFunction
protected WebFunction(StaticFunc function, WebModule module, QueryContext qc)
Constructor.- Parameters:
function- user-defined functionqc- query contextmodule- web module
-
-
Method Detail
-
parseAnnotations
public abstract boolean parseAnnotations(Context ctx) throws QueryException, IOException
Checks a function for REST and permission annotations. This function is called both when a module is parsed, and when the function is prepared for evaluation.- Parameters:
ctx- database context- Returns:
trueif function contains relevant annotations- Throws:
QueryException- query exceptionIOException- I/O exception
-
error
protected abstract QueryException error(String msg, Object... ext)
Creates an exception with the specified message.- Parameters:
msg- messageext- error extension- Returns:
- exception
-
checkVariable
protected final QNm checkVariable(String tmp, boolean... declared) throws QueryException
Checks the specified template and adds a variable.- Parameters:
tmp- template stringdeclared- variable declaration flags- Returns:
- resulting variable
- Throws:
QueryException- query exception
-
checkParsed
protected final boolean checkParsed(boolean found, AnnList list, boolean[] declared) throws QueryExceptionChecks parsed meta data.- Parameters:
found- found flaglist- list of annotationsdeclared- declared parameters- Returns:
- found flag
- Throws:
QueryException- query exception
-
checkVariable
protected final QNm checkVariable(QNm name, boolean[] declared) throws QueryException
Checks if the specified variable exists in the current function.- Parameters:
name- variabledeclared- variable declaration flags- Returns:
- resulting variable
- Throws:
QueryException- query exception
-
bind
protected final void bind(QNm name, Expr[] args, Value value, QueryContext qc, String info) throws QueryException
Binds a value to a function argument.- Parameters:
name- variable nameargs- argumentsvalue- value to be boundqc- query contextinfo- info string- Throws:
QueryException- query exception
-
toString
protected static String toString(Item item)
Returns the specified item as a string.- Parameters:
item- item- Returns:
- string
-
-