Package com.helger.xml.xpath
Class MapBasedXPathFunctionResolver
java.lang.Object
com.helger.xml.xpath.MapBasedXPathFunctionResolver
- All Implemented Interfaces:
com.helger.commons.lang.ICloneable<MapBasedXPathFunctionResolver>,XPathFunctionResolver
@NotThreadSafe
public class MapBasedXPathFunctionResolver
extends Object
implements XPathFunctionResolver, com.helger.commons.lang.ICloneable<MapBasedXPathFunctionResolver>
Class is used in conjunction with
XPathExpression to
resolve variable values used in XPath queries at runtime. The whole QName is
used as the key in the map. The namespace is not-ignored in this class.- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionDefault ctor.Copy constructor -
Method Summary
Modifier and TypeMethodDescriptioncom.helger.commons.state.EChangeaddAllFrom(MapBasedXPathFunctionResolver aOther, boolean bOverwrite) Add all functions from the other function resolver into this resolver.com.helger.commons.state.EChangeaddUniqueFunction(String sNamespaceURI, String sLocalPart, int nArity, XPathFunction aFunction) Add a new function.com.helger.commons.state.EChangeaddUniqueFunction(QName aName, int nArity, XPathFunction aFunction) Add a new function.com.helger.commons.state.EChangeclear()Remove all functions at once.booleancom.helger.commons.collection.impl.ICommonsOrderedMap<XPathFunctionKey,XPathFunction> getClone()intinthashCode()com.helger.commons.state.EChangeRemove the function with the specified name.com.helger.commons.state.EChangeremoveFunction(QName aName, int nArity) Remove the function with the specified name.com.helger.commons.state.EChangeremoveFunctionsWithName(QName aName) Remove all functions with the same name.resolveFunction(XPathFunctionKey aFunctionKey) resolveFunction(QName aFunctionName, int nArity) toString()
-
Constructor Details
-
MapBasedXPathFunctionResolver
public MapBasedXPathFunctionResolver()Default ctor. -
MapBasedXPathFunctionResolver
Copy constructor- Parameters:
aOther- Object to copy data from
-
-
Method Details
-
addUniqueFunction
@Nonnull public com.helger.commons.state.EChange addUniqueFunction(@Nonnull String sNamespaceURI, @Nonnull String sLocalPart, @Nonnegative int nArity, @Nonnull XPathFunction aFunction) Add a new function.- Parameters:
sNamespaceURI- The namespace URI of the functionsLocalPart- The local part of the functionnArity- The number of parameters of the functionaFunction- The function to be used. May not benull.- Returns:
EChange
-
addUniqueFunction
@Nonnull public com.helger.commons.state.EChange addUniqueFunction(@Nonnull QName aName, @Nonnegative int nArity, @Nonnull XPathFunction aFunction) Add a new function.- Parameters:
aName- The qualified name of the functionnArity- The number of parameters of the functionaFunction- The function to be used. May not benull.- Returns:
EChange
-
addAllFrom
@Nonnull public com.helger.commons.state.EChange addAllFrom(@Nonnull MapBasedXPathFunctionResolver aOther, boolean bOverwrite) Add all functions from the other function resolver into this resolver.- Parameters:
aOther- The function resolver to import the functions from. May not benull.bOverwrite- iftrueexisting functions will be overwritten with the new functions, otherwise the old functions are kept.- Returns:
EChange
-
removeFunction
@Nonnull public com.helger.commons.state.EChange removeFunction(@Nonnull QName aName, @Nonnegative int nArity) Remove the function with the specified name.- Parameters:
aName- The name to be removed. May not benull.nArity- The number of parameters of the function. Must be ≥ 0.- Returns:
EChange
-
removeFunction
Remove the function with the specified name.- Parameters:
aKey- The function key to be removed. May benull.- Returns:
EChange
-
removeFunctionsWithName
Remove all functions with the same name. This can be helpful when the same function is registered for multiple parameters.- Parameters:
aName- The name to be removed. May benull.- Returns:
EChange.CHANGEDif at least one function was removed.
-
getAllFunctions
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedMap<XPathFunctionKey,XPathFunction> getAllFunctions()- Returns:
- A mutable copy of all contained functions. Never
nullbut maybe empty.
-
getFunctionCount
- Returns:
- The number of contained functions. Always ≥ 0.
-
clear
Remove all functions at once.- Returns:
EChange.CHANGEDif at least one function was removed.
-
resolveFunction
@Nullable public XPathFunction resolveFunction(@Nonnull QName aFunctionName, @Nonnegative int nArity) - Specified by:
resolveFunctionin interfaceXPathFunctionResolver
-
resolveFunction
-
getClone
- Specified by:
getClonein interfacecom.helger.commons.lang.ICloneable<MapBasedXPathFunctionResolver>
-
equals
-
hashCode
public int hashCode() -
toString
-