Class 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.

    • 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,
        Perform the substitution in this, by looking up in the given properties, and returns the resulting string
        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
      • stringValue

        public java.lang.String stringValue()
      • hashCode

        public int hashCode()
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Returns this string in original (unsubstituted) form
        toString in class java.lang.Object