/** * Constructs a PropertiesUtil using a given Properties object as its source of defined properties. * * @param props the Properties to use by default */ public PropertiesUtil(final Properties props) { this.environment = new Environment(new PropertiesPropertySource(props)); }
public SortedArrayStringMap(final ReadOnlyStringMap other) { if (other instanceof SortedArrayStringMap) { initFrom0((SortedArrayStringMap) other); } else if (other != null) { resize(ceilingNextPowerOfTwo(other.size())); other.forEach(PUT_ALL, this); } }
/** * Constructs a PropertiesUtil for a given properties file name on the classpath. The properties specified in this * file are used by default. If a property is not defined in this file, then the equivalent system property is used. * * @param propertiesFileName the location of properties file to load */ public PropertiesUtil(final String propertiesFileName) { this.environment = new Environment(new PropertyFilePropertySource(propertiesFileName)); }
@PerformanceSensitive public static Class<?> getCallerClass(final String fqcn) { return getCallerClass(fqcn, Strings.EMPTY); }
private ProviderUtil() { for (ClassLoader classLoader : LoaderUtil.getClassLoaders()) { try { loadProviders(classLoader); } catch (Throwable ex) { LOGGER.debug("Unable to retrieve provider from ClassLoader {}", classLoader, ex); } } for (final LoaderUtil.UrlResource resource : LoaderUtil.findUrlResources(PROVIDER_RESOURCE)) { loadProvider(resource.getUrl(), resource.getClassLoader()); } }
private static StringMap createContextData() { final StringMap result = new SortedArrayStringMap(); result.putValue("a", "1"); result.putValue("b", "2"); return result; }
@PerformanceSensitive public static Class<?> getCallerClass(final Class<?> anchor) { return stackLocator.getCallerClass(anchor); }
/** * Returns an implementation of the {@code StringMap} used to back this thread context map, pre-populated * with the contents of the specified context data. * <p> * Subclasses may override. * </p> * @param original the key-value pairs to initialize the returned context data with * @return an implementation of the {@code StringMap} used to back this thread context map */ protected StringMap createStringMap(final ReadOnlyStringMap original) { return new SortedArrayStringMap(original); }
private static StringBuilder getSB() { return Constants.ENABLE_THREADLOCALS ? getState().getStringBuilder() : webSafeState.getStringBuilder(); }
@PerformanceSensitive public static Stack<Class<?>> getCurrentStackTrace() { return stackLocator.getCurrentStackTrace(); }
/** * Returns the data elements as if they were parameters on the logging event. * @return the data elements. */ @Override public Object[] getParameters() { final Object[] result = new Object[data.size()]; for (int i = 0; i < data.size(); i++) { result[i] = data.getValueAt(i); } return result; }
@SuppressWarnings("unchecked") @Override public <V, T> void forEach(final TriConsumer<String, ? super V, T> action, final T state) { iterating = true; try { for (int i = 0; i < size; i++) { action.accept(keys[i], (V) values[i], state); } } finally { iterating = false; } }
/** * Gets the named property as a String. * * @param name the name of the property to look up * @param defaultValue the default value to use if the property is undefined * @return the String value of the property or {@code defaultValue} if undefined. */ public String getStringProperty(final String name, final String defaultValue) { final String prop = getStringProperty(name); return (prop == null) ? defaultValue : prop; }
@Override public void accept(final String s, final Object o) { original.putValue("c", "other"); } });
@Override public CharSequence getNormalForm(final Iterable<? extends CharSequence> tokens) { return PREFIX + Util.joinAsCamelCase(tokens); } }
private void ensureCapacity() { if (size >= threshold) { resize(threshold * 2); } }
@Override public void accept(final String s, final Object o, final Object o2) { original.clear(); } }, null);
@PerformanceSensitive public static Class<?> getCallerClass(final int depth) { return stackLocator.getCallerClass(depth + 1); }
/** * Constructs a new instance based on an existing {@link Map}. * @param map The Map. */ public MapMessage(final Map<String, V> map) { this.data = new SortedArrayStringMap(map); }
@PerformanceSensitive public static Class<?> getCallerClass(final String fqcn, final String pkg) { return stackLocator.getCallerClass(fqcn, pkg); }