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
,Function
,GroundedValue
,Item
,Sequence
public class Translate extends SystemFunction implements Callable, StatefulSystemFunction
Implement the XPath translate() function
-
-
Constructor Summary
Constructors Constructor Description Translate()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringValue
call(XPathContext context, Sequence[] arguments)
Evaluate the expressionTranslate
copy()
Make a copy of this SystemFunction.Expression
fixArguments(Expression... arguments)
Allow the function to create an optimized call based on the values of the actual argumentsjava.lang.String
getCompilerName()
Get the (local) name of a class that can be used to generate bytecode for this system functionIntToIntMap
getStaticMap()
Get 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 time-
Methods 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, makeFunctionCall, makeOptimizedFunctionCall, resultIfEmpty, setArity, setDetails, setRetainedStaticContext, supplyTypeInformation, toShortString, toString, typeCheckCaller
-
Methods inherited from class net.sf.saxon.functions.AbstractFunction
atomize, deepEquals, effectiveBooleanValue, getAnnotations, getSerialNumber, 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.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
-
-
-
-
Method Detail
-
fixArguments
public Expression fixArguments(Expression... arguments)
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
public IntToIntMap 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
public static StringValue translate(StringValue sv0, StringValue sv1, StringValue sv2)
Perform the translate function- Parameters:
sv0
- the string to be translatedsv1
- the characters to be substitutedsv2
- the replacement characters- Returns:
- the converted string
-
translateUsingMap
public static StringValue translateUsingMap(StringValue in, IntToIntMap map)
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
public StringValue call(XPathContext context, Sequence[] arguments) throws XPathException
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
-
getCompilerName
public java.lang.String getCompilerName()
Description copied from class:SystemFunction
Get the (local) name of a class that can be used to generate bytecode for this system function- Overrides:
getCompilerName
in classSystemFunction
- Returns:
- the name of a bytecode generation class, or null if there is no bytecode support for this function
-
copy
public Translate 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.
-
-