/*******************************************************************************
* Copyright (c)                                                                *
*           2005   Tristan Allwood,                                            *
*           2005   Daniel Burke,                                               *
*           2005   Marc Hull,                                                  *
*           2005   Ekaterina Itskova,                                          *
*           2005   Steve Zymler                                                *
*                                                                              *
* Permission is hereby granted, free of charge, to any person obtaining a      *
* copy of this software and associated documentation files (the                *
* "Software"), to deal in the Software without restriction, including          *
* without limitation the rights to use, copy, modify, merge, publish,          *
* distribute, sublicense, and/or sell copies of the Software, and to           *
* permit persons to whom the Software is furnished to do so, subject to        *
* the following conditions:                                                    *
*                                                                              *
* The above copyright notice and this permission notice shall be included      *
* in all copies or substantial portions of the Software.                       *
*                                                                              *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS      *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF                   *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.       *
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY         *
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,         *
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE            *
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                       *
*******************************************************************************/
/*
 * Created on 27-Nov-2004
 *
 */
package uk.ac.ic.doc.kevlar.gui.internal.keyboard;

/**
 * @author Marc
 **/
public class Group extends Item {

    public Item[] items;
    
    public Group(int... items) {

        super(-1);
        
        this.items = new Item[items.length];
        
        for (int i=0; i<items.length; i++) {
            
            this.items[i] = new Item(items[i]);
            
        }
        
    }
    
    public Group(Item... items) {

        super(-1);
        
        this.items = new Item[items.length];
        
        for (int i=0; i<items.length; i++) {
            
            this.items[i] = items[i];
            
        }
        
    }
    
    public Group(Group... items) {
        
        super(-1);
        
        int size = 0;
        
        for (Group g : items) {
            
            size += g.getItems().length;
            
        }
        
        this.items = new Item[size];
        int index = 0;
        
        for (Group g : items) {
            
            Item[] ints = g.getItems();
            
            for (Item i : ints) {
                
                this.items[index] = i;
                index++;
                
            }
            
        }
        
    }
    
    public Item[] getItems() {
        
        return items;
        
    }
    
    public String toString() {
    	
    	String result = "";
    	
    	for (int i=0; i<items.length; i++) {
    		
    		result += items[i].toString();
    		
    		if (i != 0) {
    			
    			result += ", ";
    			
    		}
    		
    	}
    	
    	return result;
    	
    }
    
}
