当前位置: 首页>>代码示例>>Java>>正文


Java PrimitiveWrapperMap类代码示例

本文整理汇总了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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:MetaData.java

示例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;
    }
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:27,代码来源:MetaData.java


注:本文中的com.sun.beans.finder.PrimitiveWrapperMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。