/** * Creates a new instance and initializes it. * * @param variableResolver the variable resolver, may be null * @param prefix the prefix for variables, not null * @param suffix the suffix for variables, not null * @param escape the escape character * @param valueDelimiter the variable default value delimiter string, may be null * @throws IllegalArgumentException if the prefix or suffix is null * @since 3.2 */ public StrSubstitutor(final StrLookup<?> variableResolver, final String prefix, final String suffix, final char escape, final String valueDelimiter) { this.setVariableResolver(variableResolver); this.setVariablePrefix(prefix); this.setVariableSuffix(suffix); this.setEscapeChar(escape); this.setValueDelimiter(valueDelimiter); }
/** * Tests get set. */ @Test public void testGetSetPrefix() { final StrSubstitutor sub = new StrSubstitutor(); assertTrue(sub.getVariablePrefixMatcher() instanceof StrMatcher.StringMatcher); sub.setVariablePrefix('<'); assertTrue(sub.getVariablePrefixMatcher() instanceof StrMatcher.CharMatcher); sub.setVariablePrefix("<<"); assertTrue(sub.getVariablePrefixMatcher() instanceof StrMatcher.StringMatcher); try { sub.setVariablePrefix(null); fail(); } catch (final IllegalArgumentException ex) { // expected } assertTrue(sub.getVariablePrefixMatcher() instanceof StrMatcher.StringMatcher); final StrMatcher matcher = StrMatcher.commaMatcher(); sub.setVariablePrefixMatcher(matcher); assertSame(matcher, sub.getVariablePrefixMatcher()); try { sub.setVariablePrefixMatcher(null); fail(); } catch (final IllegalArgumentException ex) { // expected } assertSame(matcher, sub.getVariablePrefixMatcher()); }
/** * Creates a new instance and initializes it. * * @param variableResolver the variable resolver, may be null * @param prefix the prefix for variables, not null * @param suffix the suffix for variables, not null * @param escape the escape character * @throws IllegalArgumentException if the prefix or suffix is null */ public StrSubstitutor(final StrLookup<?> variableResolver, final String prefix, final String suffix, final char escape) { this.setVariableResolver(variableResolver); this.setVariablePrefix(prefix); this.setVariableSuffix(suffix); this.setEscapeChar(escape); this.setValueDelimiterMatcher(DEFAULT_VALUE_DELIMITER); }
public static StrSubstitutor createStrSubstitutor(String prefix, String suffix, StrLookup<String> lookup) { StrSubstitutor substitutor = new StrSubstitutor(); substitutor.setEnableSubstitutionInVariables(true); substitutor.setVariablePrefix(prefix); substitutor.setVariableSuffix(suffix); substitutor.setVariableResolver(lookup); return substitutor; }
/** * Creates a new instance and initializes it. * * @param variableResolver the variable resolver, may be null * @param prefix the prefix for variables, not null * @param suffix the suffix for variables, not null * @param escape the escape character * @throws IllegalArgumentException if the prefix or suffix is null */ public StrSubstitutor(final StrLookup<?> variableResolver, final String prefix, final String suffix, final char escape) { this.setVariableResolver(variableResolver); this.setVariablePrefix(prefix); this.setVariableSuffix(suffix); this.setEscapeChar(escape); this.setValueDelimiterMatcher(DEFAULT_VALUE_DELIMITER); }
/** * Creates a new instance and initializes it. * * @param variableResolver the variable resolver, may be null * @param prefix the prefix for variables, not null * @param suffix the suffix for variables, not null * @param escape the escape character * @param valueDelimiter the variable default value delimiter string, may be null * @throws IllegalArgumentException if the prefix or suffix is null * @since 3.2 */ public StrSubstitutor(final StrLookup<?> variableResolver, final String prefix, final String suffix, final char escape, final String valueDelimiter) { this.setVariableResolver(variableResolver); this.setVariablePrefix(prefix); this.setVariableSuffix(suffix); this.setEscapeChar(escape); this.setValueDelimiter(valueDelimiter); }
/** * Creates a new instance and initializes it. * * @param variableResolver the variable resolver, may be null * @param prefix the prefix for variables, not null * @param suffix the suffix for variables, not null * @param escape the escape character * @throws IllegalArgumentException if the prefix or suffix is null */ public StrSubstitutor(final StrLookup<?> variableResolver, final String prefix, final String suffix, final char escape) { this.setVariableResolver(variableResolver); this.setVariablePrefix(prefix); this.setVariableSuffix(suffix); this.setEscapeChar(escape); this.setValueDelimiterMatcher(DEFAULT_VALUE_DELIMITER); }
/** * Creates a new instance and initializes it. * * @param variableResolver the variable resolver, may be null * @param prefix the prefix for variables, not null * @param suffix the suffix for variables, not null * @param escape the escape character * @throws IllegalArgumentException if the prefix or suffix is null */ public StrSubstitutor(final StrLookup<?> variableResolver, final String prefix, final String suffix, final char escape) { this.setVariableResolver(variableResolver); this.setVariablePrefix(prefix); this.setVariableSuffix(suffix); this.setEscapeChar(escape); this.setValueDelimiterMatcher(DEFAULT_VALUE_DELIMITER); }
/** * Creates a new instance and initializes it. * * @param variableResolver the variable resolver, may be null * @param prefix the prefix for variables, not null * @param suffix the suffix for variables, not null * @param escape the escape character * @param valueDelimiter the variable default value delimiter string, may be null * @throws IllegalArgumentException if the prefix or suffix is null * @since 3.2 */ public StrSubstitutor(final StrLookup<?> variableResolver, final String prefix, final String suffix, final char escape, final String valueDelimiter) { this.setVariableResolver(variableResolver); this.setVariablePrefix(prefix); this.setVariableSuffix(suffix); this.setEscapeChar(escape); this.setValueDelimiter(valueDelimiter); }
/** * Creates a new instance and initializes it. * * @param variableResolver the variable resolver, may be null * @param prefix the prefix for variables, not null * @param suffix the suffix for variables, not null * @param escape the escape character * @param valueDelimiter the variable default value delimiter string, may be null * @throws IllegalArgumentException if the prefix or suffix is null * @since 3.2 */ public StrSubstitutor(final StrLookup<?> variableResolver, final String prefix, final String suffix, final char escape, final String valueDelimiter) { this.setVariableResolver(variableResolver); this.setVariablePrefix(prefix); this.setVariableSuffix(suffix); this.setEscapeChar(escape); this.setValueDelimiter(valueDelimiter); }