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 withXPathExpressionto 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
Constructors Constructor Description MapBasedXPathFunctionResolver()Default ctor.MapBasedXPathFunctionResolver(MapBasedXPathFunctionResolver aOther)Copy constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.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.booleanequals(Object o)com.helger.commons.collection.impl.ICommonsOrderedMap<XPathFunctionKey,XPathFunction>getAllFunctions()MapBasedXPathFunctionResolvergetClone()intgetFunctionCount()inthashCode()com.helger.commons.state.EChangeremoveFunction(XPathFunctionKey aKey)Remove 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.XPathFunctionresolveFunction(XPathFunctionKey aFunctionKey)XPathFunctionresolveFunction(QName aFunctionName, int nArity)StringtoString()
-
-
-
Constructor Detail
-
MapBasedXPathFunctionResolver
public MapBasedXPathFunctionResolver()
Default ctor.
-
MapBasedXPathFunctionResolver
public MapBasedXPathFunctionResolver(@Nonnull MapBasedXPathFunctionResolver aOther)
Copy constructor- Parameters:
aOther- Object to copy data from
-
-
Method Detail
-
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
@Nonnull public com.helger.commons.state.EChange removeFunction(@Nullable XPathFunctionKey aKey)
Remove the function with the specified name.- Parameters:
aKey- The function key to be removed. May benull.- Returns:
EChange
-
removeFunctionsWithName
@Nonnull public com.helger.commons.state.EChange removeFunctionsWithName(@Nullable QName aName)
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
@Nonnegative public int getFunctionCount()
- Returns:
- The number of contained functions. Always ≥ 0.
-
clear
@Nonnull public com.helger.commons.state.EChange 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
@Nullable public XPathFunction resolveFunction(@Nullable XPathFunctionKey aFunctionKey)
-
getClone
@Nonnull @ReturnsMutableCopy public MapBasedXPathFunctionResolver getClone()
- Specified by:
getClonein interfacecom.helger.commons.lang.ICloneable<MapBasedXPathFunctionResolver>
-
-