|
|||||||||
| Home >> All >> com >> [ jabberwookie overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.jabberwookie
Class Stream

java.lang.Objectcom.jabberwookie.Stream
- All Implemented Interfaces:
- com.ssttr.xml.SAXInterface
- Direct Known Subclasses:
- Client2Server, Component2Server
- public abstract class Stream
- extends java.lang.Object
- implements com.ssttr.xml.SAXInterface
- extends java.lang.Object
This implements the most basic functions required to establish and maintain a Jabber stream. It must be extended to be truely useful. Currently this is done by the Client2Server and Component2Server classes.
| Nested Class Summary | |
private class |
Stream.ChunkProcessor
|
private class |
Stream.ParserThread
Receives data from the XML parser and maps it to the appropriate namespace when possible. |
| Field Summary | |
private com.jabberwookie.ns.jabber.Chunk |
chunk
|
protected Stream.ChunkProcessor |
chunkProcessor
|
protected java.util.Vector |
chunkQueue
|
protected boolean |
connected
|
protected java.lang.String |
connectionId
|
protected static boolean |
DEBUG
|
private com.ssttr.xml.XMLElement |
el
|
private java.util.Stack |
elStack
|
protected java.io.DataInputStream |
in
|
protected IQListener |
iqListener
|
protected MessageListener |
mListener
|
protected Namespaces |
ns
|
protected java.io.OutputStream |
out
|
protected java.io.Writer |
outWriter
|
protected Stream.ParserThread |
parserT
|
protected PresenceListener |
pListener
|
protected com.ssttr.util.processor.Processor |
processor
|
protected static int |
PROCESSOR_WAIT_TIME
How long to wait before giving up on trying to process a chunk. |
protected UnrecognizedChunkListener |
unListener
|
protected java.util.Hashtable |
waitingIds
|
| Constructor Summary | |
Stream(java.io.InputStream in,
java.io.OutputStream out)
Creates a new instance of Stream. |
|
Stream(java.io.InputStream in,
java.io.OutputStream out,
com.ssttr.util.processor.Processor processor)
Creates a new instance of Stream. |
|
| Method Summary | |
void |
cData(java.lang.String data)
|
void |
chunkStart(java.lang.String tag,
java.util.Hashtable attrs)
|
void |
chunkStop(java.lang.String tag)
|
abstract void |
close()
Closes the stream, needs to be impelmented by the subclass. |
void |
docStart(java.lang.String tag,
java.util.Hashtable attrs)
|
void |
docStop(java.lang.String tag)
|
void |
dtdData(java.lang.String dtd)
|
void |
elementStart(java.lang.String tag,
java.util.Hashtable attrs)
|
void |
elementStop(java.lang.String tag)
|
java.lang.String |
getConnectionId()
|
private void |
gotId(java.lang.String id,
com.jabberwookie.ns.jabber.Chunk chunk)
Signals waitForID that a new message came in and it should check it. |
boolean |
isConnected()
|
abstract boolean |
open(java.lang.String serverName,
int timeoutSecs)
Opens the stream, needs to be impelmented by the subclass. |
void |
processChunk(com.jabberwookie.ns.jabber.Chunk chunk)
|
void |
processingInstruction(java.lang.String element)
|
void |
send(com.jabberwookie.ns.jabber.Chunk chunk)
Sends the chunk to the other end and returns immediatly. |
com.jabberwookie.ns.jabber.Chunk |
send(com.jabberwookie.ns.jabber.Chunk chunk,
int timeoutMillis)
Sends the chunk to the other end and waits for a reply. |
void |
setAllListeners(java.lang.Object listener)
Does NOT set the UnrecogizedChunkListener. |
void |
setIQListener(IQListener listener)
|
void |
setMessageListener(MessageListener listener)
|
void |
setNamespaces(Namespaces namespaces)
Sets the namespaces used when interpreting incoming data. |
void |
setPresenceListener(PresenceListener listener)
|
void |
setProcessor(com.ssttr.util.processor.Processor processor)
Sets the internal Processor used when calling your *Listeners. |
void |
setUnrecogizedChunkListener(UnrecognizedChunkListener listener)
|
private com.jabberwookie.ns.jabber.Chunk |
waitForId(java.lang.String id,
int timeoutMillis)
Blocks until the given message id is received. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
DEBUG
protected static final boolean DEBUG
- See Also:
- Constant Field Values
PROCESSOR_WAIT_TIME
protected static final int PROCESSOR_WAIT_TIME
- How long to wait before giving up on trying to process
a chunk. (but only if you're using a Processor)
- See Also:
- Constant Field Values
in
protected java.io.DataInputStream in
out
protected java.io.OutputStream out
outWriter
protected java.io.Writer outWriter
parserT
protected Stream.ParserThread parserT
processor
protected com.ssttr.util.processor.Processor processor
chunkQueue
protected java.util.Vector chunkQueue
chunkProcessor
protected Stream.ChunkProcessor chunkProcessor
mListener
protected MessageListener mListener
pListener
protected PresenceListener pListener
iqListener
protected IQListener iqListener
unListener
protected UnrecognizedChunkListener unListener
connected
protected boolean connected
connectionId
protected java.lang.String connectionId
ns
protected Namespaces ns
waitingIds
protected java.util.Hashtable waitingIds
el
private com.ssttr.xml.XMLElement el
chunk
private com.jabberwookie.ns.jabber.Chunk chunk
elStack
private java.util.Stack elStack
| Constructor Detail |
Stream
public Stream(java.io.InputStream in, java.io.OutputStream out)
- Creates a new instance of Stream. If you use this constuctor
it will block on any calls to your *Listeners.
Stream
public Stream(java.io.InputStream in, java.io.OutputStream out, com.ssttr.util.processor.Processor processor)
- Creates a new instance of Stream. If you use this constructor
and pass in a valid Processor it will call your *Listeners as
fast as the Processor allows (when there is data available, of
course).
| Method Detail |
setProcessor
public void setProcessor(com.ssttr.util.processor.Processor processor)
- Sets the internal Processor used when calling your *Listeners.
If you're going to take a while to process chunks it's highly
recomended that you not only use a Processor, but that you
use one with either a large queue, a lot of threads, or both.
This is because if your processor refuses to accept a chunk
for more than 10 seconds it will give up and drop it on the
floor. No, this isn't the best behavior, but it is easily
avoidable, just be careful.
setNamespaces
public void setNamespaces(Namespaces namespaces)
- Sets the namespaces used when interpreting incoming data.
If you don't know what the namespaces are I would suggest
reading some of the Jabber protocol documentation.
open
public abstract boolean open(java.lang.String serverName, int timeoutSecs) throws java.io.IOException
- Opens the stream, needs to be impelmented by the subclass.
close
public abstract void close()
- Closes the stream, needs to be impelmented by the subclass.
send
public void send(com.jabberwookie.ns.jabber.Chunk chunk) throws java.io.IOException
- Sends the chunk to the other end and returns immediatly.
send
public com.jabberwookie.ns.jabber.Chunk send(com.jabberwookie.ns.jabber.Chunk chunk, int timeoutMillis) throws java.io.IOException
- Sends the chunk to the other end and waits for a reply.
waitForId
private com.jabberwookie.ns.jabber.Chunk waitForId(java.lang.String id, int timeoutMillis)
- Blocks until the given message id is received.
isConnected
public boolean isConnected()
getConnectionId
public java.lang.String getConnectionId()
setMessageListener
public void setMessageListener(MessageListener listener)
setPresenceListener
public void setPresenceListener(PresenceListener listener)
setIQListener
public void setIQListener(IQListener listener)
setUnrecogizedChunkListener
public void setUnrecogizedChunkListener(UnrecognizedChunkListener listener)
setAllListeners
public void setAllListeners(java.lang.Object listener)
- Does NOT set the UnrecogizedChunkListener.
This will only work it the passed listener implements
MessageListener, PresenceListener, and IQListener. If not
it will throw a ClassCastException.
gotId
private void gotId(java.lang.String id, com.jabberwookie.ns.jabber.Chunk chunk)
- Signals waitForID that a new message came in and it should
check it.
cData
public void cData(java.lang.String data)
- Specified by:
cDatain interfacecom.ssttr.xml.SAXInterface
chunkStart
public void chunkStart(java.lang.String tag, java.util.Hashtable attrs)
- Specified by:
chunkStartin interfacecom.ssttr.xml.SAXInterface
docStart
public void docStart(java.lang.String tag, java.util.Hashtable attrs)
- Specified by:
docStartin interfacecom.ssttr.xml.SAXInterface
elementStart
public void elementStart(java.lang.String tag, java.util.Hashtable attrs)
- Specified by:
elementStartin interfacecom.ssttr.xml.SAXInterface
elementStop
public void elementStop(java.lang.String tag)
- Specified by:
elementStopin interfacecom.ssttr.xml.SAXInterface
chunkStop
public void chunkStop(java.lang.String tag)
- Specified by:
chunkStopin interfacecom.ssttr.xml.SAXInterface
processChunk
public void processChunk(com.jabberwookie.ns.jabber.Chunk chunk)
docStop
public void docStop(java.lang.String tag)
- Specified by:
docStopin interfacecom.ssttr.xml.SAXInterface
processingInstruction
public void processingInstruction(java.lang.String element)
- Specified by:
processingInstructionin interfacecom.ssttr.xml.SAXInterface
dtdData
public void dtdData(java.lang.String dtd)
- Specified by:
dtdDatain interfacecom.ssttr.xml.SAXInterface
|
|||||||||
| Home >> All >> com >> [ jabberwookie overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.jabberwookie.Stream