本文整理汇总了Java中org.apache.log4j.helpers.OptionConverter.substVars方法的典型用法代码示例。如果您正苦于以下问题:Java OptionConverter.substVars方法的具体用法?Java OptionConverter.substVars怎么用?Java OptionConverter.substVars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.helpers.OptionConverter
的用法示例。
在下文中一共展示了OptionConverter.substVars方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: varSubstTest1
import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
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: varSubstTest2
import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
public
void varSubstTest2() {
String r;
r = OptionConverter.substVars("Test2 ${key1} mid ${key2} end.", null);
assertEquals("Test2 value1 mid value2 end.", r);
}
示例3: varSubstTest3
import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
public
void varSubstTest3() {
String r;
r = OptionConverter.substVars(
"Test3 ${unset} mid ${key1} end.", null);
assertEquals("Test3 mid value1 end.", r);
}
示例4: varSubstTest4
import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
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: varSubstTest5
import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
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: subst
import org.apache.log4j.helpers.OptionConverter; //导入方法依赖的package包/类
/**
* 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;
}
}