code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
@Override public void setPlaceholderSuffix(String placeholderSuffix) { this.placeholderSuffix = placeholderSuffix; }
Set the suffix that placeholders replaced by this resolver must end with. <p> The default is "}". @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_SUFFIX
setPlaceholderSuffix
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@Override public void setValueSeparator(String valueSeparator) { this.valueSeparator = valueSeparator; }
Specify the separating character between the placeholders replaced by this resolver and their associated default value, or {@code null} if no such special character should be processed as a value separator. <p> The default is ":". @see org.springframework.util.SystemPropertyUtils#VALUE_SEPARATOR
setValueSeparator
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@Override public void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) { this.ignoreUnresolvableNestedPlaceholders = ignoreUnresolvableNestedPlaceholders; }
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. A {@code false} value indicates strict resolution, i.e. that an exception will be thrown. A {@code true} value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form. <p> The default is {@code false}. @since 3.2
setIgnoreUnresolvableNestedPlaceholders
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@Override public void setRequiredProperties(String... requiredProperties) { this.requiredProperties.addAll(Arrays.asList(requiredProperties)); }
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. A {@code false} value indicates strict resolution, i.e. that an exception will be thrown. A {@code true} value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form. <p> The default is {@code false}. @since 3.2
setRequiredProperties
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@Override public void validateRequiredProperties() { MissingRequiredPropertiesException ex = new MissingRequiredPropertiesException(); for (String key : this.requiredProperties) { if (this.getProperty(key) == null) { ex.addMissingRequiredProperty(key); } } if (!ex.getMissingRequiredProperties().isEmpty()) { throw ex; } }
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. A {@code false} value indicates strict resolution, i.e. that an exception will be thrown. A {@code true} value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form. <p> The default is {@code false}. @since 3.2
validateRequiredProperties
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@Override public boolean containsProperty(String key) { return (getProperty(key) != null); }
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. A {@code false} value indicates strict resolution, i.e. that an exception will be thrown. A {@code true} value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form. <p> The default is {@code false}. @since 3.2
containsProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@Override public String getProperty(String key) { return getProperty(key, String.class); }
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. A {@code false} value indicates strict resolution, i.e. that an exception will be thrown. A {@code true} value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form. <p> The default is {@code false}. @since 3.2
getProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@Override public String getProperty(String key, String defaultValue) { String value = getProperty(key); return (value != null ? value : defaultValue); }
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. A {@code false} value indicates strict resolution, i.e. that an exception will be thrown. A {@code true} value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form. <p> The default is {@code false}. @since 3.2
getProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@Override public <T> T getProperty(String key, Class<T> targetType, T defaultValue) { T value = getProperty(key, targetType); return (value != null ? value : defaultValue); }
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. A {@code false} value indicates strict resolution, i.e. that an exception will be thrown. A {@code true} value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form. <p> The default is {@code false}. @since 3.2
getProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@Override public String getRequiredProperty(String key) throws IllegalStateException { String value = getProperty(key); if (value == null) { throw new IllegalStateException("Required key '" + key + "' not found"); } return value; }
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. A {@code false} value indicates strict resolution, i.e. that an exception will be thrown. A {@code true} value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form. <p> The default is {@code false}. @since 3.2
getRequiredProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@Override public <T> T getRequiredProperty(String key, Class<T> valueType) throws IllegalStateException { T value = getProperty(key, valueType); if (value == null) { throw new IllegalStateException("Required key '" + key + "' not found"); } return value; }
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. A {@code false} value indicates strict resolution, i.e. that an exception will be thrown. A {@code true} value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form. <p> The default is {@code false}. @since 3.2
getRequiredProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@Override public String resolvePlaceholders(String text) { if (this.nonStrictHelper == null) { this.nonStrictHelper = createPlaceholderHelper(true); } return doResolvePlaceholders(text, this.nonStrictHelper); }
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. A {@code false} value indicates strict resolution, i.e. that an exception will be thrown. A {@code true} value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form. <p> The default is {@code false}. @since 3.2
resolvePlaceholders
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@Override public String resolveRequiredPlaceholders(String text) throws IllegalArgumentException { if (this.strictHelper == null) { this.strictHelper = createPlaceholderHelper(false); } return doResolvePlaceholders(text, this.strictHelper); }
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. A {@code false} value indicates strict resolution, i.e. that an exception will be thrown. A {@code true} value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form. <p> The default is {@code false}. @since 3.2
resolveRequiredPlaceholders
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
protected String resolveNestedPlaceholders(String value) { return (this.ignoreUnresolvableNestedPlaceholders ? resolvePlaceholders(value) : resolveRequiredPlaceholders(value)); }
Resolve placeholders within the given string, deferring to the value of {@link #setIgnoreUnresolvableNestedPlaceholders} to determine whether any unresolvable placeholders should raise an exception or be ignored. <p> Invoked from {@link #getProperty} and its variants, implicitly resolving nested placeholders. In contrast, {@link #resolvePlaceholders} and {@link #resolveRequiredPlaceholders} do <i>not</i> delegate to this method but rather perform their own handling of unresolvable placeholders, as specified by each of those methods. @since 3.2 @see #setIgnoreUnresolvableNestedPlaceholders
resolveNestedPlaceholders
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
private PropertyPlaceholderHelper createPlaceholderHelper(boolean ignoreUnresolvablePlaceholders) { return new PropertyPlaceholderHelper(this.placeholderPrefix, this.placeholderSuffix, this.valueSeparator, ignoreUnresolvablePlaceholders); }
Resolve placeholders within the given string, deferring to the value of {@link #setIgnoreUnresolvableNestedPlaceholders} to determine whether any unresolvable placeholders should raise an exception or be ignored. <p> Invoked from {@link #getProperty} and its variants, implicitly resolving nested placeholders. In contrast, {@link #resolvePlaceholders} and {@link #resolveRequiredPlaceholders} do <i>not</i> delegate to this method but rather perform their own handling of unresolvable placeholders, as specified by each of those methods. @since 3.2 @see #setIgnoreUnresolvableNestedPlaceholders
createPlaceholderHelper
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
private String doResolvePlaceholders(String text, PropertyPlaceholderHelper helper) { return helper.replacePlaceholders(text, new PropertyPlaceholderHelper.PlaceholderResolver() { public String resolvePlaceholder(String placeholderName) { return getPropertyAsRawString(placeholderName); } }); }
Resolve placeholders within the given string, deferring to the value of {@link #setIgnoreUnresolvableNestedPlaceholders} to determine whether any unresolvable placeholders should raise an exception or be ignored. <p> Invoked from {@link #getProperty} and its variants, implicitly resolving nested placeholders. In contrast, {@link #resolvePlaceholders} and {@link #resolveRequiredPlaceholders} do <i>not</i> delegate to this method but rather perform their own handling of unresolvable placeholders, as specified by each of those methods. @since 3.2 @see #setIgnoreUnresolvableNestedPlaceholders
doResolvePlaceholders
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
public String resolvePlaceholder(String placeholderName) { return getPropertyAsRawString(placeholderName); }
Resolve placeholders within the given string, deferring to the value of {@link #setIgnoreUnresolvableNestedPlaceholders} to determine whether any unresolvable placeholders should raise an exception or be ignored. <p> Invoked from {@link #getProperty} and its variants, implicitly resolving nested placeholders. In contrast, {@link #resolvePlaceholders} and {@link #resolveRequiredPlaceholders} do <i>not</i> delegate to this method but rather perform their own handling of unresolvable placeholders, as specified by each of those methods. @since 3.2 @see #setIgnoreUnresolvableNestedPlaceholders
resolvePlaceholder
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/AbstractPropertyResolver.java
Apache-2.0
@SuppressWarnings({ "rawtypes", "unchecked" }) public Map<String, Object> getSystemProperties() { try { return (Map) System.getProperties(); } catch (AccessControlException ex) { return (Map) new ReadOnlySystemAttributesMap() { @Override protected String getSystemAttribute(String attributeName) { try { return System.getProperty(attributeName); } catch (AccessControlException ex) { return null; } } }; } }
Add the given property source object with lowest precedence.
getSystemProperties
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@Override protected String getSystemAttribute(String attributeName) { try { return System.getProperty(attributeName); } catch (AccessControlException ex) { return null; } }
Add the given property source object with lowest precedence.
getSystemAttribute
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@SuppressWarnings({ "rawtypes", "unchecked" }) public Map<String, Object> getSystemEnvironment() { try { return (Map) System.getenv(); } catch (AccessControlException ex) { return (Map) new ReadOnlySystemAttributesMap() { @Override protected String getSystemAttribute(String attributeName) { try { return System.getenv(attributeName); } catch (AccessControlException ex) { return null; } } }; } }
Add the given property source object with lowest precedence.
getSystemEnvironment
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@Override protected String getSystemAttribute(String attributeName) { try { return System.getenv(attributeName); } catch (AccessControlException ex) { return null; } }
Add the given property source object with lowest precedence.
getSystemAttribute
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@Override public boolean containsProperty(String key) { return this.propertyResolver.containsProperty(key); }
Add the given property source object with lowest precedence.
containsProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@Override public String getProperty(String key) { return this.propertyResolver.getProperty(key); }
Add the given property source object with lowest precedence.
getProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@Override public String getProperty(String key, String defaultValue) { return this.propertyResolver.getProperty(key, defaultValue); }
Add the given property source object with lowest precedence.
getProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@Override public <T> T getProperty(String key, Class<T> targetType) { return this.propertyResolver.getProperty(key, targetType); }
Add the given property source object with lowest precedence.
getProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@Override public <T> T getProperty(String key, Class<T> targetType, T defaultValue) { return this.propertyResolver.getProperty(key, targetType, defaultValue); }
Add the given property source object with lowest precedence.
getProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@Override public String getRequiredProperty(String key) throws IllegalStateException { return this.propertyResolver.getRequiredProperty(key); }
Add the given property source object with lowest precedence.
getRequiredProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@Override public <T> T getRequiredProperty(String key, Class<T> targetType) throws IllegalStateException { return this.propertyResolver.getRequiredProperty(key, targetType); }
Add the given property source object with lowest precedence.
getRequiredProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@Override public String resolvePlaceholders(String text) { return this.propertyResolver.resolvePlaceholders(text); }
Add the given property source object with lowest precedence.
resolvePlaceholders
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@Override public String resolveRequiredPlaceholders(String text) throws IllegalArgumentException { return this.propertyResolver.resolveRequiredPlaceholders(text); }
Add the given property source object with lowest precedence.
resolveRequiredPlaceholders
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ArthasEnvironment.java
Apache-2.0
@Override public boolean containsProperty(String name) { String[] propertyNames = getPropertyNames(); if (propertyNames == null) { return false; } for (String temp : propertyNames) { if (temp.equals(name)) { return true; } } return false; }
Return whether this {@code PropertySource} contains a property with the given name. <p> This implementation checks for the presence of the given name within the {@link #getPropertyNames()} array. @param name the name of the property to find
containsProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/EnumerablePropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/EnumerablePropertySource.java
Apache-2.0
@Override public Object getProperty(String name) { return this.source.get(name); }
{@link PropertySource} that reads keys and values from a {@code Map} object. @author Chris Beams @author Juergen Hoeller @since 3.1 @see PropertiesPropertySource
getProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MapPropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MapPropertySource.java
Apache-2.0
@Override public boolean containsProperty(String name) { return this.source.containsKey(name); }
{@link PropertySource} that reads keys and values from a {@code Map} object. @author Chris Beams @author Juergen Hoeller @since 3.1 @see PropertiesPropertySource
containsProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MapPropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MapPropertySource.java
Apache-2.0
@Override public String[] getPropertyNames() { return this.source.keySet().toArray(new String[0]); }
{@link PropertySource} that reads keys and values from a {@code Map} object. @author Chris Beams @author Juergen Hoeller @since 3.1 @see PropertiesPropertySource
getPropertyNames
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MapPropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MapPropertySource.java
Apache-2.0
@Override public String getMessage() { return "The following properties were declared as required but could not be resolved: " + getMissingRequiredProperties(); }
Exception thrown when required properties are not found. @author Chris Beams @since 3.1 @see ConfigurablePropertyResolver#setRequiredProperties(String...) @see ConfigurablePropertyResolver#validateRequiredProperties() @see org.springframework.context.support.AbstractApplicationContext#prepareRefresh()
getMessage
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MissingRequiredPropertiesException.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MissingRequiredPropertiesException.java
Apache-2.0
public Set<String> getMissingRequiredProperties() { return this.missingRequiredProperties; }
Return the set of properties marked as required but not present upon validation. @see ConfigurablePropertyResolver#setRequiredProperties(String...) @see ConfigurablePropertyResolver#validateRequiredProperties()
getMissingRequiredProperties
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MissingRequiredPropertiesException.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MissingRequiredPropertiesException.java
Apache-2.0
public boolean contains(String name) { return this.propertySourceList.contains(PropertySource.named(name)); }
Create a new {@code MutablePropertySources} from the given propertySources object, preserving the original order of contained {@code PropertySource} objects.
contains
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
public PropertySource<?> get(String name) { int index = this.propertySourceList.indexOf(PropertySource.named(name)); return index == -1 ? null : this.propertySourceList.get(index); }
Create a new {@code MutablePropertySources} from the given propertySources object, preserving the original order of contained {@code PropertySource} objects.
get
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
public Iterator<PropertySource<?>> iterator() { return this.propertySourceList.iterator(); }
Create a new {@code MutablePropertySources} from the given propertySources object, preserving the original order of contained {@code PropertySource} objects.
iterator
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
public void addFirst(PropertySource<?> propertySource) { // if (logger.isDebugEnabled()) { // logger.debug(String.format("Adding [%s] PropertySource with highest search precedence", // propertySource.getName())); // } removeIfPresent(propertySource); this.propertySourceList.addFirst(propertySource); }
Add the given property source object with highest precedence.
addFirst
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
public void addLast(PropertySource<?> propertySource) { // if (logger.isDebugEnabled()) { // logger.debug(String.format("Adding [%s] PropertySource with lowest search precedence", // propertySource.getName())); // } removeIfPresent(propertySource); this.propertySourceList.addLast(propertySource); }
Add the given property source object with lowest precedence.
addLast
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
public void addBefore(String relativePropertySourceName, PropertySource<?> propertySource) { // if (logger.isDebugEnabled()) { // logger.debug(String.format("Adding [%s] PropertySource with search precedence immediately higher than [%s]", // propertySource.getName(), relativePropertySourceName)); // } assertLegalRelativeAddition(relativePropertySourceName, propertySource); removeIfPresent(propertySource); int index = assertPresentAndGetIndex(relativePropertySourceName); addAtIndex(index, propertySource); }
Add the given property source object with precedence immediately higher than the named relative property source.
addBefore
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
public void addAfter(String relativePropertySourceName, PropertySource<?> propertySource) { // if (logger.isDebugEnabled()) { // logger.debug(String.format("Adding [%s] PropertySource with search precedence immediately lower than [%s]", // propertySource.getName(), relativePropertySourceName)); // } assertLegalRelativeAddition(relativePropertySourceName, propertySource); removeIfPresent(propertySource); int index = assertPresentAndGetIndex(relativePropertySourceName); addAtIndex(index + 1, propertySource); }
Add the given property source object with precedence immediately lower than the named relative property source.
addAfter
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
public int precedenceOf(PropertySource<?> propertySource) { return this.propertySourceList.indexOf(propertySource); }
Return the precedence of the given property source, {@code -1} if not found.
precedenceOf
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
public PropertySource<?> remove(String name) { // if (logger.isDebugEnabled()) { // logger.debug(String.format("Removing [%s] PropertySource", name)); // } int index = this.propertySourceList.indexOf(PropertySource.named(name)); return index == -1 ? null : this.propertySourceList.remove(index); }
Remove and return the property source with the given name, {@code null} if not found. @param name the name of the property source to find and remove
remove
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
public void replace(String name, PropertySource<?> propertySource) { // if (logger.isDebugEnabled()) { // logger.debug(String.format("Replacing [%s] PropertySource with [%s]", // name, propertySource.getName())); // } int index = assertPresentAndGetIndex(name); this.propertySourceList.set(index, propertySource); }
Replace the property source with the given name with the given property source object. @param name the name of the property source to find and replace @param propertySource the replacement property source @throws IllegalArgumentException if no property source with the given name is present @see #contains
replace
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
public int size() { return this.propertySourceList.size(); }
Return the number of {@link PropertySource} objects contained.
size
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
@Override public String toString() { String[] names = new String[this.size()]; for (int i = 0; i < size(); i++) { names[i] = this.propertySourceList.get(i).getName(); } return String.format("[%s]", arrayToCommaDelimitedString(names)); }
Return the number of {@link PropertySource} objects contained.
toString
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
protected void assertLegalRelativeAddition(String relativePropertySourceName, PropertySource<?> propertySource) { // String newPropertySourceName = propertySource.getName(); // Assert.isTrue(!relativePropertySourceName.equals(newPropertySourceName), // String.format(ILLEGAL_RELATIVE_ADDITION_MESSAGE, newPropertySourceName)); }
Ensure that the given property source is not being added relative to itself.
assertLegalRelativeAddition
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
private void addAtIndex(int index, PropertySource<?> propertySource) { removeIfPresent(propertySource); this.propertySourceList.add(index, propertySource); }
Add the given property source at a particular index in the list.
addAtIndex
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
private int assertPresentAndGetIndex(String name) { int index = this.propertySourceList.indexOf(PropertySource.named(name)); // Assert.isTrue(index >= 0, String.format(NON_EXISTENT_PROPERTY_SOURCE_MESSAGE, name)); return index; }
Assert that the named property source is present and return its index. @param name the {@linkplain PropertySource#getName() name of the property source} to find @throws IllegalArgumentException if the named property source is not present
assertPresentAndGetIndex
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
private static String nullSafeToString(Object obj) { if (obj == null) { return "null"; } if (obj instanceof String) { return (String) obj; } if (obj instanceof Object[]) { return nullSafeToString((Object[]) obj); } if (obj instanceof boolean[]) { return nullSafeToString((boolean[]) obj); } if (obj instanceof byte[]) { return nullSafeToString((byte[]) obj); } if (obj instanceof char[]) { return nullSafeToString((char[]) obj); } if (obj instanceof double[]) { return nullSafeToString((double[]) obj); } if (obj instanceof float[]) { return nullSafeToString((float[]) obj); } if (obj instanceof int[]) { return nullSafeToString((int[]) obj); } if (obj instanceof long[]) { return nullSafeToString((long[]) obj); } if (obj instanceof short[]) { return nullSafeToString((short[]) obj); } String str = obj.toString(); return (str != null ? str : ""); }
Return a String representation of the specified Object. <p> Builds a String representation of the contents in case of an array. Returns {@code "null"} if {@code obj} is {@code null}. @param obj the object to build a String representation for @return a String representation of {@code obj}
nullSafeToString
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/MutablePropertySources.java
Apache-2.0
@Override public String[] getPropertyNames() { synchronized (this.source) { return super.getPropertyNames(); } }
{@link PropertySource} implementation that extracts properties from a {@link java.util.Properties} object. <p> Note that because a {@code Properties} object is technically an {@code <Object, Object>} {@link java.util.Hashtable Hashtable}, one may contain non-{@code String} keys or values. This implementation, however is restricted to accessing only {@code String}-based keys and values, in the same fashion as {@link Properties#getProperty} and {@link Properties#setProperty}. @author Chris Beams @author Juergen Hoeller @since 3.1
getPropertyNames
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertiesPropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertiesPropertySource.java
Apache-2.0
public String replacePlaceholders(String value, final Properties properties) { return replacePlaceholders(value, new PlaceholderResolver() { public String resolvePlaceholder(String placeholderName) { return properties.getProperty(placeholderName); } }); }
Replaces all placeholders of format {@code ${name}} with the corresponding property from the supplied {@link Properties}. @param value the value containing the placeholders to be replaced @param properties the {@code Properties} to use for replacement @return the supplied value with placeholders replaced inline
replacePlaceholders
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertyPlaceholderHelper.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertyPlaceholderHelper.java
Apache-2.0
public String resolvePlaceholder(String placeholderName) { return properties.getProperty(placeholderName); }
Replaces all placeholders of format {@code ${name}} with the corresponding property from the supplied {@link Properties}. @param value the value containing the placeholders to be replaced @param properties the {@code Properties} to use for replacement @return the supplied value with placeholders replaced inline
resolvePlaceholder
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertyPlaceholderHelper.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertyPlaceholderHelper.java
Apache-2.0
public String replacePlaceholders(String value, PlaceholderResolver placeholderResolver) { return parseStringValue(value, placeholderResolver, null); }
Replaces all placeholders of format {@code ${name}} with the value returned from the supplied {@link PlaceholderResolver}. @param value the value containing the placeholders to be replaced @param placeholderResolver the {@code PlaceholderResolver} to use for replacement @return the supplied value with placeholders replaced inline
replacePlaceholders
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertyPlaceholderHelper.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertyPlaceholderHelper.java
Apache-2.0
protected String parseStringValue(String value, PlaceholderResolver placeholderResolver, Set<String> visitedPlaceholders) { int startIndex = value.indexOf(this.placeholderPrefix); if (startIndex == -1) { return value; } StringBuilder result = new StringBuilder(value); while (startIndex != -1) { int endIndex = findPlaceholderEndIndex(result, startIndex); if (endIndex != -1) { String placeholder = result.substring(startIndex + this.placeholderPrefix.length(), endIndex); String originalPlaceholder = placeholder; if (visitedPlaceholders == null) { visitedPlaceholders = new HashSet<String>(4); } if (!visitedPlaceholders.add(originalPlaceholder)) { throw new IllegalArgumentException( "Circular placeholder reference '" + originalPlaceholder + "' in property definitions"); } // Recursive invocation, parsing placeholders contained in the placeholder key. placeholder = parseStringValue(placeholder, placeholderResolver, visitedPlaceholders); // Now obtain the value for the fully resolved key... String propVal = placeholderResolver.resolvePlaceholder(placeholder); if (propVal == null && this.valueSeparator != null) { int separatorIndex = placeholder.indexOf(this.valueSeparator); if (separatorIndex != -1) { String actualPlaceholder = placeholder.substring(0, separatorIndex); String defaultValue = placeholder.substring(separatorIndex + this.valueSeparator.length()); propVal = placeholderResolver.resolvePlaceholder(actualPlaceholder); if (propVal == null) { propVal = defaultValue; } } } if (propVal != null) { // Recursive invocation, parsing placeholders contained in the // previously resolved placeholder value. propVal = parseStringValue(propVal, placeholderResolver, visitedPlaceholders); result.replace(startIndex, endIndex + this.placeholderSuffix.length(), propVal); startIndex = result.indexOf(this.placeholderPrefix, startIndex + propVal.length()); } else if (this.ignoreUnresolvablePlaceholders) { // Proceed with unprocessed value. startIndex = result.indexOf(this.placeholderPrefix, endIndex + this.placeholderSuffix.length()); } else { throw new IllegalArgumentException( "Could not resolve placeholder '" + placeholder + "'" + " in value \"" + value + "\""); } visitedPlaceholders.remove(originalPlaceholder); } else { startIndex = -1; } } return result.toString(); }
Replaces all placeholders of format {@code ${name}} with the value returned from the supplied {@link PlaceholderResolver}. @param value the value containing the placeholders to be replaced @param placeholderResolver the {@code PlaceholderResolver} to use for replacement @return the supplied value with placeholders replaced inline
parseStringValue
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertyPlaceholderHelper.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertyPlaceholderHelper.java
Apache-2.0
private int findPlaceholderEndIndex(CharSequence buf, int startIndex) { int index = startIndex + this.placeholderPrefix.length(); int withinNestedPlaceholder = 0; while (index < buf.length()) { if (substringMatch(buf, index, this.placeholderSuffix)) { if (withinNestedPlaceholder > 0) { withinNestedPlaceholder--; index = index + this.placeholderSuffix.length(); } else { return index; } } else if (substringMatch(buf, index, this.simplePrefix)) { withinNestedPlaceholder++; index = index + this.simplePrefix.length(); } else { index++; } } return -1; }
Replaces all placeholders of format {@code ${name}} with the value returned from the supplied {@link PlaceholderResolver}. @param value the value containing the placeholders to be replaced @param placeholderResolver the {@code PlaceholderResolver} to use for replacement @return the supplied value with placeholders replaced inline
findPlaceholderEndIndex
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertyPlaceholderHelper.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertyPlaceholderHelper.java
Apache-2.0
public static boolean substringMatch(CharSequence str, int index, CharSequence substring) { if (index + substring.length() > str.length()) { return false; } for (int i = 0; i < substring.length(); i++) { if (str.charAt(index + i) != substring.charAt(i)) { return false; } } return true; }
Test whether the given string matches the given substring at the given index. @param str the original string (or StringBuilder) @param index the index in the original string to start matching against @param substring the substring to match at the given index
substringMatch
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertyPlaceholderHelper.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertyPlaceholderHelper.java
Apache-2.0
public String getName() { return this.name; }
Return the name of this {@code PropertySource}.
getName
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
Apache-2.0
public T getSource() { return this.source; }
Return the underlying source object for this {@code PropertySource}.
getSource
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
Apache-2.0
public boolean containsProperty(String name) { return (getProperty(name) != null); }
Return whether this {@code PropertySource} contains the given name. <p> This implementation simply checks for a {@code null} return value from {@link #getProperty(String)}. Subclasses may wish to implement a more efficient algorithm if possible. @param name the property name to find
containsProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
Apache-2.0
@Override public boolean equals(Object other) { return (this == other || (other instanceof PropertySource && nullSafeEquals(this.name, ((PropertySource<?>) other).name))); }
This {@code PropertySource} object is equal to the given object if: <ul> <li>they are the same instance <li>the {@code name} properties for both objects are equal </ul> <p> No properties other than {@code name} are evaluated.
equals
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
Apache-2.0
@Override public int hashCode() { return this.name.hashCode(); }
Return a hash code derived from the {@code name} property of this {@code PropertySource} object.
hashCode
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
Apache-2.0
@Override public String toString() { return getClass().getSimpleName() + " {name='" + this.name + "'}"; }
Produce concise output (type and name) if the current log level does not include debug. If debug is enabled, produce verbose output including the hash code of the PropertySource instance and every name/value property pair. <p> This variable verbosity is useful as a property source such as system properties or environment variables may contain an arbitrary number of property pairs, potentially leading to difficult to read exception and log messages. @see Log#isDebugEnabled()
toString
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
Apache-2.0
public static PropertySource<?> named(String name) { return new ComparisonPropertySource(name); }
Return a {@code PropertySource} implementation intended for collection comparison purposes only. <p> Primarily for internal use, but given a collection of {@code PropertySource} objects, may be used as follows: <pre class="code"> { &#64;code List<PropertySource<?>> sources = new ArrayList<PropertySource<?>>(); sources.add(new MapPropertySource("sourceA", mapA)); sources.add(new MapPropertySource("sourceB", mapB)); assert sources.contains(PropertySource.named("sourceA")); assert sources.contains(PropertySource.named("sourceB")); assert !sources.contains(PropertySource.named("sourceC")); } </pre> The returned {@code PropertySource} will throw {@code UnsupportedOperationException} if any methods other than {@code equals(Object)}, {@code hashCode()}, and {@code toString()} are called. @param name the name of the comparison {@code PropertySource} to be created and returned.
named
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
Apache-2.0
public static boolean nullSafeEquals(Object o1, Object o2) { if (o1 == o2) { return true; } if (o1 == null || o2 == null) { return false; } if (o1.equals(o2)) { return true; } if (o1.getClass().isArray() && o2.getClass().isArray()) { return arrayEquals(o1, o2); } return false; }
Determine if the given objects are equal, returning {@code true} if both are {@code null} or {@code false} if only one is {@code null}. <p> Compares arrays with {@code Arrays.equals}, performing an equality check based on the array elements rather than the array reference. @param o1 first Object to compare @param o2 second Object to compare @return whether the given objects are equal @see Object#equals(Object) @see java.util.Arrays#equals
nullSafeEquals
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
Apache-2.0
private static boolean arrayEquals(Object o1, Object o2) { if (o1 instanceof Object[] && o2 instanceof Object[]) { return Arrays.equals((Object[]) o1, (Object[]) o2); } if (o1 instanceof boolean[] && o2 instanceof boolean[]) { return Arrays.equals((boolean[]) o1, (boolean[]) o2); } if (o1 instanceof byte[] && o2 instanceof byte[]) { return Arrays.equals((byte[]) o1, (byte[]) o2); } if (o1 instanceof char[] && o2 instanceof char[]) { return Arrays.equals((char[]) o1, (char[]) o2); } if (o1 instanceof double[] && o2 instanceof double[]) { return Arrays.equals((double[]) o1, (double[]) o2); } if (o1 instanceof float[] && o2 instanceof float[]) { return Arrays.equals((float[]) o1, (float[]) o2); } if (o1 instanceof int[] && o2 instanceof int[]) { return Arrays.equals((int[]) o1, (int[]) o2); } if (o1 instanceof long[] && o2 instanceof long[]) { return Arrays.equals((long[]) o1, (long[]) o2); } if (o1 instanceof short[] && o2 instanceof short[]) { return Arrays.equals((short[]) o1, (short[]) o2); } return false; }
Compare the given arrays with {@code Arrays.equals}, performing an equality check based on the array elements rather than the array reference. @param o1 first array to compare @param o2 second array to compare @return whether the given objects are equal @see #nullSafeEquals(Object, Object) @see java.util.Arrays#equals
arrayEquals
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySource.java
Apache-2.0
@Override public boolean containsProperty(String key) { if (this.propertySources != null) { for (PropertySource<?> propertySource : this.propertySources) { if (propertySource.containsProperty(key)) { return true; } } } return false; }
Create a new resolver against the given property sources. @param propertySources the set of {@link PropertySource} objects to use
containsProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySourcesPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySourcesPropertyResolver.java
Apache-2.0
@Override public String getProperty(String key) { return getProperty(key, String.class, true); }
Create a new resolver against the given property sources. @param propertySources the set of {@link PropertySource} objects to use
getProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySourcesPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySourcesPropertyResolver.java
Apache-2.0
@Override public <T> T getProperty(String key, Class<T> targetValueType) { return getProperty(key, targetValueType, true); }
Create a new resolver against the given property sources. @param propertySources the set of {@link PropertySource} objects to use
getProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySourcesPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySourcesPropertyResolver.java
Apache-2.0
@Override protected String getPropertyAsRawString(String key) { return getProperty(key, String.class, false); }
Create a new resolver against the given property sources. @param propertySources the set of {@link PropertySource} objects to use
getPropertyAsRawString
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySourcesPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySourcesPropertyResolver.java
Apache-2.0
protected <T> T getProperty(String key, Class<T> targetValueType, boolean resolveNestedPlaceholders) { if (this.propertySources != null) { for (PropertySource<?> propertySource : this.propertySources) { Object value; if ((value = propertySource.getProperty(key)) != null) { Class<?> valueType = value.getClass(); if (resolveNestedPlaceholders && value instanceof String) { value = resolveNestedPlaceholders((String) value); } if (!this.conversionService.canConvert(valueType, targetValueType)) { throw new IllegalArgumentException( String.format("Cannot convert value [%s] from source type [%s] to target type [%s]", value, valueType.getSimpleName(), targetValueType.getSimpleName())); } return this.conversionService.convert(value, targetValueType); } } } return null; }
Create a new resolver against the given property sources. @param propertySources the set of {@link PropertySource} objects to use
getProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySourcesPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySourcesPropertyResolver.java
Apache-2.0
protected void logKeyFound(String key, PropertySource<?> propertySource, Object value) { // if (logger.isDebugEnabled()) { // logger.debug("Found key '" + key + "' in PropertySource '" + propertySource.getName() + // "' with value of type " + value.getClass().getSimpleName()); // } }
Log the given key as found in the given {@link PropertySource}, resulting in the given value. <p> The default implementation writes a debug log message with key and source. As of 4.3.3, this does not log the value anymore in order to avoid accidental logging of sensitive settings. Subclasses may override this method to change the log level and/or log message, including the property's value if desired. @param key the key found @param propertySource the {@code PropertySource} that the key has been found in @param value the corresponding value @since 4.3.1
logKeyFound
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/PropertySourcesPropertyResolver.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/PropertySourcesPropertyResolver.java
Apache-2.0
@Override public boolean containsKey(Object key) { return (get(key) != null); }
Read-only {@code Map<String, String>} implementation that is backed by system properties or environment variables. <p> Used by {@link AbstractApplicationContext} when a {@link SecurityManager} prohibits access to {@link System#getProperties()} or {@link System#getenv()}. It is for this reason that the implementations of {@link #keySet()}, {@link #entrySet()}, and {@link #values()} always return empty even though {@link #get(Object)} may in fact return non-null if the current security manager allows access to individual keys. @author Arjen Poutsma @author Chris Beams @since 3.0
containsKey
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
Apache-2.0
@Override public String get(Object key) { if (!(key instanceof String)) { throw new IllegalArgumentException( "Type of key [" + key.getClass().getName() + "] must be java.lang.String"); } return getSystemAttribute((String) key); }
Returns the value to which the specified key is mapped, or {@code null} if this map contains no mapping for the key. @param key the name of the system attribute to retrieve @throws IllegalArgumentException if given key is non-String
get
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
Apache-2.0
@Override public boolean isEmpty() { return false; }
Returns the value to which the specified key is mapped, or {@code null} if this map contains no mapping for the key. @param key the name of the system attribute to retrieve @throws IllegalArgumentException if given key is non-String
isEmpty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
Apache-2.0
@Override public int size() { throw new UnsupportedOperationException(); }
Template method that returns the underlying system attribute. <p> Implementations typically call {@link System#getProperty(String)} or {@link System#getenv(String)} here.
size
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
Apache-2.0
@Override public String put(String key, String value) { throw new UnsupportedOperationException(); }
Template method that returns the underlying system attribute. <p> Implementations typically call {@link System#getProperty(String)} or {@link System#getenv(String)} here.
put
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
Apache-2.0
@Override public boolean containsValue(Object value) { throw new UnsupportedOperationException(); }
Template method that returns the underlying system attribute. <p> Implementations typically call {@link System#getProperty(String)} or {@link System#getenv(String)} here.
containsValue
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
Apache-2.0
@Override public String remove(Object key) { throw new UnsupportedOperationException(); }
Template method that returns the underlying system attribute. <p> Implementations typically call {@link System#getProperty(String)} or {@link System#getenv(String)} here.
remove
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
Apache-2.0
@Override public void clear() { throw new UnsupportedOperationException(); }
Template method that returns the underlying system attribute. <p> Implementations typically call {@link System#getProperty(String)} or {@link System#getenv(String)} here.
clear
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
Apache-2.0
@Override public Set<String> keySet() { return Collections.emptySet(); }
Template method that returns the underlying system attribute. <p> Implementations typically call {@link System#getProperty(String)} or {@link System#getenv(String)} here.
keySet
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
Apache-2.0
@Override public void putAll(Map<? extends String, ? extends String> map) { throw new UnsupportedOperationException(); }
Template method that returns the underlying system attribute. <p> Implementations typically call {@link System#getProperty(String)} or {@link System#getenv(String)} here.
putAll
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
Apache-2.0
@Override public Collection<String> values() { return Collections.emptySet(); }
Template method that returns the underlying system attribute. <p> Implementations typically call {@link System#getProperty(String)} or {@link System#getenv(String)} here.
values
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
Apache-2.0
@Override public Set<Entry<String, String>> entrySet() { return Collections.emptySet(); }
Template method that returns the underlying system attribute. <p> Implementations typically call {@link System#getProperty(String)} or {@link System#getenv(String)} here.
entrySet
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/ReadOnlySystemAttributesMap.java
Apache-2.0
@Override public boolean containsProperty(String name) { return (getProperty(name) != null); }
Return {@code true} if a property with the given name or any underscore/uppercase variant thereof exists in this property source.
containsProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/SystemEnvironmentPropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/SystemEnvironmentPropertySource.java
Apache-2.0
@Override public Object getProperty(String name) { String actualName = resolvePropertyName(name); return super.getProperty(actualName); }
This implementation returns {@code true} if a property with the given name or any underscore/uppercase variant thereof exists in this property source.
getProperty
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/SystemEnvironmentPropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/SystemEnvironmentPropertySource.java
Apache-2.0
protected final String resolvePropertyName(String name) { String resolvedName = checkPropertyName(name); if (resolvedName != null) { return resolvedName; } String uppercasedName = name.toUpperCase(); if (!name.equals(uppercasedName)) { resolvedName = checkPropertyName(uppercasedName); if (resolvedName != null) { return resolvedName; } } return name; }
Check to see if this property source contains a property with the given name, or any underscore / uppercase variation thereof. Return the resolved name if one is found or otherwise the original name. Never returns {@code null}.
resolvePropertyName
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/SystemEnvironmentPropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/SystemEnvironmentPropertySource.java
Apache-2.0
private String checkPropertyName(String name) { // Check name as-is if (containsKey(name)) { return name; } // Check name with just dots replaced String noDotName = name.replace('.', '_'); if (!name.equals(noDotName) && containsKey(noDotName)) { return noDotName; } // Check name with just hyphens replaced String noHyphenName = name.replace('-', '_'); if (!name.equals(noHyphenName) && containsKey(noHyphenName)) { return noHyphenName; } // Check name with dots and hyphens replaced String noDotNoHyphenName = noDotName.replace('-', '_'); if (!noDotName.equals(noDotNoHyphenName) && containsKey(noDotNoHyphenName)) { return noDotNoHyphenName; } // Give up return null; }
Check to see if this property source contains a property with the given name, or any underscore / uppercase variation thereof. Return the resolved name if one is found or otherwise the original name. Never returns {@code null}.
checkPropertyName
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/SystemEnvironmentPropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/SystemEnvironmentPropertySource.java
Apache-2.0
private boolean containsKey(String name) { return (isSecurityManagerPresent() ? this.source.keySet().contains(name) : this.source.containsKey(name)); }
Check to see if this property source contains a property with the given name, or any underscore / uppercase variation thereof. Return the resolved name if one is found or otherwise the original name. Never returns {@code null}.
containsKey
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/SystemEnvironmentPropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/SystemEnvironmentPropertySource.java
Apache-2.0
protected boolean isSecurityManagerPresent() { return (System.getSecurityManager() != null); }
Check to see if this property source contains a property with the given name, or any underscore / uppercase variation thereof. Return the resolved name if one is found or otherwise the original name. Never returns {@code null}.
isSecurityManagerPresent
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/SystemEnvironmentPropertySource.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/SystemEnvironmentPropertySource.java
Apache-2.0
public static String resolvePlaceholders(String text) { return resolvePlaceholders(text, false); }
Resolve {@code ${...}} placeholders in the given text, replacing them with corresponding system property values. @param text the String to resolve @return the resolved String @throws IllegalArgumentException if there is an unresolvable placeholder @see #PLACEHOLDER_PREFIX @see #PLACEHOLDER_SUFFIX
resolvePlaceholders
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/SystemPropertyUtils.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/SystemPropertyUtils.java
Apache-2.0
@Override public String resolvePlaceholder(String placeholderName) { try { String propVal = System.getProperty(placeholderName); if (propVal == null) { // Fall back to searching the system environment. propVal = System.getenv(placeholderName); } return propVal; } catch (Throwable ex) { System.err.println("Could not resolve placeholder '" + placeholderName + "' in [" + this.text + "] as system property: " + ex); return null; } }
PlaceholderResolver implementation that resolves against system properties and system environment variables.
resolvePlaceholder
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/SystemPropertyUtils.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/SystemPropertyUtils.java
Apache-2.0
public Class<?> getSourceType() { return this.sourceType; }
Create a new source-to-target pair. @param sourceType the source type @param targetType the target type
getSourceType
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/convert/ConvertiblePair.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/convert/ConvertiblePair.java
Apache-2.0
public Class<?> getTargetType() { return this.targetType; }
Create a new source-to-target pair. @param sourceType the source type @param targetType the target type
getTargetType
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/convert/ConvertiblePair.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/convert/ConvertiblePair.java
Apache-2.0
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || obj.getClass() != ConvertiblePair.class) { return false; } ConvertiblePair other = (ConvertiblePair) obj; return this.sourceType.equals(other.sourceType) && this.targetType.equals(other.targetType); }
Create a new source-to-target pair. @param sourceType the source type @param targetType the target type
equals
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/convert/ConvertiblePair.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/convert/ConvertiblePair.java
Apache-2.0
@Override public int hashCode() { return this.sourceType.hashCode() * 31 + this.targetType.hashCode(); }
Create a new source-to-target pair. @param sourceType the source type @param targetType the target type
hashCode
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/convert/ConvertiblePair.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/convert/ConvertiblePair.java
Apache-2.0
@Override public String toString() { return this.sourceType.getName() + " -> " + this.targetType.getName(); }
Create a new source-to-target pair. @param sourceType the source type @param targetType the target type
toString
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/convert/ConvertiblePair.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/convert/ConvertiblePair.java
Apache-2.0
public static <C> Class<C[]> arrayClass(Class<C> klass) { return (Class<C[]>) Array.newInstance(klass, 0).getClass(); }
Get an array class of the given class. @param klass to get an array class of @param <C> the targeted class @return an array class of the given class
arrayClass
java
alibaba/arthas
core/src/main/java/com/taobao/arthas/core/env/convert/DefaultConversionService.java
https://github.com/alibaba/arthas/blob/master/core/src/main/java/com/taobao/arthas/core/env/convert/DefaultConversionService.java
Apache-2.0