Java EclipseRCP属性测试人员的期望值总是字符串吗?
在eclipse文档中,我看到了以下代码片段(): 我有点想知道Java EclipseRCP属性测试人员的期望值总是字符串吗?,java,eclipse-rcp,Java,Eclipse Rcp,在eclipse文档中,我看到了以下代码片段(): 我有点想知道((布尔)expectedValue)部分-因为预期值在标记中作为字符串给出: <test property="org.eclipse.jdt.core.isDefaultPackage" value="true" /> 无论何时我实现了一个属性测试程序,这个值都是以字符串的形式给出的 所以我的问题是:是否可能有一个不是字符串的期望值?根据EclipseRCP文档,它应该是。。。但是怎么做 它不是很清楚,但是期望值
((布尔)expectedValue)
部分-因为预期值在
标记中作为字符串给出:
<test property="org.eclipse.jdt.core.isDefaultPackage" value="true" />
无论何时我实现了一个属性测试程序,这个值都是以字符串的形式给出的
所以我的问题是:是否可能有一个不是字符串的期望值?根据EclipseRCP文档,它应该是。。。但是怎么做 它不是很清楚,但是期望值可以是
字符串
或布尔值
,浮点值
(!)或整数
在org.eclipse.core.internal.expressions.expressions
中找到的代码:
public static Object convertArgument(String arg) throws CoreException {
if (arg == null) {
return null;
} else if (arg.length() == 0) {
return arg;
} else if (arg.charAt(0) == '\'' && arg.charAt(arg.length() - 1) == '\'') {
return unEscapeString(arg.substring(1, arg.length() - 1));
} else if ("true".equals(arg)) { //$NON-NLS-1$
return Boolean.TRUE;
} else if ("false".equals(arg)) { //$NON-NLS-1$
return Boolean.FALSE;
} else if (arg.indexOf('.') != -1) {
try {
return Float.valueOf(arg);
} catch (NumberFormatException e) {
return arg;
}
} else {
try {
return Integer.valueOf(arg);
} catch (NumberFormatException e) {
return arg;
}
}
}
因此它是一个字符串
,除非它是真
、假
或数字
<test property="org.eclipse.jdt.core.isDefaultPackage" value="true" />
public static Object convertArgument(String arg) throws CoreException {
if (arg == null) {
return null;
} else if (arg.length() == 0) {
return arg;
} else if (arg.charAt(0) == '\'' && arg.charAt(arg.length() - 1) == '\'') {
return unEscapeString(arg.substring(1, arg.length() - 1));
} else if ("true".equals(arg)) { //$NON-NLS-1$
return Boolean.TRUE;
} else if ("false".equals(arg)) { //$NON-NLS-1$
return Boolean.FALSE;
} else if (arg.indexOf('.') != -1) {
try {
return Float.valueOf(arg);
} catch (NumberFormatException e) {
return arg;
}
} else {
try {
return Integer.valueOf(arg);
} catch (NumberFormatException e) {
return arg;
}
}
}