Rambler's Top100
/*
 *  Copyright (C) 2004 Roman Krylov
 *  rkrylov@mail.ru
 *  
 *
 *  This program 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 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 Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

package org.JWrapper;

public class JSimpleCompositeWrapper extends JCompositeWrapper
{
    protected java.util.Vector children
            = new java.util.Vector();
    
    public JSimpleCompositeWrapper(String _name)
        {
        super(_name);
        }
    
    public final int size() { return children.size(); }
    
    public JWrapper[] getChildren()
        {
        /*
         * In j2se 1.4 there was a bug:
         * if vector's size is 0, toArray returns T[1] containing null.
         * Don't know about 1.5, but let's do it for safety.
         */
        if(children.size()==0)
        { return new JWrapper[0]; } else
        { return (JWrapper[]) children.toArray(new JWrapper[0]); }
        }
    
    public JSimpleCompositeWrapper add(JWrapper wrp) throws Exception
        {
        wrp.parent=this;
        children.add(wrp);
        childAdded.Op(wrp);
        return this;
        }
    
    public JSimpleCompositeWrapper add(int i, JWrapper wrp) throws Exception
        {
        wrp.parent=this;
        children.add(i,wrp);
        childAdded.Op(wrp);
        return this;
        }
    
    public int indexOf(JWrapper wrp)
        { return children.indexOf(wrp); }
    
    public void remove(JWrapper wrp) throws Exception
        {
        children.remove(wrp);
        childRemoved.Op(wrp);
        }
    public void removeAll() throws Exception
        {
        children.clear();
        }
}

Предприятие реального времени №1

На главную   Новости   Карта сайта
  Rambler's Top100