Package com.yahoo.search.query.profile
Class SubstituteString
- java.lang.Object
-
- com.yahoo.search.query.profile.SubstituteString
-
public class SubstituteString extends java.lang.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SubstituteString.Component
static class
SubstituteString.PropertyComponent
static class
SubstituteString.RelativePropertyComponent
A component where the value should be looked up in the profile containing the substitution field rather than globallystatic class
SubstituteString.StringComponent
-
Constructor Summary
Constructors Constructor Description SubstituteString(java.util.List<SubstituteString.Component> components, java.lang.String stringValue)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<SubstituteString.Component>
components()
static SubstituteString
create(java.lang.String value)
Returns a new SubstituteString if the given string contains substitutions, null otherwise.boolean
equals(java.lang.Object other)
int
hashCode()
boolean
hasRelative()
Returns whether this has at least one relative componentjava.lang.String
stringValue()
java.lang.String
substitute(java.util.Map<java.lang.String,java.lang.String> context, com.yahoo.processing.request.Properties substitution)
Perform the substitution in this, by looking up in the given properties, and returns the resulting stringjava.lang.String
toString()
Returns this string in original (unsubstituted) form
-
-
-
Constructor Detail
-
SubstituteString
public SubstituteString(java.util.List<SubstituteString.Component> components, java.lang.String stringValue)
-
-
Method Detail
-
create
public static SubstituteString create(java.lang.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 java.lang.String substitute(java.util.Map<java.lang.String,java.lang.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 valuessubstitution
- the properties in which values to be substituted are looked up
-
components
public java.util.List<SubstituteString.Component> components()
-
stringValue
public java.lang.String stringValue()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
Returns this string in original (unsubstituted) form- Overrides:
toString
in classjava.lang.Object
-
-