net.jetrix.protocols
Class AbstractProtocol

java.lang.Object
  extended by net.jetrix.protocols.AbstractProtocol
All Implemented Interfaces:
Protocol
Direct Known Subclasses:
ConsoleProtocol, IRCProtocol, QueryProtocol, TetrinetProtocol

public abstract class AbstractProtocol
extends Object
implements Protocol

Abstract protocol implementing the readLine(Reader) method.

Since:
0.3
Version:
$Revision: 848 $, $Date: 2010-05-03 22:51:32 +0200 (lun., 03 mai 2010) $
Author:
Emmanuel Bourg

Constructor Summary
AbstractProtocol()
           
 
Method Summary
 boolean equals(Object o)
           
 int hashCode()
           
 byte[] readFrame(InputStream in)
          Reads the next message frame from the specified input stream.
 String readLine(InputStream in, String encoding)
          Read a line for this protocol.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.jetrix.Protocol
applyStyle, getEOL, getMessage, getName, translate
 

Constructor Detail

AbstractProtocol

public AbstractProtocol()
Method Detail

readFrame

public byte[] readFrame(InputStream in)
                 throws IOException
Reads the next message frame from the specified input stream. No charset decoding is performed at this stage.

Throws:
IOException

readLine

public String readLine(InputStream in,
                       String encoding)
                throws IOException
Description copied from interface: Protocol
Read a line for this protocol. A line is ended by a \n or \r character, or by a protocol specific end of line as defined by the Protocol.getEOL() method.

Specified by:
readLine in interface Protocol
Parameters:
in - the stream to be read
encoding - the charset encoding used to read the message
Throws:
IOException - thrown if the stream is closed

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2010. All Rights Reserved.