ftpcontainer.java

来自「JavaExplorer是一个独立于平台的浏览器」· Java 代码 · 共 149 行

JAVA
149
字号
/**  * File and FTP Explorer  * Copyright 2002  * BOESCH Vincent  *  * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  */package javaexplorer.util.ftp;import objectxml.*;import java.util.Arrays;import javaexplorer.util.comparator.FtpComparator;public class FtpContainer extends Ftp implements Xmlizable {    private Ftp[] _ftps = null;    /**     *  Constructeur objet FtpContainer     */    public FtpContainer() {        super();    }    /**     *  Adds a feature to the Ftp attribute     *  of the FtpContainer object     *     *@param  ftp  The feature to be added     *      to the Ftp attribute     */    public void addFtp(Ftp ftp) {        if (ftp == null) {            return;        }        if (_ftps == null) {            _ftps = new Ftp[1];            _ftps[0] = ftp;        } else {            int index = getFtpIndex(ftp.getTitle());            if (index != -1) {                _ftps[index] = ftp;            } else {                Ftp[] newSc = new Ftp[_ftps.length + 1];                System.arraycopy(_ftps, 0, newSc, 0, _ftps.length);                newSc[newSc.length - 1] = ftp;                _ftps = newSc;            }            Arrays.sort(_ftps, FtpComparator.getComparator());        }    }    /**     *  Gets the childCount attribute of the     *  FtpContainer object     *     *@return    The childCount value     */    public int getChildCount() {        return ((_ftps == null) ? 0 : _ftps.length);    }    /**     *  Gets the ftp attribute of the FtpContainer     *  object     *     *@param  title  Description of the Parameter     *@return        The ftp value     */    public Ftp getFtp(String title) {        int index = getFtpIndex(title);        if (index == -1) {            return null;        }        return _ftps[index];    }    /**     *  Gets the ftpAt attribute of the FtpContainer     *  object     *     *@param  index  Description of the Parameter     *@return        The ftpAt value     */    public Ftp getFtpAt(int index) {        if ((index < 0) || (index > getChildCount())) {            return null;        }        return _ftps[index];    }    /**     *  Gets the ftpIndex attribute of the     *  FtpContainer object     *     *@param  title  Description of the Parameter     *@return        The ftpIndex value     */    public int getFtpIndex(String title) {        if ((_ftps == null) || (title == null)) {            return -1;        }        for (int i = 0; i < _ftps.length; i++) {            if (title.equalsIgnoreCase(_ftps[i].getTitle())) {                return i;            }        }        return -1;    }    /**     *  Gets the ftps attribute of the FtpContainer     *  object     *     *@return    The ftps value     */    public Ftp[] getFtps() {        return _ftps;    }    /**     *@param  title  Description of the Parameter     */    public void removeFtp(String title) {        int index = getFtpIndex(title);        //Ftp non trouv

⌨️ 快捷键说明

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