Package org.jpox.enhancer.bcel.method

Source Code of org.jpox.enhancer.bcel.method.JdoMakeDirty

/**********************************************************************
Copyright (c) 2004 Kikuchi Kousuke and others. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Contributors:
    ...
**********************************************************************/
package org.jpox.enhancer.bcel.method;

import org.apache.bcel.Constants;
import org.apache.bcel.generic.IFNULL;
import org.apache.bcel.generic.InstructionConstants;
import org.apache.bcel.generic.InstructionHandle;
import org.apache.bcel.generic.Type;
import org.jpox.enhancer.ClassEnhancer;
import org.jpox.enhancer.bcel.BCELClassEnhancer;
import org.jpox.enhancer.bcel.BCELClassMethod;

/**
* create jdoMakeDirty method.
* @version $Revision: 1.3 $
*/
public class JdoMakeDirty extends BCELClassMethod
{
    /**
     * @param methodName
     * @param type
     * @param resultType
     * @param argType
     * @param argName
     * @param synthetic
     * @param gen
     */
    public JdoMakeDirty(
        String methodName,
        int type,
        Type resultType,
        Type[] argType,
        String[] argName,
        boolean synthetic,
        BCELClassEnhancer gen)
    {
        super(methodName, type, resultType, argType, argName, synthetic, gen);
    }

    public static JdoMakeDirty getInstance(BCELClassEnhancer gen)
    {
        return new JdoMakeDirty(
            "jdoMakeDirty",
            Constants.ACC_PUBLIC | Constants.ACC_FINAL,
            Type.VOID,
            new Type[] { Type.STRING },
            new String[] { "fieldName" },
            false,
            gen);
    }
    /* (non-Javadoc)
     * @see org.jpox.enhancer.gen.Callback#execute()
     */
    public void execute()
    {
        InstructionHandle ifnullTarget = null;

        il.append(InstructionConstants.ALOAD_0);
        il.append(
            factory.createGetField(
                className,
                ClassEnhancer.FN_StateManager,
                BCELClassEnhancer.OT_StateManager));
        IFNULL ifnull = new IFNULL(ifnullTarget);
        il.append(ifnull);
        il.append(InstructionConstants.ALOAD_0);
        il.append(
            factory.createGetField(
                className,
                ClassEnhancer.FN_StateManager,
                BCELClassEnhancer.OT_StateManager));
        il.append(InstructionConstants.ALOAD_0);
        il.append(InstructionConstants.ALOAD_1);
        il.append(
            factory.createInvoke(
                ClassEnhancer.CN_StateManager,
                "makeDirty",
                Type.VOID,
                new Type[] { BCELClassEnhancer.OT_PersistenceCapable, Type.STRING },
                Constants.INVOKEINTERFACE));
        ifnullTarget = il.append(InstructionConstants.RETURN);
        ifnull.setTarget(ifnullTarget);
    }
}
TOP

Related Classes of org.jpox.enhancer.bcel.method.JdoMakeDirty

TOP
Copyright © 2018 www.massapi.com. 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.