Class InterpolatorStringLookup

    • Field Detail

      • INSTANCE

        static final AbstractStringLookup INSTANCE
        Defines the singleton for this class.
        Since:
        1.6
      • PREFIX_SEPARATOR

        private static final char PREFIX_SEPARATOR
        Constant for the prefix separator.
        See Also:
        Constant Field Values
      • defaultStringLookup

        private final StringLookup defaultStringLookup
        The default string lookup.
      • stringLookupMap

        private final java.util.Map<java.lang.String,​StringLookup> stringLookupMap
        The map of String lookups keyed by prefix.
    • Constructor Detail

      • InterpolatorStringLookup

        InterpolatorStringLookup()
        Creates an instance using only lookups that work without initial properties and are stateless.

        Uses the default lookups.

      • InterpolatorStringLookup

        InterpolatorStringLookup​(java.util.Map<java.lang.String,​StringLookup> stringLookupMap,
                                 StringLookup defaultStringLookup,
                                 boolean addDefaultLookups)
        Creates a fully customized instance.
        Parameters:
        stringLookupMap - the map of string lookups.
        defaultStringLookup - the default string lookup.
        addDefaultLookups - whether the default lookups should be used.
      • InterpolatorStringLookup

        InterpolatorStringLookup​(java.util.Map<java.lang.String,​V> defaultMap)
        Creates an instance using only lookups that work without initial properties and are stateless.

        Uses the default lookups.

        Type Parameters:
        V - the map's value type.
        Parameters:
        defaultMap - the default map for string lookups.
      • InterpolatorStringLookup

        InterpolatorStringLookup​(StringLookup defaultStringLookup)
        Creates an instance with the given lookup.
        Parameters:
        defaultStringLookup - the default lookup.
    • Method Detail

      • toKey

        static java.lang.String toKey​(java.lang.String key)
      • getStringLookupMap

        public java.util.Map<java.lang.String,​StringLookup> getStringLookupMap()
        Gets the lookup map.
        Returns:
        The lookup map.
      • lookup

        public java.lang.String lookup​(java.lang.String var)
        Resolves the specified variable. This implementation will try to extract a variable prefix from the given variable name (the first colon (':') is used as prefix separator). It then passes the name of the variable with the prefix stripped to the lookup object registered for this prefix. If no prefix can be found or if the associated lookup object cannot resolve this variable, the default lookup object will be used.
        Parameters:
        var - the name of the variable whose value is to be looked up
        Returns:
        The value of this variable or null if it cannot be resolved
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object