/** * Sets the variable prefix to use. * <p> * The variable prefix is the character or characters that identify the * start of a variable. This method allows a single character prefix to * be easily set. * * @param prefix the prefix character to use * @return this, to enable chaining */ public StrSubstitutor setVariablePrefix(final char prefix) { return setVariablePrefixMatcher(StrMatcher.charMatcher(prefix)); }
/** * Sets the variable prefix to use. * <p> * The variable prefix is the character or characters that identify the * start of a variable. This method allows a string prefix to be easily set. * * @param prefix the prefix for variables, not null * @return this, to enable chaining * @throws IllegalArgumentException if the prefix is null */ public StrSubstitutor setVariablePrefix(final String prefix) { if (prefix == null) { throw new IllegalArgumentException("Variable prefix must not be null!"); } return setVariablePrefixMatcher(StrMatcher.stringMatcher(prefix)); }
/** * Creates a new instance and initializes it. * * @param variableResolver the variable resolver, may be null * @param prefixMatcher the prefix for variables, not null * @param suffixMatcher the suffix for variables, not null * @param escape the escape character * @param valueDelimiterMatcher the variable default value delimiter matcher, may be null * @throws IllegalArgumentException if the prefix or suffix is null * @since 3.2 */ public StrSubstitutor( final StrLookup<?> variableResolver, final StrMatcher prefixMatcher, final StrMatcher suffixMatcher, final char escape, final StrMatcher valueDelimiterMatcher) { this.setVariableResolver(variableResolver); this.setVariablePrefixMatcher(prefixMatcher); this.setVariableSuffixMatcher(suffixMatcher); this.setEscapeChar(escape); this.setValueDelimiterMatcher(valueDelimiterMatcher); }
/** * 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()); }
/** * Sets the variable prefix to use. * <p> * The variable prefix is the character or characters that identify the * start of a variable. This method allows a single character prefix to * be easily set. * * @param prefix the prefix character to use * @return this, to enable chaining */ public StrSubstitutor setVariablePrefix(final char prefix) { return setVariablePrefixMatcher(StrMatcher.charMatcher(prefix)); }
/** * Sets the variable prefix to use. * <p> * The variable prefix is the character or characters that identify the * start of a variable. This method allows a single character prefix to * be easily set. * * @param prefix the prefix character to use * @return this, to enable chaining */ public StrSubstitutor setVariablePrefix(final char prefix) { return setVariablePrefixMatcher(StrMatcher.charMatcher(prefix)); }
/** * Sets the variable prefix to use. * <p> * The variable prefix is the character or characters that identify the * start of a variable. This method allows a single character prefix to * be easily set. * * @param prefix the prefix character to use * @return this, to enable chaining */ public StrSubstitutor setVariablePrefix(final char prefix) { return setVariablePrefixMatcher(StrMatcher.charMatcher(prefix)); }
/** * Sets the variable prefix to use. * <p> * The variable prefix is the character or characters that identify the * start of a variable. This method allows a string prefix to be easily set. * * @param prefix the prefix for variables, not null * @return this, to enable chaining * @throws IllegalArgumentException if the prefix is null */ public StrSubstitutor setVariablePrefix(final String prefix) { if (prefix == null) { throw new IllegalArgumentException("Variable prefix must not be null!"); } return setVariablePrefixMatcher(StrMatcher.stringMatcher(prefix)); }
/** * Sets the variable prefix to use. * <p> * The variable prefix is the character or characters that identify the * start of a variable. This method allows a string prefix to be easily set. * * @param prefix the prefix for variables, not null * @return this, to enable chaining * @throws IllegalArgumentException if the prefix is null */ public StrSubstitutor setVariablePrefix(final String prefix) { if (prefix == null) { throw new IllegalArgumentException("Variable prefix must not be null!"); } return setVariablePrefixMatcher(StrMatcher.stringMatcher(prefix)); }
/** * Sets the variable prefix to use. * <p> * The variable prefix is the character or characters that identify the * start of a variable. This method allows a string prefix to be easily set. * * @param prefix the prefix for variables, not null * @return this, to enable chaining * @throws IllegalArgumentException if the prefix is null */ public StrSubstitutor setVariablePrefix(final String prefix) { if (prefix == null) { throw new IllegalArgumentException("Variable prefix must not be null!"); } return setVariablePrefixMatcher(StrMatcher.stringMatcher(prefix)); }
/** * Creates a new instance and initializes it. * * @param variableResolver the variable resolver, may be null * @param prefixMatcher the prefix for variables, not null * @param suffixMatcher the suffix for variables, not null * @param escape the escape character * @param valueDelimiterMatcher the variable default value delimiter matcher, may be null * @throws IllegalArgumentException if the prefix or suffix is null * @since 3.2 */ public StrSubstitutor( final StrLookup<?> variableResolver, final StrMatcher prefixMatcher, final StrMatcher suffixMatcher, final char escape, final StrMatcher valueDelimiterMatcher) { this.setVariableResolver(variableResolver); this.setVariablePrefixMatcher(prefixMatcher); this.setVariableSuffixMatcher(suffixMatcher); this.setEscapeChar(escape); this.setValueDelimiterMatcher(valueDelimiterMatcher); }
/** * Creates a new instance and initializes it. * * @param variableResolver the variable resolver, may be null * @param prefixMatcher the prefix for variables, not null * @param suffixMatcher the suffix for variables, not null * @param escape the escape character * @param valueDelimiterMatcher the variable default value delimiter matcher, may be null * @throws IllegalArgumentException if the prefix or suffix is null * @since 3.2 */ public StrSubstitutor( final StrLookup<?> variableResolver, final StrMatcher prefixMatcher, final StrMatcher suffixMatcher, final char escape, final StrMatcher valueDelimiterMatcher) { this.setVariableResolver(variableResolver); this.setVariablePrefixMatcher(prefixMatcher); this.setVariableSuffixMatcher(suffixMatcher); this.setEscapeChar(escape); this.setValueDelimiterMatcher(valueDelimiterMatcher); }
/** * Creates a new instance and initializes it. * * @param variableResolver the variable resolver, may be null * @param prefixMatcher the prefix for variables, not null * @param suffixMatcher the suffix for variables, not null * @param escape the escape character * @param valueDelimiterMatcher the variable default value delimiter matcher, may be null * @throws IllegalArgumentException if the prefix or suffix is null * @since 3.2 */ public StrSubstitutor( final StrLookup<?> variableResolver, final StrMatcher prefixMatcher, final StrMatcher suffixMatcher, final char escape, final StrMatcher valueDelimiterMatcher) { this.setVariableResolver(variableResolver); this.setVariablePrefixMatcher(prefixMatcher); this.setVariableSuffixMatcher(suffixMatcher); this.setEscapeChar(escape); this.setValueDelimiterMatcher(valueDelimiterMatcher); }