Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.ObjectType


                       Type.OBJECT,
                       Type.NO_ARGS, Constants.INVOKEVIRTUAL ) );
          
           iList.append(
               factory.createCheckCast
                   new ObjectType( interfaceClass.getName() ) ) );
          
       }
       // store the created delgate object
       iList.append(
           factory.createFieldAccess(
View Full Code Here


        // newClass.replaceMethod();

        this.oldClass = ((BCELClassMetaData) cmd).getEnhanceClass();
        this.newClass = ((BCELClassMetaData) cmd).getClassGen();
        this.constantPoolGen = this.newClass.getConstantPool();
        this.classType = new ObjectType(className);
        for (int i = 0; i < cmd.getNoOfMembers(); i++)
        {
            AbstractMemberMetaData fmd = (AbstractMemberMetaData) cmd.getMetaDataForMemberAtRelativePosition(i);
            if (!fmd.isFinal() && !fmd.isStatic())
            {
View Full Code Here

            il.append(InstructionConstants.ACONST_NULL);
        }
        else
        {
            // new ClassConstrutor()
            il.append(factory.createNew(new ObjectType(className)));
            il.append(InstructionConstants.DUP);
            il.append(factory.createInvoke(className, Constants.CONSTRUCTOR_NAME, Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
        }
        il.append(factory.createInvoke(CN_JDOImplHelper, "registerClass", Type.VOID, new Type[]{OT_CLASS, new ArrayType(Type.STRING, 1),
                new ArrayType(OT_CLASS, 1), new ArrayType(Type.BYTE, 1), OT_CLASS, OT_PersistenceCapable}, Constants.INVOKESTATIC));
View Full Code Here

                        {
                            //properties do not use jdoXXX methods
                            if (i instanceof GETFIELD)
                            {
                                ih.setInstruction(factory.createInvoke(cg.getClassName(), "jdo" + BCELUtils.getGetterName(f),
                                    field.getType(constantPoolGen), new Type[]{new ObjectType(cg.getClassName())}, Constants.INVOKESTATIC));
                            }
                            else
                            {
                                ih.setInstruction(factory.createInvoke(cg.getClassName(), "jdo" + BCELUtils.getSetterName(f),
                                    Type.VOID, new Type[]{new ObjectType(cg.getClassName()), field.getType(constantPoolGen)},
                                    Constants.INVOKESTATIC));
                            }
                            change = true;
                        }
                    }
View Full Code Here

    {
        String oidClassName = cmd.getObjectidClass();
        if (cmd.getMetaDataManager().getApiAdapter().isSingleFieldIdentityClass(oidClassName))
        {
            AbstractMemberMetaData fields[] = cmd.getManagedMembers();
            ObjectType oidType;

            if (oidClassName.equals(ClassEnhancer.CN_StringIdentity))
            {
                oidType = BCELClassEnhancer.OT_StringIdentity;
            }
            else if (oidClassName.equals(ClassEnhancer.CN_LongIdentity))
            {
                oidType = BCELClassEnhancer.OT_LongIdentity;
            }
            else if (oidClassName.equals(ClassEnhancer.CN_IntIdentity))
            {
                oidType = BCELClassEnhancer.OT_IntIdentity;
            }
            else if (oidClassName.equals(ClassEnhancer.CN_ShortIdentity))
            {
                oidType = BCELClassEnhancer.OT_ShortIdentity;
            }
            else if (oidClassName.equals(ClassEnhancer.CN_ByteIdentity))
            {
                oidType = BCELClassEnhancer.OT_ByteIdentity;
            }
            else if (oidClassName.equals(ClassEnhancer.CN_CharIdentity))
            {
                oidType = BCELClassEnhancer.OT_CharIdentity;
            }
            else
            {
                oidType = BCELClassEnhancer.OT_ObjectIdentity;
            }

            // Creates the following method:
            // public Object jdoNewObjectIdInstance()
            // {
            //     return new oidType(getClass());
            // }
            for (int i = 0; i < fields.length; i++)
            {
              AbstractMemberMetaData f = (AbstractMemberMetaData)fields[i];
                BCELMember fieldMethod = ((BCELFieldPropertyMetaData)f).getEnhanceField();
               
                if (f.isPrimaryKey())
                {
                    il.append(factory.createNew(oidType));
                    il.append(InstructionConstants.DUP);
                    il.append(InstructionConstants.ALOAD_0);
                    il.append(factory.createInvoke(className, "getClass", BCELClassEnhancer.OT_CLASS, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
                    il.append(InstructionConstants.ALOAD_0);
                   
                    createGetField(f.getName(),fieldMethod.getType(), f.isProperty());
                    if (oidType == BCELClassEnhancer.OT_ObjectIdentity)
                    {
                        // ObjectIdentity case where we override the field type and just use Object
                        il.append(factory.createInvoke(oidType.getClassName(), Constants.CONSTRUCTOR_NAME, Type.VOID,
                            new Type[]{BCELClassEnhancer.OT_CLASS, Type.OBJECT}, Constants.INVOKESPECIAL));
                    }
                    else
                    {
                        il.append(factory.createInvoke(oidType.getClassName(), Constants.CONSTRUCTOR_NAME, Type.VOID,
                            new Type[]{BCELClassEnhancer.OT_CLASS, fieldMethod.getType()}, Constants.INVOKESPECIAL));
                    }
                    il.append(InstructionFactory.createReturn(oidType));
                    break;
                }
            }/*
              * il.append(factory.createNew(oidType));
              * il.append(InstructionConstants.DUP);
              * il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
              * il.append(factory.createInvoke("java.lang.Object", "getClass",
              * Generator.OT_CLASS, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
              * il.append(factory.createInvoke(oidType.getClassName(), "
              * <init>", Type.VOID, new Type[]{Generator.OT_CLASS},
              * Constants.INVOKESPECIAL));
              * il.append(InstructionFactory.createReturn(Type.OBJECT));
              */
        }
        // Users Application Identity class
        else if (oidClassName != null && oidClassName.length() > 0)
        {
            ObjectType objectIdClassType = new ObjectType(oidClassName);
            il.append(factory.createNew(objectIdClassType));
            il.append(InstructionConstants.DUP);
            il.append(factory.createInvoke(oidClassName, Constants.CONSTRUCTOR_NAME, Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
            il.append(InstructionFactory.createReturn(objectIdClassType));
        }
View Full Code Here

            //     if (key instanceof String)
            //         return new oidType(getClass(), (String)key);
            //     else
            //         return new oidType(getClass(), (oidKeyType)key);
            // }
            ObjectType oidType;
            ObjectType oidKeyType;
            if (oidClassName.equals(ClassEnhancer.CN_StringIdentity))
            {
                oidType = BCELClassEnhancer.OT_StringIdentity;
                oidKeyType = Type.STRING;
            }
            else if (oidClassName.equals(ClassEnhancer.CN_LongIdentity))
            {
                oidType = BCELClassEnhancer.OT_LongIdentity;
                oidKeyType = new ObjectType(Long.class.getName());
            }
            else if (oidClassName.equals(ClassEnhancer.CN_IntIdentity))
            {
                oidType = BCELClassEnhancer.OT_IntIdentity;
                oidKeyType = new ObjectType(Integer.class.getName());
            }
            else if (oidClassName.equals(ClassEnhancer.CN_ShortIdentity))
            {
                oidType = BCELClassEnhancer.OT_ShortIdentity;
                oidKeyType = new ObjectType(Short.class.getName());
            }
            else if (oidClassName.equals(ClassEnhancer.CN_ByteIdentity))
            {
                oidType = BCELClassEnhancer.OT_ByteIdentity;
                oidKeyType = new ObjectType(Byte.class.getName());
            }
            else if (oidClassName.equals(ClassEnhancer.CN_CharIdentity))
            {
                oidType = BCELClassEnhancer.OT_CharIdentity;
                oidKeyType = new ObjectType(Long.class.getName());
            }
            else
            {
                oidType = BCELClassEnhancer.OT_ObjectIdentity;
                oidKeyType = new ObjectType(Object.class.getName());
            }

            il.append(InstructionConstants.ALOAD_1);
            BranchInstruction checkKeyIsNull = new IFNONNULL(null);
            il.append(checkKeyIsNull);
            createThrowException(ClassEnhancer.CN_IllegalArgumentException, "key is null");
            checkKeyIsNull.setTarget(il.append(InstructionConstants.ALOAD_1));
            il.append(factory.createInstanceOf(Type.STRING));
            il.append(InstructionConstants.ICONST_1);
            BranchInstruction isInstanceof = new IF_ICMPEQ(null);
            il.append(isInstanceof);

            // new oidType(getClass(), (oidKeyType)key);
            il.append(factory.createNew(oidType));
            il.append(InstructionConstants.DUP);
            il.append(InstructionConstants.ALOAD_0);
            il.append(factory.createInvoke("java.lang.Object", "getClass", BCELClassEnhancer.OT_CLASS, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
            il.append(InstructionConstants.ALOAD_1);
            il.append(factory.createCheckCast(oidKeyType));
            il.append(factory.createInvoke(oidType.getClassName(), Constants.CONSTRUCTOR_NAME, Type.VOID,
                new Type[] { BCELClassEnhancer.OT_CLASS, oidKeyType }, Constants.INVOKESPECIAL));

            // "return"
            il.append(InstructionFactory.createReturn(Type.OBJECT));

            // "new oidType(getClass(), (String)key);"
            isInstanceof.setTarget(il.append(factory.createNew(oidType)));
            il.append(InstructionConstants.DUP);
            il.append(InstructionConstants.ALOAD_0);
            il.append(factory.createInvoke("java.lang.Object", "getClass", BCELClassEnhancer.OT_CLASS, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
            il.append(InstructionConstants.ALOAD_1);
            il.append(factory.createCheckCast(Type.STRING));
            il.append(factory.createInvoke(oidType.getClassName(), Constants.CONSTRUCTOR_NAME, Type.VOID,
                new Type[] { BCELClassEnhancer.OT_CLASS, Type.STRING }, Constants.INVOKESPECIAL));

            // "return"
            il.append(InstructionFactory.createReturn(Type.OBJECT));

        }
        // Users Application Identity class
        else if (oidClassName != null && oidClassName.length() > 0)
        {
            // Creates the following method
            // public Object jdoNewObjectIdInstance(Object key)
            // {
            //     return new oidType((String)key);
            // }
            ObjectType objectIdClassType = new ObjectType(oidClassName);
            il.append(factory.createNew(objectIdClassType));
            il.append(InstructionConstants.DUP);
            il.append(InstructionConstants.ALOAD_1);
            il.append(factory.createCheckCast(Type.STRING));
            il.append(factory.createInvoke(oidClassName, Constants.CONSTRUCTOR_NAME, Type.VOID,
View Full Code Here

        if (!isFieldBelongsToThisClass())
        {
            return false;
        }

        ObjectType objectType = (enhanceField.getType() instanceof ObjectType) ?
            (ObjectType)enhanceField.getType() : null;

        return isTypePersistable(objectType);
    }
View Full Code Here

        if (!isFieldBelongsToThisClass())
        {
            return false;
        }

        ObjectType objectType = null;
        if (enhanceField.getType() instanceof ArrayType)
        {
            Type elementType = ((ArrayType)enhanceField.getType()).getElementType();
            if (elementType instanceof ObjectType)
            {
View Full Code Here

        if (enhanceField == null)
        {
            return false;
        }

        ObjectType objectType = (enhanceField.getType() instanceof ObjectType) ?
            (ObjectType)enhanceField.getType() : null;

        return isTypePersistenceCapable(objectType);
    }
View Full Code Here

        if (enhanceField == null)
        {
            return false;
        }

        ObjectType objectType = null;
        if (enhanceField.getType() instanceof ArrayType)
        {
            Type elementType = ((ArrayType)enhanceField.getType()).getElementType();
            if (elementType instanceof ObjectType)
            {
View Full Code Here

TOP

Related Classes of org.apache.bcel.generic.ObjectType

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.