peer2me.domain
Class Node

java.lang.Object
  extended bypeer2me.domain.Node

public class Node
extends java.lang.Object

This class represents a node in the network. It contains information like the name of the node and its network address. A node also owns a nodeConnection object listening for- and processing incoming and outgoing data packages.

Author:
Torbjørn Vatn & Steinar A. Hestnes

Constructor Summary
Node(java.lang.String address, javax.microedition.io.StreamConnection connection)
          Constructor.
Node(java.lang.String nodeName, java.lang.String address)
          Constructor.
Node(java.lang.String nodeName, java.lang.String address, javax.microedition.io.StreamConnection connection)
          Constructor.
 
Method Summary
 java.lang.String getAddress()
          This method returns the node address
 NodeConnection getNodeConnection()
          This method returns the NodeConnection owned by this node
 java.lang.String getNodeName()
          This method returns the name of the node
static Node restoreNode(java.lang.String nodeString)
          This method restores a node with the properties specified in the given input string.
 void setNodeConnection(javax.microedition.io.StreamConnection connection)
          This method sets the connection to this remote node.
 void setNodeName(java.lang.String nodeName)
          This method sets the name of the node
 void startNodeConnection()
          This method creates a nodeConnection running two threads.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Node

public Node(java.lang.String nodeName,
            java.lang.String address)
Constructor. Creates a new Node. This constructor is used when a node is created to represent the LOCAL device. In this case, nodeName and address are known. The constructor is called from FrameworkFrontEnd.initFramework().

Parameters:
nodeName - The name of the node
address - The node network address

Node

public Node(java.lang.String nodeName,
            java.lang.String address,
            javax.microedition.io.StreamConnection connection)
Constructor. Creates a new Node. This constructor is used when a node is created to represent a remote device on the node which INITIATED the search. In this case, name and address is known. In addition, a StreamConnection object containing a connection to this remote device exists. The constructor is called from the nodeFound() method in the Network subclass.

Parameters:
nodeName - The name of the node
address - The node network address
connection - The connection to this remote node

Node

public Node(java.lang.String address,
            javax.microedition.io.StreamConnection connection)
Constructor. Creates a new Node. This constructor is used when a node is created to represent a remote device on the node which was DISCOVERED during a search. In this case, only the address is known. In addition, a StreamConnection object containing a connection to this remote device exists. The constructor is called from the run() method in ConnectionListener.

Parameters:
address - The node network address
connection - The connection to this remote node
Method Detail

startNodeConnection

public void startNodeConnection()
This method creates a nodeConnection running two threads. One of the threads listens for incoming data packages, and the other processes outgoing data packages. It is only used when this node object represents a remote node.


getNodeConnection

public NodeConnection getNodeConnection()
This method returns the NodeConnection owned by this node

Returns:
nodeConnection This nodes NodeConnection

setNodeConnection

public void setNodeConnection(javax.microedition.io.StreamConnection connection)
This method sets the connection to this remote node. It is called from Network.nodeFound().

Parameters:
connection - The connection to this remote node

getNodeName

public java.lang.String getNodeName()
This method returns the name of the node

Returns:
The nodeName

setNodeName

public void setNodeName(java.lang.String nodeName)
This method sets the name of the node

Parameters:
nodeName - The name of the node

getAddress

public java.lang.String getAddress()
This method returns the node address

Returns:
The node network address

restoreNode

public static Node restoreNode(java.lang.String nodeString)
This method restores a node with the properties specified in the given input string.

Parameters:
nodeString - A string containing node properties (name:address)