本文整理汇总了Java中org.codehaus.groovy.runtime.InvokerHelper.inspect方法的典型用法代码示例。如果您正苦于以下问题:Java InvokerHelper.inspect方法的具体用法?Java InvokerHelper.inspect怎么用?Java InvokerHelper.inspect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.runtime.InvokerHelper
的用法示例。
在下文中一共展示了InvokerHelper.inspect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fieldInfo
import org.codehaus.groovy.runtime.InvokerHelper; //导入方法依赖的package包/类
protected String[] fieldInfo(Field field) {
String[] result = new String[MEMBER_VALUE_IDX + 1];
result[MEMBER_ORIGIN_IDX] = JAVA;
result[MEMBER_MODIFIER_IDX] = Modifier.toString(field.getModifiers());
result[MEMBER_DECLARER_IDX] = shortName(field.getDeclaringClass());
result[MEMBER_TYPE_IDX] = shortName(field.getType());
result[MEMBER_NAME_IDX] = field.getName();
try {
result[MEMBER_VALUE_IDX] = InvokerHelper.inspect(field.get(objectUnderInspection));
} catch (IllegalAccessException e) {
result[MEMBER_VALUE_IDX] = NOT_APPLICABLE;
}
return withoutNulls(result);
}
示例2: writeValue
import org.codehaus.groovy.runtime.InvokerHelper; //导入方法依赖的package包/类
private static void writeValue(String key, String space, String prefix, Object value, BufferedWriter out) throws IOException {
// key = key.indexOf('.') > -1 ? InvokerHelper.inspect(key) : key;
boolean isKeyword = KEYWORDS.contains(key);
key = isKeyword ? InvokerHelper.inspect(key) : key;
if (!StringGroovyMethods.asBoolean(prefix) && isKeyword) prefix = "this.";
out.append(space).append(prefix).append(key).append('=').append(InvokerHelper.inspect(value));
out.newLine();
}
示例3: writeNode
import org.codehaus.groovy.runtime.InvokerHelper; //导入方法依赖的package包/类
private void writeNode(String key, String space, int tab, ConfigObject value, BufferedWriter out) throws IOException {
key = KEYWORDS.contains(key) ? InvokerHelper.inspect(key) : key;
out.append(space).append(key).append(" {");
out.newLine();
writeConfig("", value, out, tab + 1, true);
out.append(space).append('}');
out.newLine();
}
示例4: inspect
import org.codehaus.groovy.runtime.InvokerHelper; //导入方法依赖的package包/类
@Override
public String inspect() {
final String toText = InvokerHelper.inspect(to);
final String fromText = InvokerHelper.inspect(from);
return reverse ? "" + toText + ".." + fromText : "" + fromText + ".." + toText;
}
示例5: inspect
import org.codehaus.groovy.runtime.InvokerHelper; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String inspect() {
return InvokerHelper.inspect(at) + "..<" + InvokerHelper.inspect(at);
}
示例6: writeConfig
import org.codehaus.groovy.runtime.InvokerHelper; //导入方法依赖的package包/类
private void writeConfig(String prefix, ConfigObject map, BufferedWriter out, int tab, boolean apply) throws IOException {
String space = apply ? StringGroovyMethods.multiply(TAB_CHARACTER, tab) : "";
for (Object o1 : map.keySet()) {
String key = (String) o1;
Object v = map.get(key);
if (v instanceof ConfigObject) {
ConfigObject value = (ConfigObject) v;
if (!value.isEmpty()) {
Object dotsInKeys = null;
for (Object o : value.entrySet()) {
Entry e = (Entry) o;
String k = (String) e.getKey();
if (k.indexOf('.') > -1) {
dotsInKeys = e;
break;
}
}
int configSize = value.size();
Object firstKey = value.keySet().iterator().next();
Object firstValue = value.values().iterator().next();
int firstSize;
if (firstValue instanceof ConfigObject) {
firstSize = ((ConfigObject) firstValue).size();
} else {
firstSize = 1;
}
if (configSize == 1 || DefaultGroovyMethods.asBoolean(dotsInKeys)) {
if (firstSize == 1 && firstValue instanceof ConfigObject) {
key = KEYWORDS.contains(key) ? InvokerHelper.inspect(key) : key;
String writePrefix = prefix + key + "." + firstKey + ".";
writeConfig(writePrefix, (ConfigObject) firstValue, out, tab, true);
} else if (!DefaultGroovyMethods.asBoolean(dotsInKeys) && firstValue instanceof ConfigObject) {
writeNode(key, space, tab, value, out);
} else {
for (Object j : value.keySet()) {
Object v2 = value.get(j);
Object k2 = ((String) j).indexOf('.') > -1 ? InvokerHelper.inspect(j) : j;
if (v2 instanceof ConfigObject) {
key = KEYWORDS.contains(key) ? InvokerHelper.inspect(key) : key;
writeConfig(prefix + key, (ConfigObject) v2, out, tab, false);
} else {
writeValue(key + "." + k2, space, prefix, v2, out);
}
}
}
} else {
writeNode(key, space, tab, value, out);
}
}
} else {
writeValue(key, space, prefix, v, out);
}
}
}