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 Details

    • MapBasedXPathFunctionResolver

      public MapBasedXPathFunctionResolver()
      Default ctor.
    • MapBasedXPathFunctionResolver

      public MapBasedXPathFunctionResolver(@Nonnull MapBasedXPathFunctionResolver aOther)
      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 function
      sLocalPart - The local part of the function
      nArity - The number of parameters of the function
      aFunction - The function to be used. May not be null.
      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 function
      nArity - The number of parameters of the function
      aFunction - The function to be used. May not be null.
      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 be null.
      bOverwrite - if true existing 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 be null.
      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 be null.
      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 be null.
      Returns:
      EChange.CHANGED if 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 null but 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.CHANGED if at least one function was removed.
    • resolveFunction

      @Nullable public XPathFunction resolveFunction(@Nonnull QName aFunctionName, @Nonnegative int nArity)
      Specified by:
      resolveFunction in interface XPathFunctionResolver
    • resolveFunction

      @Nullable public XPathFunction resolveFunction(@Nullable XPathFunctionKey aFunctionKey)
    • getClone

      @Nonnull @ReturnsMutableCopy public MapBasedXPathFunctionResolver getClone()
      Specified by:
      getClone in interface com.helger.commons.lang.ICloneable<MapBasedXPathFunctionResolver>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object