Package net.sf.saxon.functions
Class Translate
java.lang.Object
net.sf.saxon.functions.AbstractFunction
net.sf.saxon.functions.SystemFunction
net.sf.saxon.functions.Translate
- All Implemented Interfaces:
Callable
,StatefulSystemFunction
,FunctionItem
,GroundedValue
,Item
,Sequence
Implement the XPath translate() function
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall
(XPathContext context, Sequence[] arguments) Evaluate the expressioncopy()
Make a copy of this SystemFunction.fixArguments
(Expression... arguments) Allow the function to create an optimized call based on the values of the actual argumentsMake an elaborator for a system function call on this functionGet the translation map built at compile time if there is onestatic StringValue
translate
(StringValue sv0, StringValue sv1, StringValue sv2) Perform the translate functionstatic StringValue
translateUsingMap
(StringValue in, IntToIntMap map) Implement the translate() function using an index built at compile timeMethods inherited from class net.sf.saxon.functions.SystemFunction
dependsOnContextItem, dynamicCall, equals, export, exportAdditionalArguments, exportAttributes, getArity, getCardinality, getContextNode, getDescription, getDetails, getErrorCodeForTypeErrors, getFunctionItemType, getFunctionName, getIntegerBounds, getNetCost, getOperandRoles, getRequiredType, getResultItemType, getResultItemType, getRetainedStaticContext, getSpecialProperties, getStaticBaseUriString, getStreamerName, getUniStringArg, hashCode, importAttributes, isSequenceVariadic, isTrustedResultType, makeCall, makeFunction, makeFunction40, makeFunctionCall, makeOptimizedFunctionCall, resultIfEmpty, setArity, setDetails, setRetainedStaticContext, supplyTypeInformation, toShortString, toString, typeCheckCaller
Methods inherited from class net.sf.saxon.functions.AbstractFunction
atomize, deepEqual40, deepEquals, effectiveBooleanValue, getAnnotations, getUnicodeStringValue, isArray, isMap, makeNewContext, simplify, typeCheck
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.saxon.om.FunctionItem
getGenre
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materialize
Methods inherited from interface net.sf.saxon.om.Item
getLength, getStringValue, head, isStreamed, itemAt, iterate, reduce, subsequence
Methods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Constructor Details
-
Translate
public Translate()
-
-
Method Details
-
fixArguments
Allow the function to create an optimized call based on the values of the actual arguments- Overrides:
fixArguments
in classSystemFunction
- Parameters:
arguments
- the supplied arguments to the function call- Returns:
- either a function call on this function, or an expression that delivers the same result, or null indicating that no optimization has taken place
-
getStaticMap
Get the translation map built at compile time if there is one- Returns:
- the map built at compile time, or null if not available
-
translate
Perform the translate function- Parameters:
sv0
- the string to be translatedsv1
- the characters to be substitutedsv2
- the replacement characters- Returns:
- the converted string
-
translateUsingMap
Implement the translate() function using an index built at compile time- Parameters:
in
- the string to be translatedmap
- index built at compile time, mapping input characters to output characters. The map returns -1 for a character that is to be deleted from the input string, Integer.MAX_VALUE for a character that is to remain intact- Returns:
- the translated character string
-
call
Evaluate the expression- Specified by:
call
in interfaceCallable
- Parameters:
context
- the dynamic evaluation contextarguments
- the values of the arguments, supplied as Sequences- Returns:
- the result of the evaluation, in the form of a Sequence
- Throws:
XPathException
- if a dynamic error occurs during the evaluation of the expression
-
copy
Make a copy of this SystemFunction. This is required only for system functions such as regex functions that maintain state on behalf of a particular caller.- Specified by:
copy
in interfaceStatefulSystemFunction
- Returns:
- a copy of the system function able to contain its own copy of the state on behalf of the caller.
-
getElaborator
Make an elaborator for a system function call on this function- Overrides:
getElaborator
in classSystemFunction
- Returns:
- a suitable elaborator; or null if no custom elaborator is available
-