PeerStateHandler
Keywords: uk.ac.ic.doc.automed.p2p.state.PeerStateHandler class

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

## uk.ac.ic.doc.automed.p2p.state
Class PeerStateHandler

    java.lang.Object
      uk.ac.ic.doc.automed.p2p.state.PeerStateHandler

    public class PeerStateHandler

extends java.lang.Object

Field Summary
`static int` | `STATE_INIT`
`static int` | `STATE_JOINED_GLOBAL`
`static int` | `STATE_JOINED_LOCAL`
`static int` | `STATE_REGISTER_GLOBAL`
`static int` | `STATE_STAND_ALONE`

Constructor Summary
`PeerStateHandler()` Creates a new instance of PeerStateHandler

Method Summary
`void` | `addListener(StateChangedListener listener)` Register an interested listener
`void` | `changePeerState(int newState)` It handle all state transitions in one method, throwing exceptions when conflicts occur .
`int` | `getPeerState()` Return the current peer state

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

Field Detail

### STATE_INIT

    public static final int STATE_INIT

See Also:
  Constant Field Values

### STATE_STAND_ALONE

    public static final int STATE_STAND_ALONE

See Also:
  Constant Field Values

### STATE_JOINED_LOCAL

    public static final int STATE_JOINED_LOCAL

See Also:
  Constant Field Values

### STATE_REGISTER_GLOBAL

    public static final int STATE_REGISTER_GLOBAL

See Also:
  Constant Field Values

### STATE_JOINED_GLOBAL

    public static final int STATE_JOINED_GLOBAL

See Also:
  Constant Field Values

Constructor Detail

### PeerStateHandler

    public PeerStateHandler()

  Creates a new instance of PeerStateHandler

  Parameters:
    `AutoMedPeer` - a reference to the `AutoMedPeer`

Method Detail

### addListener

    public void addListener(StateChangedListener listener)

  Register an interested listener

### changePeerState

    public void changePeerState(int newState)
                         throws StateChangedException

  It handle all state transitions in one method, throwing exceptions when
  conflicts occur
  . This method is synchronized to make sure that peer's states are updated
  in order.

  Throws:
    `StateChangedException`

### getPeerState

    public int getPeerState()

  Return the current peer state

  Returns:
    int the current peer state

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