org.apache.log4j.helpers.OptionConverter#substVars ( )源码实例Demo

下面列出了org.apache.log4j.helpers.OptionConverter#substVars ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cacheonix-core   文件: OptionConverterTestCase.java
public
void varSubstTest1() {
  String r;

  r = OptionConverter.substVars("hello world.", null);
  assertEquals("hello world.", r);
  
  r = OptionConverter.substVars("hello ${TOTO} world.", null);
  
  assertEquals("hello wonderful world.", r);
}
 
源代码2 项目: cacheonix-core   文件: OptionConverterTestCase.java
public
void varSubstTest2() {
  String r;

  r = OptionConverter.substVars("Test2 ${key1} mid ${key2} end.", null);
  assertEquals("Test2 value1 mid value2 end.", r);
}
 
源代码3 项目: cacheonix-core   文件: OptionConverterTestCase.java
public
void varSubstTest3() {
  String r;

  r = OptionConverter.substVars(
		     "Test3 ${unset} mid ${key1} end.", null);
  assertEquals("Test3  mid value1 end.", r);
}
 
源代码4 项目: cacheonix-core   文件: OptionConverterTestCase.java
public
void varSubstTest4() {
  String res;
  String val = "Test4 ${incomplete ";
  try {
    res = OptionConverter.substVars(val, null);
  }
  catch(IllegalArgumentException e) {
    String errorMsg = e.getMessage();
    //System.out.println('['+errorMsg+']');
    assertEquals('"'+val
   + "\" has no closing brace. Opening brace at position 6.", 
   errorMsg);
  }
}
 
源代码5 项目: cacheonix-core   文件: OptionConverterTestCase.java
public
void varSubstTest5() {
  Properties props = new Properties();
  props.put("p1", "x1");
  props.put("p2", "${p1}");
  String res = OptionConverter.substVars("${p2}", props);
  System.out.println("Result is ["+res+"].");
  assertEquals(res, "x1");
}
 
源代码6 项目: cacheonix-core   文件: DOMConfigurator.java
/**
 * Substitutes property value for any references in expression.
 *
 * @param value value from configuration file, may contain
 *              literal text, property references or both
 * @param props properties.
 * @return evaluated expression, may still contain expressions
 *         if unable to expand.
 * @since 1.2.15
 */
public static String subst(final String value, final Properties props) {
    try {
        return OptionConverter.substVars(value, props);
    } catch (IllegalArgumentException e) {
        LogLog.warn("Could not perform variable substitution.", e);
        return value;
    }
}
 
源代码7 项目: logging-log4j2   文件: XmlConfiguration.java
/**
 * Substitutes property value for any references in expression.
 *
 * @param value value from configuration file, may contain
 *              literal text, property references or both
 * @param props properties.
 * @return evaluated expression, may still contain expressions
 * if unable to expand.
 */
public String subst(final String value, final Properties props) {
    try {
        return OptionConverter.substVars(value, props);
    } catch (IllegalArgumentException e) {
        LOGGER.warn("Could not perform variable substitution.", e);
        return value;
    }
}
 
源代码8 项目: logging-log4j2   文件: XmlConfigurationFactory.java
/**
 * Substitutes property value for any references in expression.
 *
 * @param value value from configuration file, may contain
 *              literal text, property references or both
 * @param props properties.
 * @return evaluated expression, may still contain expressions
 * if unable to expand.
 */
public static String subst(final String value, final Properties props) {
    try {
        return OptionConverter.substVars(value, props);
    } catch (IllegalArgumentException e) {
        LOGGER.warn("Could not perform variable substitution.", e);
        return value;
    }
}