Eclipse Platform
Release 3.2

org.eclipse.core.commands
Class State

java.lang.Object
  extended byorg.eclipse.core.commands.common.EventManager
      extended byorg.eclipse.core.commands.State
Direct Known Subclasses:
PersistentState

public class State
extends EventManager

A piece of state information that can be shared between objects, and might be persisted between sessions. This can be used for commands that toggle between two states and wish to pass this state information between different handlers.

This state object can either be used as a single state object shared between several commands, or one state object per command -- depending on the needs of the application.

Clients may instantiate or extend this class.

Since:
3.2

Constructor Summary
State()
           
 
Method Summary
 void addListener(IStateListener listener)
          Adds a listener to changes for this state.
 void dispose()
          Disposes of this state.
protected  void fireStateChanged(Object oldValue)
          Notifies listeners to this state that it has changed in some way.
 String getId()
          Returns the identifier for this state.
 Object getValue()
          The current value associated with this state.
 void removeListener(IStateListener listener)
          Removes a listener to changes from this state.
 void setId(String id)
          Sets the identifier for this object.
 void setValue(Object value)
          Sets the value for this state object.
 
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

State

public State()
Method Detail

addListener

public void addListener(IStateListener listener)
Adds a listener to changes for this state.

Parameters:
listener - The listener to add; must not be null.

dispose

public void dispose()
Disposes of this state. This allows the state to unregister itself with any managers or as a listener.


fireStateChanged

protected final void fireStateChanged(Object oldValue)
Notifies listeners to this state that it has changed in some way.

Parameters:
oldValue - The old value; may be anything.

getId

public final String getId()
Returns the identifier for this state.

Returns:
The id; may be null.

getValue

public Object getValue()
The current value associated with this state. This can be any type of object, but implementations will usually restrict this value to a particular type.

Returns:
The current value; may be anything.

removeListener

public void removeListener(IStateListener listener)
Removes a listener to changes from this state.

Parameters:
listener - The listener to remove; must not be null.

setId

public void setId(String id)
Sets the identifier for this object. This method should only be called by the command framework. Clients should not call this method.

Parameters:
id - The id; must not be null.

setValue

public void setValue(Object value)
Sets the value for this state object.

Parameters:
value - The value to set; may be anything.

Eclipse Platform
Release 3.2

Guidelines for using Eclipse APIs.

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