Package org.objectweb.speedo.generation.enhancer.pc

Source Code of org.objectweb.speedo.generation.enhancer.pc.FieldRemover

/**
* Copyright (C) 2001-2005 France Telecom R&D
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
package org.objectweb.speedo.generation.enhancer.pc;

import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Constants;
import org.objectweb.speedo.generation.enhancer.common.LoggedClassAdapter;
import org.objectweb.speedo.lib.Personality;
import org.objectweb.speedo.metadata.SpeedoClass;
import org.objectweb.speedo.metadata.SpeedoField;
import org.objectweb.util.monolog.api.Logger;

/**
* This visistor removes the persistent fields of a persistent class because
* they have been moved into the XXXFields class.
*
* @author S.Chassande-Barrioz
*/
public class FieldRemover extends LoggedClassAdapter {

  /**
     * is Speedo Meta Object representing the persistent class.
   */
    private final SpeedoClass clazz;

  public FieldRemover(final ClassVisitor classVisitor,
      final SpeedoClass sClass,
      final Logger logger,
      final Personality p) {
    super(classVisitor, p, logger);
    this.clazz = sClass;
  }

  public void visitField(final int access,
               final String name,
               final String desc,
               final Object value,
               final Attribute attrs) {
    boolean keepfield = (access & Constants.ACC_STATIC) != 0;
        if (!keepfield) {
            SpeedoField sf = (SpeedoField) clazz.fields.get(name);
            keepfield = sf == null;
            if (!keepfield) {
                keepfield = sf.persistenceStatus == SpeedoField.NONE;
            }
        }
        if (keepfield) {
            super.visitField(access, name, desc, value, attrs);
    }
  }
}
TOP

Related Classes of org.objectweb.speedo.generation.enhancer.pc.FieldRemover

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.