1.1 --- a/src/net/fortuna/ical4j/model/ComponentList.java Thu Feb 12 18:02:00 2015 +0100 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,186 +0,0 @@ 1.4 -/** 1.5 - * Copyright (c) 2012, Ben Fortuna 1.6 - * All rights reserved. 1.7 - * 1.8 - * Redistribution and use in source and binary forms, with or without 1.9 - * modification, are permitted provided that the following conditions 1.10 - * are met: 1.11 - * 1.12 - * o Redistributions of source code must retain the above copyright 1.13 - * notice, this list of conditions and the following disclaimer. 1.14 - * 1.15 - * o Redistributions in binary form must reproduce the above copyright 1.16 - * notice, this list of conditions and the following disclaimer in the 1.17 - * documentation and/or other materials provided with the distribution. 1.18 - * 1.19 - * o Neither the name of Ben Fortuna nor the names of any other contributors 1.20 - * may be used to endorse or promote products derived from this software 1.21 - * without specific prior written permission. 1.22 - * 1.23 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.24 - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.25 - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.26 - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 1.27 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1.28 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1.29 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1.30 - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 1.31 - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 1.32 - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 1.33 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.34 - */ 1.35 -package net.fortuna.ical4j.model; 1.36 - 1.37 -import java.io.IOException; 1.38 -import java.io.Serializable; 1.39 -import java.net.URISyntaxException; 1.40 -import java.text.ParseException; 1.41 -import java.util.ArrayList; 1.42 -import java.util.Iterator; 1.43 - 1.44 -/** 1.45 - * $Id$ [Apr 5, 2004] 1.46 - * 1.47 - * Defines a list of iCalendar components. 1.48 - * @author Ben Fortuna 1.49 - */ 1.50 -public class ComponentList extends ArrayList implements Serializable { 1.51 - 1.52 - private static final long serialVersionUID = 7308557606558767449L; 1.53 - 1.54 - /** 1.55 - * Default constructor. 1.56 - */ 1.57 - public ComponentList() { 1.58 - } 1.59 - 1.60 - /** 1.61 - * Creates a new instance with the specified initial capacity. 1.62 - * @param initialCapacity the initial capacity of the list 1.63 - */ 1.64 - public ComponentList(final int initialCapacity) { 1.65 - super(initialCapacity); 1.66 - } 1.67 - 1.68 - /** 1.69 - * Creates a deep copy of the specified component list. 1.70 - * @param components a component list to copy 1.71 - * @throws IOException where an error occurs reading component data 1.72 - * @throws ParseException where component data cannot be parsed 1.73 - * @throws URISyntaxException where component data contains an invalid URI 1.74 - */ 1.75 - public ComponentList(ComponentList components) throws ParseException, 1.76 - IOException, URISyntaxException { 1.77 - 1.78 - for (final Iterator i = components.iterator(); i.hasNext();) { 1.79 - final Component c = (Component) i.next(); 1.80 - add(c.copy()); 1.81 - } 1.82 - } 1.83 - 1.84 - /** 1.85 - * {@inheritDoc} 1.86 - */ 1.87 - public final String toString() { 1.88 - final StringBuffer buffer = new StringBuffer(); 1.89 - for (final Iterator i = iterator(); i.hasNext();) { 1.90 - buffer.append(i.next().toString()); 1.91 - } 1.92 - return buffer.toString(); 1.93 - } 1.94 - 1.95 - /** 1.96 - * Returns the first component of specified name. 1.97 - * @param aName name of component to return 1.98 - * @return a component or null if no matching component found 1.99 - */ 1.100 - public final Component getComponent(final String aName) { 1.101 - for (final Iterator i = iterator(); i.hasNext();) { 1.102 - final Component c = (Component) i.next(); 1.103 - if (c.getName().equals(aName)) { 1.104 - return c; 1.105 - } 1.106 - } 1.107 - return null; 1.108 - } 1.109 - 1.110 - /** 1.111 - * Returns a list containing all components with specified name. 1.112 - * @param name name of components to return 1.113 - * @return a list of components with the matching name 1.114 - */ 1.115 - public final ComponentList getComponents(final String name) { 1.116 - final ComponentList components = new ComponentList(); 1.117 - for (final Iterator i = iterator(); i.hasNext();) { 1.118 - final Component c = (Component) i.next(); 1.119 - if (c.getName().equals(name)) { 1.120 - components.add(c); 1.121 - } 1.122 - } 1.123 - return components; 1.124 - } 1.125 - 1.126 - /** 1.127 - * Add a component to the list. 1.128 - * @param component the component to add 1.129 - * @return true 1.130 - * @see java.util.List#add(Object) 1.131 - */ 1.132 - public final boolean add(final Component component) { 1.133 - return add((Object) component); 1.134 - } 1.135 - 1.136 - /** 1.137 - * Overrides superclass to throw an <code>IllegalArgumentException</code> where argument is not a 1.138 - * <code>net.fortuna.ical4j.model.Component</code>. 1.139 - * @param component a component to add 1.140 - * @return true if the object was added, otherwise false 1.141 - * @see java.util.List#add(Object) 1.142 - */ 1.143 - public final boolean add(final Object component) { 1.144 - if (!(component instanceof Component)) { 1.145 - throw new IllegalArgumentException("Argument not a " 1.146 - + Component.class.getName()); 1.147 - } 1.148 - return super.add(component); 1.149 - } 1.150 - 1.151 - /** 1.152 - * @return boolean indicates if the list is empty 1.153 - * @see java.util.List#isEmpty() 1.154 - */ 1.155 - // public final boolean isEmpty() { 1.156 - // return components.isEmpty(); 1.157 - // } 1.158 - /** 1.159 - * @return an iterator 1.160 - * @see java.util.List#iterator() 1.161 - */ 1.162 - // public final Iterator iterator() { 1.163 - // return components.iterator(); 1.164 - // } 1.165 - /** 1.166 - * Remove a component from the list. 1.167 - * @param component the component to remove 1.168 - * @return true if the list contained the specified component 1.169 - * @see java.util.List#remove(java.lang.Object) 1.170 - */ 1.171 - public final boolean remove(final Component component) { 1.172 - return remove((Object) component); 1.173 - } 1.174 - 1.175 - /** 1.176 - * @return the number of components in the list 1.177 - * @see java.util.List#size() 1.178 - */ 1.179 - // public final int size() { 1.180 - // return components.size(); 1.181 - // } 1.182 - /** 1.183 - * Provides a list containing all components contained in this component list. 1.184 - * @return a list 1.185 - */ 1.186 - // public final List toList() { 1.187 - // return new ArrayList(components); 1.188 - // } 1.189 -}