Class XMLSocket

java.lang.Object
  |
  +--XMLSocket
All Implemented Interfaces:
java.lang.Runnable

public class XMLSocket
extends java.lang.Object
implements java.lang.Runnable

XMLSocket is a socket wrapper which reads the socket to get XML blocks. Messages are split up and sent to the listeners. XMLSocket is used to read and parse XML from a socket.


Constructor Summary
XMLSocket(java.net.Socket client)
          Default constructor
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
          adds a PropertyChangeListener for a message
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener pcl)
          adds a PropertyChangeListener for a message
 void close()
          closes the socket
 XMLString getNextMessage()
          get the next message from the queue
 boolean hasMessage()
          is there a message waiting in the queue
 boolean isDone()
          Is the XMLSocket finished with the socket
 void parseXML(XParser up, java.io.Reader read)
          Parse XML with a parser, results are in the XParser
 void parseXML(XParser up, java.lang.String xml)
          Parse XML with a parser, results are in the XParser
 void run()
          reader thread, fires events
 void sendMessage(java.lang.String message)
          sends an string to the socket (preferrably XML)
 void setThrowEvent(boolean t)
          tell the XMLSocket to fire newMessage events per each successful read or not.
 void startThread()
          Starts the Reader Thread
 void unPopMessage(XMLString xml)
          Put a message at the start of the queue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLSocket

public XMLSocket(java.net.Socket client)
          throws java.io.IOException
Default constructor

Parameters:
client - the ClientHandler
Method Detail

startThread

public void startThread()
Starts the Reader Thread


setThrowEvent

public void setThrowEvent(boolean t)
tell the XMLSocket to fire newMessage events per each successful read or not.

Parameters:
t - "Fire a newMessage event per xml event?"

run

public void run()
reader thread, fires events

Specified by:
run in interface java.lang.Runnable

isDone

public boolean isDone()
Is the XMLSocket finished with the socket

Returns:
boolean true if finished false otherwise

sendMessage

public void sendMessage(java.lang.String message)
sends an string to the socket (preferrably XML)

Parameters:
message - the message to send.

hasMessage

public boolean hasMessage()
is there a message waiting in the queue

Returns:
boolean true if a message is on queue false otherwise

getNextMessage

public XMLString getNextMessage()
get the next message from the queue

Returns:
XMLString the next message on the queue

unPopMessage

public void unPopMessage(XMLString xml)
Put a message at the start of the queue

Parameters:
xml - the XMLString message to put at the start of the queue

parseXML

public void parseXML(XParser up,
                     java.io.Reader read)
              throws org.xml.sax.SAXException,
                     java.io.IOException
Parse XML with a parser, results are in the XParser

Parameters:
up - the XParser to the parse the XML
read - the reader to provide the XML.
Throws:
org.xml.sax.SAXException - if there is an XML parser error
java.io.IOException - if there is an IO parser error

parseXML

public void parseXML(XParser up,
                     java.lang.String xml)
              throws org.xml.sax.SAXException,
                     java.io.IOException
Parse XML with a parser, results are in the XParser

Parameters:
up - the XParser to the parse the XML
xml - the XML to parse.
Throws:
org.xml.sax.SAXException - if there is an XML parser error
java.io.IOException - if there is an IO parser error

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
adds a PropertyChangeListener for a message

Parameters:
pcl - the property change listener to add

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener pcl)
adds a PropertyChangeListener for a message

Parameters:
propertyName - the property to watch for
pcl - the property change listener to add

close

public void close()
           throws java.io.IOException
closes the socket

Throws:
java.io.IOException - in case of IO Error