Package org.basex.query.func
Class StandardFunc
java.lang.Object
org.basex.query.expr.ExprInfo
org.basex.query.expr.Expr
org.basex.query.expr.ParseExpr
org.basex.query.expr.Arr
org.basex.query.func.StandardFunc
- Direct Known Subclasses:
AdminDeleteLogs,AdminLogs,AdminSessions,AdminWriteLog,ArchiveCreate,ArchiveDelete,ArchiveEntries,ArchiveExtractBinary,ArchiveExtractTo,ArchiveOptions,ArrayAppend,ArrayFilter,ArrayFlatten,ArrayFoldLeft,ArrayFoldRight,ArrayForEach,ArrayForEachPair,ArrayGet,ArrayHead,ArrayInsertBefore,ArrayJoin,ArrayPut,ArrayRemove,ArrayReverse,ArraySize,ArraySort,ArraySubarray,ArrayTail,BinAnd,BinBin,BinDecodeString,BinEncodeString,BinFind,BinFromOctets,BinHex,BinInsertBefore,BinJoin,BinLength,BinNot,BinOctal,BinOr,BinPackDouble,BinPackFloat,BinPackInteger,BinPadLeft,BinPadRight,BinPart,BinShift,BinToOctets,BinUnpackDouble,BinUnpackFloat,BinUnpackInteger,BinUnpackUnsignedInteger,BinXor,ClientClose,ClientConnect,ClientExecute,ClientInfo,ClientQuery,ContextFn,ConvertBinaryToBytes,ConvertBinaryToIntegers,ConvertDateTimeToInteger,ConvertDayTimeToInteger,ConvertFn,ConvertIntegerFromBase,ConvertIntegerToBase,ConvertIntegerToDateTime,ConvertIntegerToDayTime,CryptoDecrypt,CryptoEncrypt,CryptoGenerateSignature,CryptoHmac,CryptoValidateSignature,CsvParse,CsvSerialize,DbAdd,DbAlterBackup,DbBackups,DbContentType,DbCopy,DbCreate,DbCreateBackup,DbDelete,DbDrop,DbDropBackup,DbExists,DbExport,DbFlush,DbInfo,DbIsRaw,DbIsXml,DbList,DbName,DbNodeId,DbOpen,DbOpenId,DbOptimize,DbOption,DbPath,DbProperty,DbRename,DbReplace,DbRestore,DbRetrieve,DbStore,DbSystem,DbText,DbTextRange,Docs,FetchBinary,FetchContentType,FetchText,FetchXml,FileBaseDir,FileCopy,FileCreateDir,FileCreateTempFile,FileCurrentDir,FileDelete,FileDirSeparator,FileExists,FileIsAbsolute,FileIsDir,FileIsFile,FileLastModified,FileLineSeparator,FileList,FileName,FileParent,FilePathSeparator,FilePathToNative,FilePathToUri,FileReadBinary,FileReadText,FileReadTextLines,FileResolvePath,FileSize,FileTempDir,FileWrite,FileWriteBinary,FileWriteText,FileWriteTextLines,FnAbs,FnAdjustDateToTimezone,FnAdjustTimeToTimezone,FnAdustDateTimeToTimezone,FnAnalyzeString,FnApply,FnAvailableEnvironmentVariables,FnBoolean,FnCeiling,FnCodepointEqual,FnCodepointsToString,FnCompare,FnConcat,FnContains,FnContainsToken,FnCount,FnCurrentDate,FnCurrentDateTime,FnCurrentTime,FnDateTime,FnDayFromDate,FnDayFromDateTime,FnDayFromDuration,FnDeepEqual,FnDefaultCollation,FnDefaultLanguage,FnDistinctValues,FnEmpty,FnEncodeForUri,FnEndsWith,FnEnvironmentVariable,FnError,FnEscapeHtmlUri,FnExactlyOne,FnFalse,FnFilter,FnFloor,FnFoldLeft,FnFoldRight,FnForEach,FnForEachPair,FnFormatDate,FnFormatDateTime,FnFormatInteger,FnFormatNumber,FnFormatTime,FnFunctionArity,FnFunctionLookup,FnFunctionName,FnHead,FnHoursFromDateTime,FnHoursFromDuration,FnHoursFromTime,FnImplicitTimezone,FnIndexOf,FnInScopePrefixes,FnInsertBefore,FnIriToUri,FnLast,FnLocalNameFromQName,FnLowerCase,FnMatches,FnMin,FnMinutesFromDateTime,FnMinutesFromDuration,FnMinutesFromTime,FnMonthFromDate,FnMonthFromDateTime,FnMonthsFromDuration,FnNamespaceUriForPrefix,FnNamespaceUriFromQName,FnNormalizeUnicode,FnNot,FnOneOrMore,FnOutermost,FnParseIetfDate,FnPosition,FnPrefixFromQName,FnPut,FnQName,FnRandomNumberGenerator,FnRemove,FnReplace,FnResolveQName,FnResolveUri,FnReverse,FnRound,FnSecondsFromDateTime,FnSecondsFromDuration,FnSecondsFromTime,FnSerialize,FnSort,FnStartsWith,FnStaticBaseUri,FnStringJoin,FnStringToCodepoints,FnSubsequence,FnSubstring,FnSubstringAfter,FnSubstringBefore,FnSum,FnTail,FnTimezoneFromDate,FnTimezoneFromDateTime,FnTimezoneFromTime,FnTokenize,FnTrace,FnTranslate,FnTrue,FnUnordered,FnUpperCase,FnYearFromDate,FnYearFromDateTime,FnYearsFromDuration,FnZeroOrOne,FtContains,FtCount,FtMark,FtScore,FtSearch,FtTokenize,FtTokens,HashHash,HashMd5,HashSha1,HashSha256,HofFoldLeft1,HofId,HofScanLeft,HofSortWith,HofTakeWhile,HofTopKBy,HofTopKWith,HofUntil,HtmlParse,HtmlParser,HttpSendRequest,IndexFn,InspectContext,InspectFunction,InspectFunctionAnnotations,InspectFunctions,InspectModule,InspectStaticContext,InspectType,InspectXqdoc,JobsCurrent,JobsEval,JobsFinished,JobsList,JobsListDetails,JobsResult,JobsServices,JobsStop,JobsWait,JsonParse,JsonSerialize,LazyCache,LazyIsCached,LazyIsLazy,MapContains,MapEntry,MapFind,MapForEach,MapGet,MapKeys,MapMerge,MapPut,MapRemove,MapSize,MathAtan2,MathFn,OutCr,OutFormat,OutNl,OutTab,Parse,ProcExecute,ProcFork,ProcProperty,ProcPropertyNames,ProcSystem,ProfCurrentMs,ProfCurrentNs,ProfGc,ProfHuman,ProfRuntime,ProfSleep,ProfTime,ProfTrack,ProfType,ProfVariables,ProfVoid,RandomDouble,RandomGaussian,RandomInteger,RandomSeededDouble,RandomSeededInteger,RandomSeededPermutation,RandomUuid,RepoDelete,RepoInstall,RepoList,SqlClose,SqlCommit,SqlConnect,SqlExecute,SqlInit,SqlPrepare,SqlRollback,StringsColognePhonetic,StringsLevenshtein,StringsSoundex,UnitAssert,UnitAssertEquals,UnitFail,UpdateCache,UpdateOutput,UserAlter,UserCheck,UserCreate,UserCurrent,UserDrop,UserExists,UserGrant,UserInfo,UserList,UserPassword,UserUpdateInfo,UtilArrayMembers,UtilArrayValues,UtilChars,UtilDdo,UtilDeepEqual,UtilDuplicates,UtilIf,UtilInit,UtilIntersperse,UtilItem,UtilLast,UtilMapEntries,UtilMapValues,UtilOr,UtilReplicate,UtilRoot,UtilWithin,ValidateDtd,ValidateRng,ValidateXsd,ValidateXsdProcessor,ValidateXsdVersion,WebContentType,WebCreateUrl,WebDecodeUrl,WebEncodeUrl,WebError,WebForward,WebRedirect,WebResponseHeader,XQueryEval,XQueryForkJoin,XQueryParse,XsltInit,XsltProcessor,XsltTransform,XsltVersion,ZipBinaryEntry,ZipEntries,ZipZipFile
Built-in functions.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
FieldsModifier and TypeFieldDescriptionFunction definition.Static context. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidChecks if the current user has create permissions.protected final FItemcheckArity(Expr expr, int nargs, boolean updating, QueryContext qc) Casts and checks the function item for its arity.protected final FItemcheckArity(Expr expr, int nargs, QueryContext qc) Casts and checks the function item for its arity.protected final voidChecks if the current user has create permissions.protected final DataReturns a database instance for the first string argument of the function.protected final IOcheckPath(byte[] uri) Returns a valid reference if a file is found at the specified path or the static base uri.protected final IOcheckPath(int i, QueryContext qc) Returns a valid reference if a file is found at the specified path or the static base uri.final ExprcoerceFunc(Expr expr, CompileContext cc, SeqType declType, SeqType... argTypes) Refines the type of a function item argument.protected final ExprOpens a database at compile time.final StandardFunccopy(CompileContext cc, IntObjMap<Var> vm) Copies an expression.final Datadata()Returns the data reference bound to this expression.final voidAssigns a data reference, if supported.protected final booleandataLock(ASTVisitor visitor, int i) Tries to mark the specified argument for locking.protected final longdateTimeToMs(Expr expr, QueryContext qc) Converts the specified dateTime to milliseconds.final StringReturns a string description of the expression.final booleanThis function is e.g.booleanIndicates if an expression has one of the specified compiler properties.protected Expropt(CompileContext cc) Performs function specific optimizations.protected final ExproptFirst()Optimizes a function that returns an empty sequence when the first atomized argument is empty, and adjusts the occurrence indicator if the argument will always yield one item.protected final ExprOptimizes a function that returns an empty sequence when the first argument or the context value is empty.final ExprOptimizes an already compiled expression without recompiling its sub-expressions.final voidCreates a query plan.final voidplan(QueryString qs) Creates a query string.protected final byte[]serialize(Iter iter, SerializerOptions opts, QueryError err, QueryContext qc) Serializes the data from the specified iterator.protected voidSimplifies the types of all arguments.protected final StringEvaluates the specified URI.toBindings(int i, QueryContext qc) Returns all keys and values of the specified binding argument.protected final CollationtoCollation(int i, QueryContext qc) Checks if the specified collation is supported.protected final ADatetoDate(Item item, AtomType type, QueryContext qc) Checks if the specified item has the specified Date type.protected final DBNodeChecks if the specified expression is a database node.protected final StringtoEncodingOrNull(int i, QueryError err, QueryContext qc) Returns a normalized encoding representation.protected final ItemtoNodeOrAtomItem(int i, QueryContext qc) Returns the expression at the specified index as node or atomized item.protected final <E extends Options>
EtoOptions(int i, E opts, QueryContext qc) Parses the options at the specified index.protected final PathtoPath(byte[] path) Converts the specified string to a file path.protected final PathtoPath(int i, QueryContext qc) Converts the specified argument to a file path.protected final IOContenttoQuery(byte[] uri, QueryContext qc) Evaluates the specified URI.protected final IOContenttoQuery(int i, QueryContext qc) Evaluates the specified URI.booleanvacuous()Tests if this is a vacuous expression (empty sequence or error function).Methods inherited from class org.basex.query.expr.Arr
accept, allAreValues, args, checkUp, compile, copyAll, count, exprSize, flatten, inline, inline, inlineable, mayBePositional, simplifyAllMethods inherited from class org.basex.query.expr.ParseExpr
adoptType, atomValue, checkAllUp, checkNoEmpty, checkNoEmpty, checkNoneUp, checkNoUp, checkType, checkType, checkUp, copyType, ctxValue, ebv, item, iter, refineType, seqType, size, test, toArray, toArray, toAtomItem, toB64, toB64, toBin, toBin, toBoolean, toBoolean, toBytes, toBytes, toDouble, toDouble, toElem, toFloat, toFunc, toItem, toItem, toLong, toLong, toMap, toMap, toNode, toNode, toNodeOrNull, toNumber, toNumberOrNull, toQNm, toQNm, toToken, toToken, toTokenOrNull, toZeroToken, valueMethods inherited from class org.basex.query.expr.Expr
arg, atomItem, atomIter, ddo, funcType, hasFreeVars, indexAccessible, isSimple, markTailCalls, mergeEbv, simplifyFor, typeCheck, uses, visitAllMethods inherited from class org.basex.query.expr.ExprInfo
toErrorString, toString
-
Field Details
-
definition
Function definition. -
sc
Static context.
-
-
Constructor Details
-
StandardFunc
protected StandardFunc()Constructor.
-
-
Method Details
-
optimize
Description copied from class:ExprOptimizes an already compiled expression without recompiling its sub-expressions.- Overrides:
optimizein classExpr- Parameters:
cc- compilation context- Returns:
- optimized expression
- Throws:
QueryException- query exception
-
simplifyArgs
Simplifies the types of all arguments. This function is overwritten by functions that rely on the original argument type.- Parameters:
cc- compilation context- Throws:
QueryException- query exception
-
opt
Performs function specific optimizations.- Parameters:
cc- compilation context- Returns:
- optimized or original expression
- Throws:
QueryException- query exception
-
copy
Description copied from class:ExprCopies an expression. Used for inlining functions, or for copying static queries. It is utilized byVarRef.inline(org.basex.query.InlineContext),FuncItem.inline(org.basex.query.expr.Expr[], org.basex.query.CompileContext),Closure.inline(org.basex.query.InlineContext)andStaticFunc.inline(org.basex.query.expr.Expr[], org.basex.query.CompileContext).- Specified by:
copyin classExpr- Parameters:
cc- compilation contextvm- mapping from old variable IDs to new variable copies. Required byClosure.copy(org.basex.query.CompileContext, org.basex.util.hash.IntObjMap<org.basex.query.var.Var>)andVarRef.copy(org.basex.query.CompileContext, org.basex.util.hash.IntObjMap<org.basex.query.var.Var>)- Returns:
- copied expression
-
optFirst
Optimizes a function that returns an empty sequence when the first atomized argument is empty, and adjusts the occurrence indicator if the argument will always yield one item.- Returns:
- original expression or function argument
-
optFirst
Optimizes a function that returns an empty sequence when the first argument or the context value is empty.- Returns the first argument (or the context) if it yields an empty sequence.
- Sets the occurrence indicator to 1 if the argument returns at least one item.
- Parameters:
occ- assign occurrence indicator (trueif function will always yield a result if first argument is non-empty)atom- argument will be atomizedvalue- context value (ignored ifnull)- Returns:
- original expression or function argument
-
serialize
protected final byte[] serialize(Iter iter, SerializerOptions opts, QueryError err, QueryContext qc) throws QueryException Serializes the data from the specified iterator.- Parameters:
iter- data to serializeopts- serialization parameterserr- error codeqc- query context- Returns:
- result
- Throws:
QueryException- query exception
-
has
Description copied from class:ExprIndicates if an expression has one of the specified compiler properties. This method must only be called at compile time. It is invoked to test properties of sub-expressions. It returnstrueif at least flag matches an expression. -
vacuous
public boolean vacuous()Description copied from class:ExprTests if this is a vacuous expression (empty sequence or error function). This check is needed for updating queries. -
coerceFunc
public final Expr coerceFunc(Expr expr, CompileContext cc, SeqType declType, SeqType... argTypes) throws QueryException Refines the type of a function item argument.- Parameters:
expr- expressioncc- compilation contextdeclType- declared return typeargTypes- argument types- Returns:
- old or new expression
- Throws:
QueryException- query context
-
compileData
Opens a database at compile time.- Parameters:
cc- compilation context- Returns:
- self reference
- Throws:
QueryException- query exception
-
data
Description copied from class:Expr -
data
Description copied from class:ExprAssigns a data reference, if supported. -
toDate
Checks if the specified item has the specified Date type. If it is item, the specified Date is returned.- Parameters:
item- item to be checkedtype- target typeqc- query context- Returns:
- date
- Throws:
QueryException- query exception
-
toDBNode
Checks if the specified expression is a database node. Returns the node or an exception.- Parameters:
item- item to be checked- Returns:
- item
- Throws:
QueryException- query exception
-
toCollation
Checks if the specified collation is supported.- Parameters:
i- index of argumentqc- query context- Returns:
- collator or
null(default collation) - Throws:
QueryException- query exception
-
toPath
Converts the specified argument to a file path.- Parameters:
i- index of argumentqc- query context- Returns:
- file instance
- Throws:
QueryException- query exception
-
toPath
Converts the specified string to a file path.- Parameters:
path- path string- Returns:
- file instance
- Throws:
QueryException- query exception
-
checkPath
Returns a valid reference if a file is found at the specified path or the static base uri. Otherwise, returns an error.- Parameters:
i- index of URI argumentqc- query context- Returns:
- input source, or exception
- Throws:
QueryException- query exception
-
checkPath
Returns a valid reference if a file is found at the specified path or the static base uri. Otherwise, returns an error.- Parameters:
uri- file URI- Returns:
- input source, or exception
- Throws:
QueryException- query exception
-
toQuery
Evaluates the specified URI.- Parameters:
i- index of input argumentqc- query context- Returns:
- query contents and URL
- Throws:
QueryException- query exception
-
toQuery
Evaluates the specified URI.- Parameters:
uri- uriqc- query context- Returns:
- query contents and URL
- Throws:
QueryException- query exception
-
toBaseUri
Evaluates the specified URI.- Parameters:
path- custom pathoptions- options with base-uri property- Returns:
- base URI
-
toEncodingOrNull
protected final String toEncodingOrNull(int i, QueryError err, QueryContext qc) throws QueryException Returns a normalized encoding representation.- Parameters:
i- index of encoding argumenterr- error for invalid encodingqc- query context- Returns:
- string or
null - Throws:
QueryException- query exception
-
toNodeOrAtomItem
Returns the expression at the specified index as node or atomized item. Returns the item or throws an exception.- Parameters:
i- index of argumentqc- query context- Returns:
- node or atomized item
- Throws:
QueryException- query exception
-
toOptions
protected final <E extends Options> E toOptions(int i, E opts, QueryContext qc) throws QueryException Parses the options at the specified index.- Type Parameters:
E- options type- Parameters:
i- index of argument (can exceed length of argument, or may yield an empty sequence)opts- optionsqc- query context- Returns:
- passed on options
- Throws:
QueryException- query exception
-
toBindings
Returns all keys and values of the specified binding argument.- Parameters:
i- index of argumentqc- query context- Returns:
- resulting map
- Throws:
QueryException- query exception
-
checkData
Returns a database instance for the first string argument of the function. This method assumes that the function has at least one argument.- Parameters:
qc- query context- Returns:
- data instance
- Throws:
QueryException- query exception
-
checkAdmin
Checks if the current user has create permissions. If negative, an exception is thrown.- Parameters:
qc- query context- Throws:
QueryException- query exception
-
checkCreate
Checks if the current user has create permissions. If negative, an exception is thrown.- Parameters:
qc- query context- Throws:
QueryException- query exception
-
checkArity
Casts and checks the function item for its arity.- Parameters:
expr- expressionnargs- number of arguments (arity)qc- query context- Returns:
- function item
- Throws:
QueryException- query exception
-
checkArity
protected final FItem checkArity(Expr expr, int nargs, boolean updating, QueryContext qc) throws QueryException Casts and checks the function item for its arity.- Parameters:
expr- expressionnargs- number of arguments (arity)qc- query contextupdating- updating flag- Returns:
- function item
- Throws:
QueryException- query exception
-
dateTimeToMs
Converts the specified dateTime to milliseconds.- Parameters:
expr- expressionqc- query context- Returns:
- resulting value
- Throws:
QueryException- query exception
-
dataLock
Tries to mark the specified argument for locking.- Parameters:
visitor- visitori- index of database argument- Returns:
- result of check
-
equals
Description copied from class:ArrThis function is e.g. called by:Must be overwritten by implementing class.If.optimize(CompileContext),Switch.optimize(CompileContext),Typeswitch.optimize(CompileContext), in order to discard identical expressions.CmpR.mergeEbv(Expr, boolean, CompileContext)orCmpSR.mergeEbv(Expr, boolean, CompileContext), in order to merge expressions with identical input.CmpG.optimize(CompileContext)orCmpV.optimize(CompileContext), in order to pre-evaluate equality tests.CmpG.optimize(CompileContext)orPos.get(Expr, CmpV.OpV, InputInfo, CompileContext), in order to compare the start and end value.PathCache, in order to find identical root values at runtime.
-
description
Description copied from class:ExprInfoReturns a string description of the expression. This method is only called by error messages. Contrary to theExprInfo.toString()method, arguments are not included in the output.- Overrides:
descriptionin classExprInfo- Returns:
- result of check
-
plan
Description copied from class:ExprInfoCreates a query plan. -
plan
Description copied from class:ExprInfoCreates a query string.
-