|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2020 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -61,6 +61,9 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
|
61 | 61 | @Nullable
|
62 | 62 | private String valueSeparator = SystemPropertyUtils.VALUE_SEPARATOR;
|
63 | 63 |
|
| 64 | + @Nullable |
| 65 | + private Character escapeCharacter = SystemPropertyUtils.ESCAPE_CHARACTER; |
| 66 | + |
64 | 67 | private final Set<String> requiredProperties = new LinkedHashSet<>();
|
65 | 68 |
|
66 | 69 |
|
@@ -121,6 +124,19 @@ public void setValueSeparator(@Nullable String valueSeparator) {
|
121 | 124 | this.valueSeparator = valueSeparator;
|
122 | 125 | }
|
123 | 126 |
|
| 127 | + /** |
| 128 | + * Specify the escape character to use to ignore placeholder prefix |
| 129 | + * or value separator, or {@code null} if no escaping should take |
| 130 | + * place. |
| 131 | + * <p>The default is "\". |
| 132 | + * @since 6.2 |
| 133 | + * @see org.springframework.util.SystemPropertyUtils#ESCAPE_CHARACTER |
| 134 | + */ |
| 135 | + @Override |
| 136 | + public void setEscapeCharacter(@Nullable Character escapeCharacter) { |
| 137 | + this.escapeCharacter = escapeCharacter; |
| 138 | + } |
| 139 | + |
124 | 140 | /**
|
125 | 141 | * Set whether to throw an exception when encountering an unresolvable placeholder
|
126 | 142 | * nested within the value of a given property. A {@code false} value indicates strict
|
@@ -232,7 +248,7 @@ protected String resolveNestedPlaceholders(String value) {
|
232 | 248 |
|
233 | 249 | private PropertyPlaceholderHelper createPlaceholderHelper(boolean ignoreUnresolvablePlaceholders) {
|
234 | 250 | return new PropertyPlaceholderHelper(this.placeholderPrefix, this.placeholderSuffix,
|
235 |
| - this.valueSeparator, ignoreUnresolvablePlaceholders); |
| 251 | + this.valueSeparator, ignoreUnresolvablePlaceholders, this.escapeCharacter); |
236 | 252 | }
|
237 | 253 |
|
238 | 254 | private String doResolvePlaceholders(String text, PropertyPlaceholderHelper helper) {
|
|
0 commit comments