本文整理汇总了Java中com.sun.beans.finder.PrimitiveWrapperMap类的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveWrapperMap类的具体用法?Java PrimitiveWrapperMap怎么用?Java PrimitiveWrapperMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrimitiveWrapperMap类属于com.sun.beans.finder包,在下文中一共展示了PrimitiveWrapperMap类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: instantiate
import com.sun.beans.finder.PrimitiveWrapperMap; //导入依赖的package包/类
protected Expression instantiate(Object oldInstance, Encoder out) {
Class<?> c = (Class)oldInstance;
// As of 1.3 it is not possible to call Class.forName("int"),
// so we have to generate different code for primitive types.
// This is needed for arrays whose subtype may be primitive.
if (c.isPrimitive()) {
Field field = null;
try {
field = PrimitiveWrapperMap.getType(c.getName()).getDeclaredField("TYPE");
} catch (NoSuchFieldException ex) {
System.err.println("Unknown primitive type: " + c);
}
return new Expression(oldInstance, field, "get", new Object[]{null});
}
else if (oldInstance == String.class) {
return new Expression(oldInstance, "", "getClass", new Object[]{});
}
else if (oldInstance == Class.class) {
return new Expression(oldInstance, String.class, "getClass", new Object[]{});
}
else {
Expression newInstance = new Expression(oldInstance, Class.class, "forName", new Object[] { c.getName() });
newInstance.loader = c.getClassLoader();
return newInstance;
}
}
示例2: instantiate
import com.sun.beans.finder.PrimitiveWrapperMap; //导入依赖的package包/类
protected Expression instantiate(Object oldInstance, Encoder out) {
Class c = (Class)oldInstance;
// As of 1.3 it is not possible to call Class.forName("int"),
// so we have to generate different code for primitive types.
// This is needed for arrays whose subtype may be primitive.
if (c.isPrimitive()) {
Field field = null;
try {
field = PrimitiveWrapperMap.getType(c.getName()).getDeclaredField("TYPE");
} catch (NoSuchFieldException ex) {
System.err.println("Unknown primitive type: " + c);
}
return new Expression(oldInstance, field, "get", new Object[]{null});
}
else if (oldInstance == String.class) {
return new Expression(oldInstance, "", "getClass", new Object[]{});
}
else if (oldInstance == Class.class) {
return new Expression(oldInstance, String.class, "getClass", new Object[]{});
}
else {
Expression newInstance = new Expression(oldInstance, Class.class, "forName", new Object[] { c.getName() });
newInstance.loader = c.getClassLoader();
return newInstance;
}
}