Package com.sun.grid.jgdi.configuration.reflect

Examples of com.sun.grid.jgdi.configuration.reflect.ClassDescriptor


        return getProperties(obj, EditorUtil.PROPERTIES_READ_ONLY);
    }

    static List getProperties(GEObject obj, int propScope) {
        List<PropertyDescriptor> propList = new ArrayList<PropertyDescriptor>();
        ClassDescriptor cd = Util.getDescriptor(obj.getClass());
        for (PropertyDescriptor pd : cd.getProperties()) {
            if (EditorUtil.doNotDisplayAttr(obj, pd, propScope)) {
                continue;
            }
            if (isValidPropertyType(pd, propScope)) {
                propList.add(pd);
View Full Code Here


        return propList;
    }

    static PropertyDescriptor getProperty(GEObject obj, int propScope, String name) {
        List<PropertyDescriptor> propList = new ArrayList<PropertyDescriptor>();
        ClassDescriptor cd = Util.getDescriptor(obj.getClass());
        PropertyDescriptor pd = cd.getProperty(EditorUtil.unifyClientNamesWithAttr(obj, name));
        if (pd == null) {
            return null;
        }
        if (EditorUtil.doNotDisplayAttr(obj, pd, propScope)) {
            return null;
View Full Code Here

         */
        private Object parse(String value, PropertyDescriptor pd) throws SAXException {
            Class clazz = pd.getPropertyType();
            if (pd.hasCullWrapper()) {
               
                ClassDescriptor realClassDescriptor = Util.getDescriptor(pd.getPropertyType());
               
                Object obj = realClassDescriptor.newInstance();
               
                PropertyDescriptor rpd = realClassDescriptor.getPropertyByCullFieldName(pd.getCullContentField());
               
                if (rpd instanceof SimplePropertyDescriptor) {
                    ((SimplePropertyDescriptor)rpd).setValue(obj, parse(value, rpd));
                    return obj;
                } else {
View Full Code Here

        return write(obj, ctx);
    }
   
    private static void write(GEObject obj, Class clazz, Context ctx) {
       
        ClassDescriptor cd = Util.getDescriptor(clazz);
        ctx.p.print('<');
        ctx.p.print(cd.getCullName());
        ctx.p.print('>');
        if (obj == null) {
            ctx.p.print(NONE);
        } else {
            ctx.p.println();
            ctx.p.indent();
            for(int i = 0; i < cd.getPropertyCount(); i++) {
                PropertyDescriptor pd = cd.getProperty(i);
               
                if (!ctx.include(pd)) {
                    continue;
                }
                if (pd instanceof SimplePropertyDescriptor) {
                    write(obj, (SimplePropertyDescriptor)pd, ctx);
                } else if (pd instanceof ListPropertyDescriptor) {
                    write(obj, (ListPropertyDescriptor)pd, ctx);
                } else if (pd instanceof MapPropertyDescriptor) {
                    write(obj, (MapPropertyDescriptor)pd, ctx);
                } else if (pd instanceof MapListPropertyDescriptor) {
                    write(obj, (MapListPropertyDescriptor)pd, ctx);
                } else {
                    throw new IllegalStateException("Unknown property type " + pd.getClass());
                }
               
            }
            ctx.p.deindent();
        }
        ctx.p.print("</");
        ctx.p.print(cd.getCullName());
        ctx.p.println('>');
       
    }
View Full Code Here

    public static void addDescriptor(Class aClass, ClassDescriptor cd) {
        classDescriptorMap.put(aClass, cd);
    }
   
    public static ClassDescriptor getDescriptor(Class aClass) {
        ClassDescriptor ret = null;
        ret = classDescriptorMap.get(aClass);
        if (ret == null) {
            ret = createDescriptor(aClass);
            classDescriptorMap.put(aClass, ret);
        }
View Full Code Here

        }
        return ret;
    }
   
    public static Object clone(Object obj) {
        ClassDescriptor cd = getDescriptor(obj.getClass());
        return cd.clone(obj);
    }
View Full Code Here

    }
    // private ------------------------------------------------------------------
    private static int objectId;
   
    private static ClassDescriptor createDescriptor(Class aClass) {
        ClassDescriptor ret = null;
        StringBuilder name = new StringBuilder();
        String packagename = aClass.getPackage().getName();
        name.append(packagename);
        name.append(".reflect.");
       
View Full Code Here

            propertyName = name.substring(0, bracketIndex);
            name = name.substring(bracketIndex + 1, bracketCloseIndex);
        }
       
        if (propertyName != null) {
            ClassDescriptor descr = getDescriptor(root.getClass());
            PropertyDescriptor propDescr = descr.getProperty(propertyName);
            if (propDescr == null) {
                throw new IllegalArgumentException("Invalid Path: property " + propertyName + " in object " + root.getName() + " not found");
            } else if (!GEObject.class.isAssignableFrom(propDescr.getBeanClass())) {
                throw new IllegalArgumentException("Invalid Path: property " + propertyName + " in object " + root.getName() + " is not a GEObject");
            } else {
View Full Code Here

    public static void getDifferences(GEObject obj1, GEObject obj2, String path, List<Difference> differences) {
       
        if (!obj1.getClass().equals(obj2.getClass())) {
            differences.add(new Difference(path, "obj1 and obj2 have not the same class"));
        } else {
            ClassDescriptor cd = getDescriptor(obj1.getClass());
           
            for (int i = 0; i < cd.getPropertyCount(); i++) {
                PropertyDescriptor pd = cd.getProperty(i);
                String propPath = path + pd.getPropertyName();
               
                if (pd instanceof SimplePropertyDescriptor) {
                   
                    SimplePropertyDescriptor spd = (SimplePropertyDescriptor) pd;
View Full Code Here

TOP

Related Classes of com.sun.grid.jgdi.configuration.reflect.ClassDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.