⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 generalutils.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
字号:
/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program 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 General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

 /**
  * Title: XELOPES Data Mining Library
  * Description: The XELOPES library is an open platform-independent and data-source-independent library for Embedded Data Mining.
  * Copyright: Copyright (c) 2002 Prudential Systems Software GmbH
  * Company: ZSoft (www.zsoft.ru), Prudsys (www.prudsys.com)
  * @author Carsten Weisse
  * @version 1.0
  */

package com.prudsys.pdm.Utils;

import com.prudsys.pdm.Core.*;

/**
 * Collection of utilies that are of general interest for XELOPES.
 */
public class GeneralUtils {

  /**
   * Display parameters of MiningAlgorithmSpecification.
   *
   * @param miningAlgorithmSpecification MiningAlgorithmSpefification whose parameters are displayed
   * @throws MiningException could not display parameters
   */
  public static void displayMiningAlgSpecParameters(MiningAlgorithmSpecification miningAlgorithmSpecification ) throws MiningException
    {
        String show = "";
        MiningAlgorithmParameter[] attribute = miningAlgorithmSpecification.getInputAttribute();
        if( attribute.length > 0 )
        {
            System.out.println("Algorithm parameters for " +  miningAlgorithmSpecification.getName());
        }
        String name, desc, method, type, value;
        for (int i = 0; i < attribute.length; i++)
        {
            name = attribute[i].getName();
            desc = attribute[i].getDescr();
            method = attribute[i].getMethod();
            type = attribute[i].getType();
            value = attribute[i].getValue();

            show = show + "Name = " + name + "; " + "Descr = " + desc + "; " + "Method = " + method + "; " + "Value = " + value + "; Type = " + type + "\n";
        }
        System.out.println( show );
    }

  /**
   * Create instance of MiningAlgorithm.
   *
   * @param className class name of algorithm object to be created
   * @return created algorithm instance
   * @exception MiningException cannot initialize algorithm
   */
  public static MiningAlgorithm createMiningAlgorithmInstance( String className) throws MiningException
  {
      Class algorithmClass = null;
      Object algorithm = null;
      try
      {
          algorithmClass = Class.forName( className, true, GeneralUtils.class.getClassLoader());
          algorithm = algorithmClass.newInstance();
      }
      catch( ClassNotFoundException ex)
      {
          throw new MiningException( "Class not found." );
      }
      catch( InstantiationException ie )
      {
          throw new MiningException( "Can't create class instance." );
      }
      catch ( IllegalAccessException iae )
      {
          throw new MiningException( "Illegal access exception." );
      }
      if( !(algorithm instanceof MiningAlgorithm) )
      {
          throw new MiningException( "Each algorithm has to implement MiningAlgorithm interface" );
      }
      MiningAlgorithm miningAlgorithm = (MiningAlgorithm)algorithm;

      return miningAlgorithm;
  }
  
  /**
   * Create instance of MiningAlgorithm.
   *
   * @param className class name of algorithm object to be created
   * @param classloader class loader from which the class must be loaded
   * @return created algorithm instance
   * @exception MiningException cannot initialize algorithm
   */
  public static MiningAlgorithm createMiningAlgorithmInstance( String className , ClassLoader classloader) throws MiningException
  {
      Class algorithmClass = null;
      Object algorithm = null;
      try
      {
          algorithmClass = Class.forName( className, true, classloader);
          algorithm = algorithmClass.newInstance();
      }
      catch( ClassNotFoundException ex)
      {
          throw new MiningException( "Class not found." );
      }
      catch( InstantiationException ie )
      {
          throw new MiningException( "Can't create class instance." );
      }
      catch ( IllegalAccessException iae )
      {
          throw new MiningException( "Illegal access exception." );
      }
      if( !(algorithm instanceof MiningAlgorithm) )
      {
          throw new MiningException( "Each algorithm has to implement MiningAlgorithm interface" );
      }
      MiningAlgorithm miningAlgorithm = (MiningAlgorithm)algorithm;

      return miningAlgorithm;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -