Class SubstituteString

java.lang.Object
com.yahoo.search.query.profile.SubstituteString

public class SubstituteString extends Object
A string which contains one or more elements of the form %{name}, where these occurrences are to be replaced by a query profile lookup on name.

This objects does the analysis on creation and provides a (reasonably) fast method of performing the actual substitution (at lookup time).

This is a value object. Lookups in this are thread safe.

Author:
bratseth
  • Constructor Details

  • Method Details

    • create

      public static SubstituteString create(String value)
      Returns a new SubstituteString if the given string contains substitutions, null otherwise.
    • hasRelative

      public boolean hasRelative()
      Returns whether this has at least one relative component
    • substitute

      public Object substitute(Map<String,String> context, com.yahoo.processing.request.Properties substitution)
      Perform the substitution in this, by looking up in the given properties, and returns the resulting string
      Parameters:
      context - the content which is used to resolve profile variants when looking up substitution values
      substitution - the properties in which values to be substituted are looked up
    • components

      public List<SubstituteString.Component> components()
    • stringValue

      public String stringValue()
    • hashCode

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

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Returns this string in original (unsubstituted) form
      Overrides:
      toString in class Object