Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.jface.viewers
Class StructuredSelection

    java.lang.Object
      org.eclipse.jface.viewers.StructuredSelection

All Implemented Interfaces:
  ISelection, IStructuredSelection

public class StructuredSelection
extends Object
implements IStructuredSelection

A concrete implementation of the `IStructuredSelection` interface, suitable for instantiating.

This class is not intended to be subclassed.

Field Summary
`static StructuredSelection` | `EMPTY` The canonical empty selection.

Constructor Summary
`StructuredSelection()` Creates a new empty selection.
`StructuredSelection(List elements)` Creates a structured selection from the given `List`.
`StructuredSelection(Object element)` Creates a structured selection containing a single object.
`StructuredSelection(Object[] elements)` Creates a structured selection from the given elements.

Method Summary
`boolean` | `equals(Object o)` Returns whether this structured selection is equal to the given object.
`Object` | `getFirstElement()` Returns the first element in this selection, or `null` if the selection is empty.
`boolean` | `isEmpty()` Returns whether this selection is empty.
`Iterator` | `iterator()` Returns an iterator over the elements of this selection.
`int` | `size()` Returns the number of elements selected in this selection.
`Object[]` | `toArray()` Returns the elements in this selection as an array.
`List` | `toList()` Returns the elements in this selection as a `List`.
`String` | `toString()` Internal method which returns a string representation of this selection suitable for debug purposes only.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### EMPTY

    public static final StructuredSelection EMPTY

  The canonical empty selection. This selection should be used instead of `null`.

Constructor Detail

### StructuredSelection

    public StructuredSelection()

  Creates a new empty selection. See also the static field `EMPTY` which contains an empty selection singleton.

See Also:
  `EMPTY`

### StructuredSelection

    public StructuredSelection(Object[] elements)

  Creates a structured selection from the given elements.

Parameters:
  `elements` - an array of elements

### StructuredSelection

    public StructuredSelection(Object element)

  Creates a structured selection containing a single object. The object must not be `null`.

Parameters:
  `element` - the element

### StructuredSelection

    public StructuredSelection(List elements)

  Creates a structured selection from the given `List`.

Method Detail

### equals

    public boolean equals(Object o)

  Returns whether this structured selection is equal to the given object. Two structured selections are equal iff they contain the same elements in the same order.

  Parameters:
    `o` - the other object
  Returns:
    `true` if they are equal, and `false` otherwise

### getFirstElement

    public Object getFirstElement()

  Description copied from interface: `IStructuredSelection`
  Returns the first element in this selection, or `null` if the selection is empty.

  Specified by:
    `getFirstElement` in interface `IStructuredSelection`
  Returns:
    an element, or `null` if none

### isEmpty

    public boolean isEmpty()

  Description copied from interface: `ISelection`
  Returns whether this selection is empty.

  Specified by:
    `isEmpty` in interface `ISelection`
  Returns:
    `true` if this selection is empty, and `false` otherwise

### iterator

    public Iterator iterator()

  Description copied from interface: `IStructuredSelection`
  Returns an iterator over the elements of this selection.

  Specified by:
    `iterator` in interface `IStructuredSelection`
  Returns:
    an iterator over the selected elements

### size

    public int size()

  Description copied from interface: `IStructuredSelection`
  Returns the number of elements selected in this selection.

  Specified by:
    `size` in interface `IStructuredSelection`
  Returns:
    the number of elements selected

### toArray

    public Object[] toArray()

  Description copied from interface: `IStructuredSelection`
  Returns the elements in this selection as an array.

  Specified by:
    `toArray` in interface `IStructuredSelection`
  Returns:
    the selected elements as an array

### toList

    public List toList()

  Description copied from interface: `IStructuredSelection`
  Returns the elements in this selection as a `List`.

  Specified by:
    `toList` in interface `IStructuredSelection`
  Returns:
    the selected elements as a list

### toString

    public String toString()

  Internal method which returns a string representation of this selection suitable for debug purposes only.

  Returns:
    debug string

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.