Class MapBasedQueryWalker

All Implemented Interfaces:
QueryHelper.WalkerCallback
Direct Known Subclasses:
AbstractClassImpl.ClassQueryWalker, MapBasedQueryWalkerOrSupported

public class MapBasedQueryWalker extends QueryHelper.WalkerCallbackAdapter
Query walker that adds all properties for "equals" comparison to a map. If an unsupported property or comparison operation is encountered, an InvalidArgumentException is thrown unless the method handleUnmatchedComparison(int, String, String) returns true (default implementation returns false).
Author:
Frederik Heremans, Tijs Rademakers
  • Constructor Details

    • MapBasedQueryWalker

      public MapBasedQueryWalker(Set<String> supportedEqualsParameters, Set<String> supportedMatchesParameters)
  • Method Details

    • setSupportedGreaterThanParameters

      public void setSupportedGreaterThanParameters(Set<String> supportedGreaterThanParameters)
    • setSupportedGreaterThanOrEqualParameters

      public void setSupportedGreaterThanOrEqualParameters(Set<String> supportedGreaterThanOrEqualParameters)
    • setSupportedLessThanParameters

      public void setSupportedLessThanParameters(Set<String> supportedLessThanParameters)
    • setSupportedLessThanOrEqualParameters

      public void setSupportedLessThanOrEqualParameters(Set<String> supportedLessThanOrEqualParameters)
    • enableVariablesSupport

      public void enableVariablesSupport(org.alfresco.service.namespace.NamespaceService namespaceService, org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
    • getVariableProperties

      public List<MapBasedQueryWalker.QueryVariableHolder> getVariableProperties()
    • matches

      public void matches(String property, String value, boolean negated)
      Description copied from interface: QueryHelper.WalkerCallback
      Called any time a MATCHES clause is encountered.
      Specified by:
      matches in interface QueryHelper.WalkerCallback
      Overrides:
      matches in class QueryHelper.WalkerCallbackAdapter
      Parameters:
      property - Name of the property
      value - String
      negated - returns true if "NOT MATCHES" was used
    • comparison

      public void comparison(int type, String propertyName, String propertyValue, boolean negated)
      Description copied from interface: QueryHelper.WalkerCallback
      One of EQUALS LESSTHAN GREATERTHAN LESSTHANOREQUALS GREATERTHANOREQUALS;
      Specified by:
      comparison in interface QueryHelper.WalkerCallback
      Overrides:
      comparison in class QueryHelper.WalkerCallbackAdapter
    • getProperty

      public String getProperty(String propertyName, int type)
    • getProperty

      public <T> T getProperty(String propertyName, int type, Class<T> returnType)
      Get the property value, converted to the requested type.
      Parameters:
      propertyName - name of the parameter
      type - int
      returnType - type of object to return
      Returns:
      the converted parameter value. Null, if the property has no value.
      Throws:
      IllegalArgumentException - when no conversion for the given returnType is available or if returnType is null.
      InvalidArgumentException - when conversion to the given type was not possible due to an error while converting
    • and

      public void and()
      Description copied from interface: QueryHelper.WalkerCallback
      Called any time an AND is encountered.
      Specified by:
      and in interface QueryHelper.WalkerCallback
      Overrides:
      and in class QueryHelper.WalkerCallbackAdapter
    • processVariable

      protected void processVariable(String propertyName, String propertyValue, int type)
    • handleUnmatchedComparison

      protected boolean handleUnmatchedComparison(int type, String propertyName, String propertyValue)
      Called when unsupported property is encountered or comparison operator other than equals.
      Returns:
      true, if the comparison is handles successfully. False, if an exception should be thrown because the comparison can't be handled.