Package com.helger.xml.xpath
Class MapBasedXPathVariableResolver
java.lang.Object
com.helger.xml.xpath.MapBasedXPathVariableResolver
- All Implemented Interfaces:
com.helger.commons.lang.ICloneable<MapBasedXPathVariableResolver>,XPathVariableResolver
@NotThreadSafe
public class MapBasedXPathVariableResolver
extends Object
implements XPathVariableResolver, com.helger.commons.lang.ICloneable<MapBasedXPathVariableResolver>
Class is used in conjunction with
XPathExpression to
resolve variable values used in XPath queries at runtime. The local part of
the QName to resolve is used as the key in the map. The namespace is ignored
in this class.- Author:
- Philip Helger
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault ctor.Copy constructorMapBasedXPathVariableResolver(Map<String, ?> aVars) Ctor taking another map. -
Method Summary
Modifier and TypeMethodDescriptioncom.helger.commons.state.EChangeaddAllFrom(MapBasedXPathVariableResolver aOther, boolean bOverwrite) Add all variables from the other variable resolver into this resolver.com.helger.commons.state.EChangeaddAllFrom(MapBasedXPathVariableResolverQName aOther, boolean bOverwrite) Add all variables from the other variable resolver into this resolver.com.helger.commons.state.EChangeaddUniqueVariable(String sName, Object aValue) Add a new variable.com.helger.commons.state.EChangeclear()Remove all variables at once.booleancom.helger.commons.collection.impl.ICommonsMap<String,?> getClone()intinthashCode()com.helger.commons.state.EChangeremoveVariable(String sName) Remove the variable with the specified name.com.helger.commons.state.EChangeremoveVariables(Iterable<String> aNames) Remove multiple variables at once.resolveVariable(QName aVariableName) voidsetAllVariables(Map<String, ?> aVars) Set multiple variables at once.toString()
-
Constructor Details
-
MapBasedXPathVariableResolver
public MapBasedXPathVariableResolver()Default ctor. -
MapBasedXPathVariableResolver
Ctor taking another map.- Parameters:
aVars- Variables to re-use. May benull.
-
MapBasedXPathVariableResolver
Copy constructor- Parameters:
aOther- Object to copy data from
-
-
Method Details
-
addUniqueVariable
@Nonnull public com.helger.commons.state.EChange addUniqueVariable(@Nonnull String sName, @Nonnull Object aValue) Add a new variable.- Parameters:
sName- The name (=local part) of the variableaValue- The value to be used.- Returns:
EChange
-
addAllFrom
@Nonnull public com.helger.commons.state.EChange addAllFrom(@Nonnull MapBasedXPathVariableResolver aOther, boolean bOverwrite) Add all variables from the other variable resolver into this resolver.- Parameters:
aOther- The variable resolver to import the variable from. May not benull.bOverwrite- iftrueexisting variables will be overwritten with the new variables, otherwise the old variables are kept.- Returns:
EChange
-
addAllFrom
@Nonnull public com.helger.commons.state.EChange addAllFrom(@Nonnull MapBasedXPathVariableResolverQName aOther, boolean bOverwrite) Add all variables from the other variable resolver into this resolver. This methods takes only the local part of the QName and loses the namespace URI.- Parameters:
aOther- The variable resolver to import the variable from. May not benull.bOverwrite- iftrueexisting variables will be overwritten with the new variables, otherwise the old variables are kept.- Returns:
EChange
-
removeVariable
Remove the variable with the specified name.- Parameters:
sName- The name to be removed. May benull.- Returns:
EChange
-
removeVariables
Remove multiple variables at once.- Parameters:
aNames- The names to be removed. May benull.- Returns:
EChange.CHANGEDif at least one variable was removed.
-
getAllVariables
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsMap<String,?> getAllVariables()- Returns:
- A mutable copy of all contained variables. Never
nullbut maybe empty.
-
getVariableCount
- Returns:
- The number of contained variables. Always ≥ 0.
-
clear
Remove all variables at once.- Returns:
EChange.CHANGEDif at least one variable was removed.
-
setAllVariables
Set multiple variables at once.- Parameters:
aVars- The variables to be set. May benull.
-
resolveVariable
- Specified by:
resolveVariablein interfaceXPathVariableResolver
-
getClone
- Specified by:
getClonein interfacecom.helger.commons.lang.ICloneable<MapBasedXPathVariableResolver>
-
equals
-
hashCode
public int hashCode() -
toString
-