Package org.jpox.enhancer.bcel.method

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

/**********************************************************************
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.generic.InstructionConstants;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.Type;
import org.jpox.enhancer.bcel.BCELClassEnhancer;
import org.jpox.enhancer.bcel.BCELClassMethod;
import org.jpox.enhancer.bcel.metadata.BCELMember;
import org.jpox.enhancer.bcel.metadata.BCELFieldPropertyMetaData;

/**
* @version $Revision: 1.5 $
*/
public class NormalGetMethod extends BCELClassMethod
{
  protected BCELFieldPropertyMetaData fieldConfig;

  /**
   * @param methodName
   * @param type
   * @param resultType
   * @param argType
   * @param argName
   * @param synthetic
   * @param gen
   */
  public NormalGetMethod(
    String methodName,
    int type,
    Type resultType,
    Type[] argType,
    String[] argName,
    boolean synthetic,
    BCELClassEnhancer gen,
    BCELFieldPropertyMetaData fieldConfig)
    {
    super(methodName, type, resultType, argType, argName, synthetic, gen);
    this.fieldConfig = fieldConfig;
  }

  /* (non-Javadoc)
   * @see org.jpox.enhancer.gen.Callback#execute()
   */
  public void execute()
    {
        BCELMember targetField = fieldConfig.getEnhanceField();
    if (targetField.isStatic())
        {
      il.append(
        factory.createGetStatic(className, targetField.getName(), targetField.getType()));
      il.append(InstructionFactory.createReturn(targetField.getType()));
    }
        else
        {
      il.append(InstructionConstants.ALOAD_0);
      il.append(
        factory.createGetField(className, targetField.getName(), targetField.getType()));
      il.append(InstructionFactory.createReturn(targetField.getType()));
    }
  }
}
TOP

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

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.