com.saxonica.functions.extfn
Class SubsequenceTestFn

java.lang.Object
  extended by net.sf.saxon.lib.ExtensionFunctionDefinition
      extended by com.saxonica.functions.extfn.SubsequenceTestFn
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
SubsequenceTestFn.SubsequenceAfterFn, SubsequenceTestFn.SubsequenceBeforeFn, SubsequenceTestFn.SubsequenceFromFn, SubsequenceTestFn.SubsequenceUntilFn

public abstract class SubsequenceTestFn
extends ExtensionFunctionDefinition

Abstract class providing functionality common to functions saxon:subsequence-before, saxon:subsequence-after etc; contains the concrete implementations of these functions as inner subclasses

See Also:
Serialized Form

Nested Class Summary
static class SubsequenceTestFn.SubsequenceAfterFn
          Implement saxon:subsequence-after
static class SubsequenceTestFn.SubsequenceBeforeFn
          Implement saxon:subsequence-before
static class SubsequenceTestFn.SubsequenceFromFn
          Implement saxon:subsequence-from
static class SubsequenceTestFn.SubsequenceUntilFn
          Implement saxon:subsequence-until
 
Constructor Summary
SubsequenceTestFn()
           
 
Method Summary
protected abstract  SequenceIterator compute(SequenceIterator input, FunctionItem test, XPathContext context)
          The function that does the work, which must be implemented in subclasses
 SequenceType[] getArgumentTypes()
          Get the required types for the arguments of this function.
 int getMaximumNumberOfArguments()
          Get the maximum number of arguments allowed by the function.
 int getMinimumNumberOfArguments()
          Get the minimum number of arguments required by the function
 SequenceType getResultType(SequenceType[] suppliedArgumentTypes)
          Get the type of the result of the function
 ExtensionFunctionCall makeCallExpression()
          Create a call on this function.
 boolean trustResultType()
          Ask whether the result actually returned by the function can be trusted, or whether it should be checked against the declared type.
 
Methods inherited from class net.sf.saxon.lib.ExtensionFunctionDefinition
dependsOnFocus, getFunctionQName, hasSideEffects
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubsequenceTestFn

public SubsequenceTestFn()
Method Detail

getMinimumNumberOfArguments

public int getMinimumNumberOfArguments()
Get the minimum number of arguments required by the function

The default implementation returns the number of items in the result of calling getArgumentTypes()

Overrides:
getMinimumNumberOfArguments in class ExtensionFunctionDefinition
Returns:
the minimum number of arguments that must be supplied in a call to this function

getMaximumNumberOfArguments

public int getMaximumNumberOfArguments()
Get the maximum number of arguments allowed by the function.

The default implementation returns the value of getMinimumNumberOfArguments()

Overrides:
getMaximumNumberOfArguments in class ExtensionFunctionDefinition
Returns:
the maximum number of arguments that may be supplied in a call to this function

trustResultType

public boolean trustResultType()
Ask whether the result actually returned by the function can be trusted, or whether it should be checked against the declared type.

Overrides:
trustResultType in class ExtensionFunctionDefinition
Returns:
true if the function implementation warrants that the value it returns will be an instance of the declared result type. The default value is false, in which case the result will be checked at run-time to ensure that it conforms to the declared type. If the value true is returned, but the function returns a value of the wrong type, the consequences are unpredictable.

getArgumentTypes

public SequenceType[] getArgumentTypes()
Get the required types for the arguments of this function.

This method must be implemented in all subtypes.

Specified by:
getArgumentTypes in class ExtensionFunctionDefinition
Returns:
the required types of the arguments, as defined by the function signature. Normally this should be an array of size getMaximumNumberOfArguments(); however for functions that allow a variable number of arguments, the array can be smaller than this, with the last entry in the array providing the required type for all the remaining arguments.

getResultType

public SequenceType getResultType(SequenceType[] suppliedArgumentTypes)
Get the type of the result of the function

This method must be implemented in all subtypes.

Specified by:
getResultType in class ExtensionFunctionDefinition
Parameters:
suppliedArgumentTypes - the static types of the supplied arguments to the function. This is provided so that a more precise result type can be returned in the common case where the type of the result depends on the types of the arguments.
Returns:
the return type of the function, as defined by its function signature

compute

protected abstract SequenceIterator compute(SequenceIterator input,
                                            FunctionItem test,
                                            XPathContext context)
                                     throws XPathException
The function that does the work, which must be implemented in subclasses

Parameters:
input - the input sequence
test - the function to be applied to the items in the sequence, which takes an item in the sequence as input and produces a boolean as its result
context - the XPath dynamic context
Returns:
the result
Throws:
XPathException - if a dynamic error occurs

makeCallExpression

public ExtensionFunctionCall makeCallExpression()
Create a call on this function. This method is called by the compiler when it identifies a function call that calls this function.

Specified by:
makeCallExpression in class ExtensionFunctionDefinition
Returns:
an expression representing a call of this extension function


Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.