1 /******************************************************************************* 2 * Copyright (c) 2000, 2006 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.jface.viewers; 12 13 import java.util.Iterator; 14 import java.util.List; 15 16 /** 17 * A selection containing elements. 18 */ 19 public interface IStructuredSelection extends ISelection { 20 /** 21 * Returns the first element in this selection, or <code>null</code> 22 * if the selection is empty. 23 * 24 * @return an element, or <code>null</code> if none 25 */ 26 public Object getFirstElement(); 27 28 /** 29 * Returns an iterator over the elements of this selection. 30 * 31 * @return an iterator over the selected elements 32 */ 33 public Iterator iterator(); 34 35 /** 36 * Returns the number of elements selected in this selection. 37 * 38 * @return the number of elements selected 39 */ 40 public int size(); 41 42 /** 43 * Returns the elements in this selection as an array. 44 * 45 * @return the selected elements as an array 46 */ 47 public Object[] toArray(); 48 49 /** 50 * Returns the elements in this selection as a <code>List</code>. 51 * 52 * @return the selected elements as a list 53 */ 54 public List toList(); 55 } 56