# Class PositionInfo

java.lang.Object
org.eclipse.e4.ui.model.internal.PositionInfo

public final class PositionInfo extends Object
A holder class for the full information to position an element in a list.

Author:
  René Brandstetter

## Field Summary

Fields
Modifier and Type
Field
Description
`static final PositionInfo`
`FIRST`
The `PositionInfo` which represent an insert at the beginning of the list.
`static final PositionInfo`
`LAST`
The `PositionInfo` which represent an insert at the end of the list.

## Constructor Summary

Constructors
Constructor
Description
`PositionInfo(Position position, String positionReference)`
Creates an instance of the PositionInfo.

## Method Summary

Modifier and Type
Method
Description
`Position`
`getPosition()`
Returns the kind/type of positioning which should be used.
`String`
`getPositionReference()`
Returns additional information which is needed to place an element.
`int`
`getPositionReferenceAsInteger()`
Returns the additional information which is needed to place an element as an int.
`static PositionInfo`
`parse(String positionInfo)`
Creates a `PositionInfo` object out of the given positioning string.
`String`
`toString()`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### FIRST

public static final PositionInfo FIRST
The `PositionInfo` which represent an insert at the beginning of the list.

### LAST

public static final PositionInfo LAST
The `PositionInfo` which represent an insert at the end of the list.

## Constructor Details

### PositionInfo

public PositionInfo(Position position, String positionReference)
Creates an instance of the PositionInfo.

Parameters:
  `position` - the kind of the positioning
  `positionReference` - additional information which is need to position an element (e.g.: index, ID of another element)
Throws:
  `NullPointerException` - if the `position` is `null`

## Method Details

### getPosition

public Position getPosition()
Returns the kind/type of positioning which should be used.

Returns:
  the position

### getPositionReference

public String getPositionReference()
Returns additional information which is needed to place an element.

Returns:
  the positionReference, or `null` if no additional information is given

### getPositionReferenceAsInteger

public int getPositionReferenceAsInteger()
Returns the additional information which is needed to place an element as an int.

Returns:
  the positionReference as an int
Throws:
  `NumberFormatException` - if the `positionReference` can't be parsed to an int
  `NullPointerException` - if the `positionReference` is `null`

### parse

public static PositionInfo parse(String positionInfo)
Creates a `PositionInfo` object out of the given positioning string.

Examples for a positioning string:

- `last` - place an element to the end of a list
- `first` - place an element to the beginning of a list
- `index:3` - place an element at the provided index 3 in a list
- `before:org.eclipse.test.id` - place an element in a list in front of the element with the ID "org.eclipse.test.id"
- `after:org.eclipse.test.id` - place an element in a list after the element with the ID "org.eclipse.test.id"

Parameters:
  `positionInfo` - the positioning string
Returns:
  a `PositionInfo` which holds all the data mentioned in the positioning string, or `null` if the positioning string doesn't hold a positioning information

### toString

public String toString()

Overrides:
  `toString` in class `Object`