Package org.objectweb.speedo.generation.mivisitor

Source Code of org.objectweb.speedo.generation.mivisitor.IndexVisitor

/**
* Copyright (C) 2001-2004 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.mivisitor;

import java.util.Iterator;

import org.objectweb.speedo.api.SpeedoException;
import org.objectweb.speedo.lib.Personality;
import org.objectweb.speedo.metadata.SpeedoField;
import org.objectweb.speedo.metadata.SpeedoIndex;
import org.objectweb.speedo.metadata.SpeedoPackage;

/**
* @author Y.Bersihand
*/
public class IndexVisitor extends AbstractMetaInfoVisitor {

  public IndexVisitor(Personality p) {
    super(p);
  }
 
  protected String getLoggerName() {
    return super.getLoggerName() + ".index";
  }

  public void visitIndex(SpeedoIndex si, SpeedoPackage sp) throws SpeedoException {
      //try to find the column name(s)
      if (si.columnNames.isEmpty()) {
        for (Iterator it = si.fieldNames.iterator(); it.hasNext(); ) {
          String fieldName = (String) it.next();
          //try to add the column name(s) to the index
              SpeedoField sf = (SpeedoField) si.speedoClass.fields.get(fieldName);
              if( sf.columns != null  && sf.columns.length != 0) {
                for(int i = 0; i < sf.columns.length; i++) {
                  si.columnNames.add(sf.columns[i].name);
                }
              } else {
                //by default, it is the field name
                si.columnNames.add(fieldName);
              }
        }
      }
      sp.xmlDescriptor.mos.add(si);
      super.visitIndex(si, sp);
  }
}
TOP

Related Classes of org.objectweb.speedo.generation.mivisitor.IndexVisitor

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.