亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? packagesorter.java

?? 該源代碼為一些通用的程序
?? JAVA
字號:
/* ========================================================================
 * JCommon : a free general purpose class library for the Java(tm) platform
 * ========================================================================
 *
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
 * 
 * Project Info:  http://www.jfree.org/jcommon/index.html
 *
 * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
 * USA.  
 *
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
 * in the United States and other countries.]
 * 
 * ------------------
 * PackageSorter.java
 * ------------------
 * (C)opyright 2003, 2004, by Thomas Morgner and Contributors.
 *
 * Original Author:  Thomas Morgner;
 * Contributor(s):   David Gilbert (for Object Refinery Limited);
 *
 * $Id: PackageSorter.java,v 1.2 2005/10/18 13:14:50 mungady Exp $
 *
 * Changes
 * -------
 * 02-Sep-2003 : Initial version
 * 07-Jun-2004 : Added JCommon header (DG);
 * 
 */

package org.jfree.base.modules;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import org.jfree.util.Log;

/**
 * Compares two modules for order. A module is considered less than an other
 * module if the module is a required module of the compared module. Modules
 * are considered equal if they have no relation.
 * <p>
 * When sorting, we match this modules position against all dependent
 * modules until all positions are stable. Circular references are evil
 * and are filtered during the module loading process in the package manager. 
 *
 * @author Thomas Morgner
 */
public final class PackageSorter
{
  /**
   * An Internal wrapper class which collects additional information
   * on the given module. Every module has a position, which is heigher
   * than the position of all dependent modules.
   * 
   * @author Thomas Morgner
   */
  private static class SortModule implements Comparable
  {
    /** stores the relative position of the module in the global list. */ 
    private int position;
    /** The package state of the to be matched module. */
    private final PackageState state;
    /** A list of all directly dependent subsystems. */
    private ArrayList dependSubsystems;
    // direct dependencies, indirect ones are handled by the
    // dependent classes ...

    /**
     * Creates a new SortModule for the given package state. 
     * 
     * @param state the package state object, that should be wrapped up
     * by this class. 
     */
    public SortModule(final PackageState state)
    {
      this.position = -1;
      this.state = state;
    }

    /**
     * Returns the list of all dependent subsystems. The list gets defined
     * when the sorting is started.
     * 
     * @return the list of all dependent subsystems.
     */
    public ArrayList getDependSubsystems()
    {
      return this.dependSubsystems;
    }

    /**
     * Defines a list of dependent subsystems for this module. The list contains
     * the names of the dependent subsystems as strings.
     * 
     * @param dependSubsystems a list of all dependent subsystems. 
     */
    public void setDependSubsystems(final ArrayList dependSubsystems)
    {
      this.dependSubsystems = dependSubsystems;
    }

    /**
     * Returns the current position of this module in the global list.
     * The position is computed by comparing all positions of all dependent
     * subsystem modules.
     * 
     * @return the current module position.
     */
    public int getPosition()
    {
      return this.position;
    }

    /**
     * Defines the position of this module in the global list of all
     * known modules.
     * 
     * @param position the position.
     */
    public void setPosition(final int position)
    {
      this.position = position;
    }

    /**
     * Returns the package state contained in this SortModule.
     * 
     * @return the package state of this module.
     */
    public PackageState getState()
    {
      return this.state;
    }

    /**
     * Returns a basic string representation of this SortModule. This
     * should be used for debugging purposes only. 
     * @see java.lang.Object#toString()
     * 
     * @return a string representation of this module.
     */
    public String toString ()
    {
      final StringBuffer buffer = new StringBuffer();
      buffer.append("SortModule: ");
      buffer.append(this.position);
      buffer.append(" ");
      buffer.append(this.state.getModule().getName());
      buffer.append(" ");
      buffer.append(this.state.getModule().getModuleClass());
      return buffer.toString();
    }

    /**
     * Compares this module against an other sort module.
     *  
     * @see java.lang.Comparable#compareTo(java.lang.Object)
     * 
     * @param o the other sort module instance.
     * @return -1 if the other's module position is less than
     * this modules position, +1 if this module is less than the
     * other module or 0 if both modules have an equal position in
     * the list.
     */
    public int compareTo(final Object o)
    {
      final SortModule otherModule = (SortModule) o;
      if (this.position > otherModule.position)
      {
        return +1;
      }
      if (this.position < otherModule.position)
      {
        return -1;
      }
      return 0;
    }
  }

  /**
   * DefaultConstructor.
   */
  private PackageSorter() {
      // nothing required.
  }

  /**
   * Sorts the given list of package states. The packages
   * are sorted by their dependencies in a way so that all
   * dependent packages are placed on lower positions than
   * the packages which declared the dependency. 
   *
   * @param modules the list of modules.
   */
  public static void sort (final List modules)
  {
    final HashMap moduleMap = new HashMap();
    final ArrayList errorModules = new ArrayList();
    final ArrayList weightModules = new ArrayList();

    for (int i = 0; i < modules.size(); i++)
    {
      final PackageState state = (PackageState) modules.get(i);
      if (state.getState() == PackageState.STATE_ERROR)
      {
        errorModules.add (state);
      }
      else
      {
        final SortModule mod = new SortModule(state);
        weightModules.add (mod);
        moduleMap.put(state.getModule().getModuleClass(), mod);
      }
    }

    final SortModule[] weigths = (SortModule[])
        weightModules.toArray(new SortModule[weightModules.size()]);

    for (int i = 0; i < weigths.length; i++)
    {
      final SortModule sortMod = weigths[i];
      sortMod.setDependSubsystems
          (collectSubsystemModules(sortMod.getState().getModule(),
              moduleMap));
    }


    // repeat the computation until all modules have a matching
    // position. This is not the best algorithm, but it works
    // and is relativly simple. It will need some optimizations
    // in the future, but as this is only executed once, we don't
    // have to care much about it.
    boolean doneWork = true;
    while (doneWork)
    {
      doneWork = false;
      for (int i = 0; i < weigths.length; i++)
      {
        final SortModule mod = weigths[i];
        final int position = searchModulePosition(mod, moduleMap);
        if (position != mod.getPosition())
        {
          mod.setPosition(position);
          doneWork = true;
        }
      }
    }

    Arrays.sort(weigths);
    modules.clear();
    for (int i = 0; i < weigths.length; i++)
    {
      modules.add (weigths[i].getState());
    }
    for (int i = 0; i < errorModules.size(); i++)
    {
      modules.add (errorModules.get(i));
    }
  }

  /**
   * Computes the new module position. This position is computed
   * according to the dependent modules and subsystems. The returned
   * position will be higher than the highest dependent module position.
   *
   * @param smodule the sort module for that we compute the new positon.
   * @param moduleMap the map with all modules.
   * @return the new positon.
   */
  private static int searchModulePosition
      (final SortModule smodule, final HashMap moduleMap)
  {
    final Module module = smodule.getState().getModule();
    int position = 0;

    // check the required modules. Increase our level to at least
    // one point over the highest dependent module
    // ignore missing modules.
    ModuleInfo[] modInfo = module.getOptionalModules();
    for (int modPos = 0; modPos < modInfo.length; modPos++)
    {
      final String moduleName = modInfo[modPos].getModuleClass();
      final SortModule reqMod = (SortModule) moduleMap.get(moduleName);
      if (reqMod == null)
      {
        continue;
      }
      if (reqMod.getPosition() >= position)
      {
        position = reqMod.getPosition() + 1;
      }
    }

    // check the required modules. Increase our level to at least
    // one point over the highest dependent module
    // there are no missing modules here (or the package manager
    // is invalid)
    modInfo = module.getRequiredModules();
    for (int modPos = 0; modPos < modInfo.length; modPos++)
    {
      final String moduleName = modInfo[modPos].getModuleClass();
      final SortModule reqMod = (SortModule) moduleMap.get(moduleName);
      if (reqMod.getPosition() >= position)
      {
        position = reqMod.getPosition() + 1;
      }
    }

    // check the subsystem dependencies. This way we make sure
    // that subsystems are fully initialized before we try to use
    // them.
    final String subSystem = module.getSubSystem();
    final Iterator it = moduleMap.values().iterator();
    while (it.hasNext())
    {
      final SortModule mod = (SortModule) it.next();
      // it is evil to compute values on ourself...
      if (mod.getState().getModule() == module)
      {
        // same module ...
        continue;
      }
      final Module subSysMod = mod.getState().getModule();
      // if the module we check is part of the same subsystem as
      // we are, then we dont do anything. Within the same subsystem
      // the dependencies are computed solely by the direct references.
      if (subSystem.equals(subSysMod.getSubSystem()))
      {
        // same subsystem ... ignore
        continue;
      }

      // does the module from the global list <mod> depend on the
      // subsystem we are part of?
      //
      // if yes, we have a relation and may need to adjust the level...
      if (smodule.getDependSubsystems().contains(subSysMod.getSubSystem()))
      {
        // check whether the module is a base module of the given
        // subsystem. We will not adjust our position in that case,
        // as this would lead to an infinite loop
        if (isBaseModule(subSysMod, module) == false)
        {
          if (mod.getPosition() >= position)
          {
            position = mod.getPosition() + 1;
          }
        }
      }
    }
    return position;
  }

  /**
   * Checks, whether a module is a base module of an given module.
   *
   * @param mod the module which to check
   * @param mi the module info of the suspected base module.
   * @return true, if the given module info describes a base module of the
   * given module, false otherwise.
   */
  private static boolean isBaseModule(final Module mod, final ModuleInfo mi)
  {
    ModuleInfo[] info = mod.getRequiredModules();
    for (int i = 0; i < info.length; i++)
    {
      if (info[i].getModuleClass().equals(mi.getModuleClass()))
      {
        return true;
      }
    }
    info = mod.getOptionalModules();
    for (int i = 0; i < info.length; i++)
    {
      if (info[i].getModuleClass().equals(mi.getModuleClass()))
      {
        return true;
      }
    }
    return false;
  }


  /**
   * Collects all directly dependent subsystems.
   *
   * @param childMod the module which to check
   * @param moduleMap the map of all other modules, keyed by module class.
   * @return the list of all dependent subsystems.
   */
  private static ArrayList collectSubsystemModules
      (final Module childMod, final HashMap moduleMap)
  {
    final ArrayList collector = new ArrayList();
    ModuleInfo[] info = childMod.getRequiredModules();
    for (int i = 0; i < info.length; i++)
    {
      final SortModule dependentModule = (SortModule)
          moduleMap.get(info[i].getModuleClass());
      if (dependentModule == null)
      {
        Log.warn 
          (new Log.SimpleMessage
            ("A dependent module was not found in the list of known modules.",
            info[i].getModuleClass()));
        continue;
      }

      collector.add (dependentModule.getState().getModule().getSubSystem());
    }

    info = childMod.getOptionalModules();
    for (int i = 0; i < info.length; i++)
    {
      final Module dependentModule = (Module)
          moduleMap.get(info[i].getModuleClass());
      if (dependentModule == null)
      {
        Log.warn ("A dependent module was not found in the list of known modules.");
        continue;
      }
      collector.add (dependentModule.getSubSystem());
    }
    return collector;
  }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99热这里都是精品| 丝袜国产日韩另类美女| 国产精品一区二区x88av| 欧美成人vps| 国产激情精品久久久第一区二区| 精品国产伦一区二区三区免费| 美女国产一区二区| 国产欧美日韩亚州综合| av高清久久久| 日韩电影免费一区| 日韩欧美专区在线| 国产suv精品一区二区三区| 国产精品视频一区二区三区不卡| 99久久er热在这里只有精品15| 一区二区在线观看免费视频播放| 欧美日韩国产综合久久| 久久99精品久久久| 国产精品久久久久影院老司| 欧美亚洲综合色| 黄一区二区三区| 中文字幕一区二区三区四区不卡| 欧美三级日本三级少妇99| 麻豆成人av在线| 中文字幕一区二| 欧美一区永久视频免费观看| 国产伦精品一区二区三区免费迷| 日韩美女精品在线| 91精品国产品国语在线不卡| 成人中文字幕在线| 亚洲高清在线精品| 国产无遮挡一区二区三区毛片日本| 色综合久久久久网| 另类小说综合欧美亚洲| 成人免费在线视频| 日韩欧美在线观看一区二区三区| 不卡的电影网站| 美女尤物国产一区| 亚洲另类中文字| 久久久久久免费网| 欧美日本在线视频| 99riav一区二区三区| 老司机午夜精品99久久| 一区二区三区欧美在线观看| 精品国产一区二区三区久久久蜜月 | 日本一不卡视频| 国产精品九色蝌蚪自拍| 精品久久五月天| 欧美日韩高清一区二区不卡| 成人99免费视频| 国内精品伊人久久久久av影院 | 美腿丝袜在线亚洲一区| 亚洲久本草在线中文字幕| 久久综合成人精品亚洲另类欧美| 欧美在线播放高清精品| 豆国产96在线|亚洲| 麻豆国产精品一区二区三区| 亚洲国产精品综合小说图片区| 国产精品久久网站| 久久久亚洲高清| 日韩三级免费观看| 欧美日韩黄色影视| 一本久久精品一区二区| 顶级嫩模精品视频在线看| 美女国产一区二区三区| 天天做天天摸天天爽国产一区 | 久久久综合网站| 欧美一区二区三区四区在线观看| 欧美综合天天夜夜久久| 91在线一区二区三区| av福利精品导航| 99久久婷婷国产综合精品电影 | 色哟哟国产精品| 北条麻妃一区二区三区| 国产成人精品影视| 国产电影一区二区三区| 国产精品2024| 成人一区二区三区视频在线观看| 国产精品一区免费在线观看| 国产不卡在线一区| av男人天堂一区| 色偷偷88欧美精品久久久| 色欲综合视频天天天| 91麻豆文化传媒在线观看| 91欧美一区二区| 欧美在线free| 欧美精品三级在线观看| 欧美一区二区三区色| 日韩一二三四区| 久久久久久影视| 亚洲国产电影在线观看| 日韩理论在线观看| 亚洲国产精品久久久久秋霞影院 | 欧美成人三级在线| 久久综合狠狠综合久久综合88 | 亚洲柠檬福利资源导航| 一区二区三区在线免费播放| 亚洲成人免费在线观看| 久久综合综合久久综合| 国产毛片精品国产一区二区三区| 成人精品一区二区三区四区| 91蝌蚪porny九色| 在线不卡欧美精品一区二区三区| 日韩欧美成人一区二区| 国产日韩欧美电影| 一区二区三区在线观看网站| 日韩电影在线一区二区三区| 国产一区二区三区不卡在线观看| av在线不卡观看免费观看| 一本大道久久精品懂色aⅴ| 欧美高清视频在线高清观看mv色露露十八 | 国产成人综合视频| 色噜噜偷拍精品综合在线| 日韩一级免费一区| 国产精品欧美一区二区三区| 亚洲va欧美va人人爽| 国产一区二区三区免费在线观看 | 国产成人综合在线播放| 91黄色激情网站| 日韩欧美国产高清| 亚洲色图.com| 韩国精品免费视频| 日本伦理一区二区| xvideos.蜜桃一区二区| 亚洲黄色片在线观看| 激情久久五月天| 日本韩国精品一区二区在线观看| 久久综合中文字幕| 亚洲国产日韩综合久久精品| 国产精品系列在线播放| 欧美狂野另类xxxxoooo| 国产精品妹子av| 久草在线在线精品观看| 欧美综合一区二区| 国产精品国产自产拍高清av| 奇米一区二区三区| 91丝袜美女网| 中文字幕在线观看不卡视频| 日韩av中文在线观看| 91美女蜜桃在线| 久久久99精品久久| 免费高清在线视频一区·| 日本高清不卡视频| 国产欧美精品国产国产专区| 奇米888四色在线精品| 欧美性受极品xxxx喷水| 中文字幕一区二区三区在线观看| 韩国女主播成人在线观看| 777a∨成人精品桃花网| 亚洲一区二区三区四区五区中文| 成人精品电影在线观看| 久久久精品欧美丰满| 极品少妇xxxx偷拍精品少妇| 欧美电影一区二区| 天天综合网 天天综合色| 色婷婷综合激情| 亚洲欧美日韩在线播放| 成人av免费在线播放| 国产日韩欧美一区二区三区乱码| 狠狠v欧美v日韩v亚洲ⅴ| 日韩欧美不卡一区| 久久99精品久久久久久动态图| 91精品视频网| 秋霞电影一区二区| 91精品国产高清一区二区三区蜜臀 | 在线看国产日韩| 一区二区三区免费看视频| 91日韩精品一区| 亚洲靠逼com| 欧美午夜精品一区| 亚洲国产乱码最新视频| 欧美精品在线视频| 青青草国产精品97视觉盛宴| 欧美一卡二卡在线| 久久 天天综合| 欧美国产乱子伦| 91免费版pro下载短视频| 一区二区三区精密机械公司| 欧美色老头old∨ideo| 视频精品一区二区| 精品国产亚洲一区二区三区在线观看| 伦理电影国产精品| 久久精品日韩一区二区三区| 成人久久视频在线观看| 玉足女爽爽91| 911国产精品| 国产在线精品一区二区夜色| 国产欧美一区视频| 91麻豆.com| 日韩福利视频导航| 精品999久久久| 99久久精品国产导航| 国产在线精品视频| 国产精品水嫩水嫩| 欧美亚洲一区二区三区四区| 秋霞影院一区二区| 国产亚洲精品bt天堂精选| 91在线无精精品入口| 中文字幕成人av| 成人av在线一区二区三区| 樱桃视频在线观看一区|