# Class ActiveShellExpression

java.lang.Object
org.eclipse.core.expressions.Expression
org.eclipse.ui.ActiveShellExpression

public final class ActiveShellExpression extends Expression

An expression that checks the active shell variable. The variable name is `ISources.ACTIVE_SHELL_NAME` and falls back to `ISources.ACTIVE_WORKBENCH_WINDOW`. That is, if the active shell doesn't match, then it will be allowed to match the active workbench window.

Since:
  3.1

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`SOURCES`
The sources value to use with this expression.

### Fields inherited from class Expression

`ATT_VALUE, FALSE, HASH_CODE_NOT_COMPUTED, HASH_FACTOR, TRUE`

## Constructor Summary

Constructors
Constructor
Description
`ActiveShellExpression(Shell activeShell)`
Constructs a new instance of `ActiveShellExpression`

## Method Summary

Modifier and Type
Method
Description
`void`
`collectExpressionInfo(ExpressionInfo info)`
Expression information for this expression.
`protected int`
`computeHashCode()`
Method to compute the hash code for this object.
`boolean`
`equals(Object object)`
`EvaluationResult`
`evaluate(IEvaluationContext context)`
Evaluates this expression.
`String`
`toString()`

### Methods inherited from class Expression

`computeExpressionInfo, equals, equals, hashCode, hashCode, hashCode`

### Methods inherited from class Object

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

## Field Details

### SOURCES

public static final int SOURCES
The sources value to use with this expression.

See Also:
  - Constant Field Values

## Constructor Details

### ActiveShellExpression

public ActiveShellExpression(Shell activeShell)
Constructs a new instance of `ActiveShellExpression`

Parameters:
  `activeShell` - The shell to match with the active shell; `null` if it will match any active shell.

## Method Details

### collectExpressionInfo

public void collectExpressionInfo(ExpressionInfo info)
Expression information for this expression. Namely active shell and active workbench window name.

Overrides:
  `collectExpressionInfo` in class `Expression`
Parameters:
  `info` - the expression information object used to collect the information
Since:
  3.2

### computeHashCode

protected int computeHashCode()
Description copied from class: `Expression`
Method to compute the hash code for this object. The result returned from this method in cached in the `fHashCode` field. If the value returned from the method equals `Expression.HASH_CODE_NOT_COMPUTED` (e.g. `-1`) then the value is incremented by one.

This default implementation calls `super.hashCode()`

Overrides:
  `computeHashCode` in class `Expression`
Returns:
  a hash code for this object.

### equals

public boolean equals(Object object)

Overrides:
  `equals` in class `Object`

### evaluate

public EvaluationResult evaluate(IEvaluationContext context)
Evaluates this expression. If the active shell defined by the context matches the shell from this expression, then this evaluates to `EvaluationResult.TRUE`. Similarly, if the active workbench window shell defined by the context matches the shell from this expression, then this evaluates to `EvaluationResult.TRUE`.

Specified by:
  `evaluate` in class `Expression`
Parameters:
  `context` - The context from which the current state is determined; must not be `null`.
Returns:
  `EvaluationResult.TRUE` if the shell is active; `EvaluationResult.FALSE` otherwise.

### toString

public String toString()

Overrides:
  `toString` in class `Object`