| 1 | /******************************************************************************* | 
| 2 |  * Copyright (c) 2008 IBM Corporation and others. | 
| 3 |  * All rights reserved. This program and the accompanying materials | 
| 4 |  * are made available under the terms of the Eclipse Public License v1.0 | 
| 5 |  * which accompanies this distribution, and is available at | 
| 6 |  * http://www.eclipse.org/legal/epl-v10.html | 
| 7 |  * | 
| 8 |  * Contributors: | 
| 9 |  *     IBM Corporation - initial API and implementation | 
| 10 |  *******************************************************************************/ | 
| 11 | package org.eclipse.pde.api.tools.internal.model; | 
| 12 |   | 
| 13 | import java.util.Iterator; | 
| 14 | import java.util.List; | 
| 15 |   | 
| 16 | import org.eclipse.core.runtime.CoreException; | 
| 17 | import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement; | 
| 18 | import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer; | 
| 19 |   | 
| 20 | /** | 
| 21 |  * A collection of class file containers. | 
| 22 |  *  | 
| 23 |  * @since 1.0 | 
| 24 |  */ | 
| 25 | public class CompositeApiTypeContainer extends AbstractApiTypeContainer { | 
| 26 |          | 
| 27 |         private List fContainers; | 
| 28 |          | 
| 29 |         /** | 
| 30 |          * Constructs a composite container on the given list of containers. | 
| 31 |          *  | 
| 32 |          * @param containers list of containers | 
| 33 |          */ | 
| 34 |         public CompositeApiTypeContainer(IApiElement parent, List containers) { | 
| 35 |                 super(parent, IApiElement.API_TYPE_CONTAINER, "Composite Class File Container"); //$NON-NLS-1$ | 
| 36 |                 this.fContainers = containers; | 
| 37 |         } | 
| 38 |   | 
| 39 |         /* (non-Javadoc) | 
| 40 |          * @see org.eclipse.pde.api.tools.internal.AbstractApiTypeContainer#createClassFileContainers() | 
| 41 |          */ | 
| 42 |         protected List createApiTypeContainers() throws CoreException { | 
| 43 |                 return fContainers; | 
| 44 |         } | 
| 45 |          | 
| 46 |         /** | 
| 47 |          * @see java.lang.Object#toString() | 
| 48 |          */ | 
| 49 |         public String toString() { | 
| 50 |                 StringBuffer buff = new StringBuffer(); | 
| 51 |                 buff.append("Composite Class File Container:\n"); //$NON-NLS-1$ | 
| 52 |                 if(fContainers == null) { | 
| 53 |                         buff.append("\t<EMPTY>"); //$NON-NLS-1$ | 
| 54 |                 } | 
| 55 |                 else { | 
| 56 |                         IApiTypeContainer container = null; | 
| 57 |                         for(Iterator iter = fContainers.iterator(); iter.hasNext();) { | 
| 58 |                                 container = (IApiTypeContainer) iter.next(); | 
| 59 |                                 buff.append("\t"+container.toString()); //$NON-NLS-1$ | 
| 60 |                         } | 
| 61 |                 } | 
| 62 |                 return buff.toString(); | 
| 63 |         } | 
| 64 | } |