net.sf.saxon.functions
Class SystemFunction

java.lang.Object
  extended by net.sf.saxon.expr.Expression
      extended by net.sf.saxon.expr.FunctionCall
          extended by net.sf.saxon.functions.SystemFunction
All Implemented Interfaces:
Serializable, SourceLocator, Container, EvaluableItem, SequenceIterable, InstructionInfoProvider
Direct Known Subclasses:
Adjust, Aggregate, Available, BaseURI, BooleanFn, CodepointEqual, CodepointsToString, CollatingFunction, Collection, CompileTimeFunction, Component, Concat, Current, CurrentDateTime, CurrentGroup, DateTimeConstructor, Doc, DocAvailable, Document, DynamicFunctionCall, Error, EscapeURI, Evaluate, Existence, Find, ForceCase, ForEachGroupFunction, FormatDate, FormatNumber2, Id, Idref, InScopePrefixes, Insert, KeyFn, Lang, Last, Matches, NamePart, NamespaceForPrefix, Nilled, NormalizeSpace, NormalizeUnicode, NumberFn, Parse, Position, QNameFn, RegexGroup, Remove, Replace, ResolveQName, ResolveURI, Root, Rounding, Serialize, StringFn, StringJoin, StringLength, StringToCodepoints, Subsequence, Substring, SystemProperty, Tokenize, Trace, Translate, TreatFn, Try, UnparsedEntity, UnparsedText

public abstract class SystemFunction
extends FunctionCall

Abstract superclass for system-defined and user-defined functions

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
 
Constructor Summary
SystemFunction()
           
 
Method Summary
 void checkArguments(StaticContext env)
          Method called during static type checking
 int computeCardinality()
          Determine the cardinality of the function.
 int computeSpecialProperties()
          Determine the special properties of this expression.
 void display(int level, PrintStream out, Configuration config)
          Diagnostic print of expression structure
 StandardFunction.Entry getDetails()
          Get the details
 String getErrorCodeForTypeErrors()
          Return the error code to be used for type errors.
 ItemType getItemType(TypeHierarchy th)
          Determine the item type of the value returned by the function
static void main(String[] args)
          The main() method of this class is not intended to be called, it merely tells the code inspection tools in IDEA that the constructors of each function class are actual entry points
static FunctionCall makeSystemFunction(String name, int arity, NamePool pool)
          Make a system function (one in the standard function namespace).
 Expression optimize(Optimizer opt, StaticContext env, ItemType contextItemType)
          Perform optimisation of an expression and its subexpressions.
 void setDetails(StandardFunction.Entry entry)
          Set the details of this type of function
 
Methods inherited from class net.sf.saxon.expr.FunctionCall
getArguments, getDisplayName, getFunctionNameCode, getNumberOfArguments, iterateSubExpressions, preEvaluate, promote, replaceSubExpression, setArguments, setFunctionNameCode, simplify, typeCheck
 
Methods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, effectiveBooleanValue, evaluateAsString, evaluateItem, getCardinality, getColumnNumber, getContainingProcedure, getDependencies, getExecutable, getHostLanguage, getImplementationMethod, getInstructionInfo, getIntrinsicDependencies, getLineNumber, getLocationId, getLocationProvider, getParentExpression, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasBadParentPointer, iterate, markTailFunctionCalls, process, resetStaticProperties, setLocationId, setParentExpression, setParentExpression, suppressValidation
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemFunction

public SystemFunction()
Method Detail

makeSystemFunction

public static FunctionCall makeSystemFunction(String name,
                                              int arity,
                                              NamePool pool)
Make a system function (one in the standard function namespace).

Parameters:
name - The local name of the function. It may also be a lexical QName for a recognized built-in function, e.g. saxon:evaluate, in which case the prefix is hard-coded.
Returns:
a FunctionCall that implements this function, if it exists, or null if the function is unknown.

setDetails

public void setDetails(StandardFunction.Entry entry)
Set the details of this type of function


getDetails

public StandardFunction.Entry getDetails()
Get the details


checkArguments

public void checkArguments(StaticContext env)
                    throws XPathException
Method called during static type checking

Throws:
XPathException

optimize

public Expression optimize(Optimizer opt,
                           StaticContext env,
                           ItemType contextItemType)
                    throws XPathException
Perform optimisation of an expression and its subexpressions.

This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.

Overrides:
optimize in class FunctionCall
Parameters:
opt - the optimizer in use. This provides access to supporting functions; it also allows different optimization strategies to be used in different circumstances.
env - the static context of the expression
contextItemType - the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set to Type.ITEM_TYPE
Returns:
the original expression, rewritten if appropriate to optimize execution
Throws:
StaticError - if an error is discovered during this phase (typically a type error)
XPathException

getErrorCodeForTypeErrors

public String getErrorCodeForTypeErrors()
Return the error code to be used for type errors. This is overridden for functions such as exactly-one(), one-or-more(), ...


getItemType

public ItemType getItemType(TypeHierarchy th)
Determine the item type of the value returned by the function

Specified by:
getItemType in class Expression
Parameters:
th -
Returns:
a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)

computeCardinality

public int computeCardinality()
Determine the cardinality of the function.


computeSpecialProperties

public int computeSpecialProperties()
Determine the special properties of this expression. The general rule is that a system function call is non-creative if its return type is atomic, or if all its arguments are non-creative. This is overridden for the generate-id() function, which is considered creative if its operand is creative (because the result depends on the identity of the operand)

Overrides:
computeSpecialProperties in class Expression

display

public void display(int level,
                    PrintStream out,
                    Configuration config)
Diagnostic print of expression structure

Overrides:
display in class FunctionCall
Parameters:
level - indentation level for this expression
out - Output destination

main

public static void main(String[] args)
                 throws Exception
The main() method of this class is not intended to be called, it merely tells the code inspection tools in IDEA that the constructors of each function class are actual entry points

Throws:
Exception


Copyright (C) Michael H. Kay. All rights reserved.