Java Doc for INonBlockingConnection.java in  » Web-Server » xsocket » org » xsocket » connection » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » xsocket » org.xsocket.connection 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.xsocket.connection.INonBlockingConnection

All known Subclasses:   org.xsocket.connection.NonBlockingConnection,
INonBlockingConnection
public interface INonBlockingConnection extends IConnection,IDataSource,IDataSink,GatheringByteChannel,ReadableByteChannel,WritableByteChannel,Flushable(Code)
A connection which accesses the underlying channel in a non-blocking manner.


author:
   grro@xsocket.org


Field Summary
final public static  intUNLIMITED
    


Method Summary
public  voidactivateSecuredMode()
     ad hoc activation of a secured mode (SSL).
public  intavailable()
    
public  voidflush()
     flush the send buffer.
public  StringgetEncoding()
    
public  FlushModegetFlushmode()
    
public  intgetPendingWriteDataSize()
     returns the size of the data which have already been written, but not yet transferred to the underlying socket.
public  intgetReadBufferVersion()
     get the version of read buffer.
public  ExecutorgetWorkerpool()
    
public  intindexOf(String str)
     Returns the index of the first occurrence of the given string.
public  intindexOf(String str, String encoding)
     Returns the index of the first occurrence of the given string.
public  booleanisAutoflush()
    
public  booleanisOpen()
     return if the data source is open.
public  voidmarkReadPosition()
     Marks the read position in the connection.
public  voidmarkWritePosition()
     Marks the write position in the connection.
public  ByteBuffer[]readByteBufferByDelimiter(String delimiter, String encoding)
     read a ByteBuffer by using a delimiter.
public  ByteBuffer[]readByteBufferByDelimiter(String delimiter, String encoding, int maxLength)
     read a ByteBuffer by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes
Parameters:
  delimiter - the delimiter
Parameters:
  encoding - the encoding of the delimiter
Parameters:
  maxLength - the max length of bytes that should be read.
public  byte[]readBytesByDelimiter(String delimiter, String encoding)
    
public  byte[]readBytesByDelimiter(String delimiter, String encoding, int maxLength)
     read a byte array by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes
Parameters:
  delimiter - the delimiter
Parameters:
  encoding - the encoding to use
Parameters:
  maxLength - the max length of bytes that should be read.
public  StringreadStringByDelimiter(String delimiter, String encoding)
    
public  StringreadStringByDelimiter(String delimiter, String encoding, int maxLength)
     read a string by using a delimiter
Parameters:
  delimiter - the delimiter
Parameters:
  encoding - the encoding to use
Parameters:
  maxLength - the max length of bytes that should be read.
public  StringreadStringByLength(int length, String encoding)
     read a string by using a length definition
Parameters:
  length - the amount of bytes to read.
public  voidremoveReadMark()
    
public  voidremoveWriteMark()
    
public  booleanresetToReadMark()
     Resets to the marked read position.
public  booleanresetToWriteMark()
     Resets to the marked write position.
public  voidresumeRead()
    
public  voidsetAutoflush(boolean autoflush)
     set autoflush.
public  voidsetEncoding(String encoding)
    
public  voidsetFlushmode(FlushMode flushMode)
     set the flush mode

By setting the flush mode with ASYNC (default is SYNC) the data will be transferred to the underlying connection in a asynchronous way. In most cases there are high performance improvements.
public  voidsetHandler(IHandler handler)
    
public  voidsetWriteTransferRate(int bytesPerSecond)
     set the send delay time.
public  voidsuspendRead()
    
public  longtransferFrom(FileChannel source)
    
public  intwrite(String message, String encoding)
     write a message
Parameters:
  message - the message to write
Parameters:
  encoding - the encoding which should be used th encode the chars into byte (e.g.

Field Detail
UNLIMITED
final public static int UNLIMITED(Code)





Method Detail
activateSecuredMode
public void activateSecuredMode() throws IOException(Code)
ad hoc activation of a secured mode (SSL). By performing of this method all remaining data to send will be flushed. After this all data will be sent and received in the secured mode
throws:
  IOException - If some other I/O error occurs



available
public int available() throws IOException(Code)
get the number of available bytes to read the number of available bytes, possibly zero, or -1 if the channel has reached end-of-stream



flush
public void flush() throws ClosedChannelException, IOException, SocketTimeoutException(Code)
flush the send buffer. The method call will block until the outgoing data has been flushed into the underlying os-specific send buffer.
throws:
  IOException - If some other I/O error occurs
throws:
  SocketTimeoutException - If the timeout has been reached
throws:
  ClosedChannelException - if the underlying channel is closed



getEncoding
public String getEncoding()(Code)
gets the encoding (used by string related methods like write(String) ...) the encoding



getFlushmode
public FlushMode getFlushmode()(Code)
return the flush mode the flush mode



getPendingWriteDataSize
public int getPendingWriteDataSize()(Code)
returns the size of the data which have already been written, but not yet transferred to the underlying socket. the size of the pending data to write



getReadBufferVersion
public int getReadBufferVersion() throws IOException(Code)
get the version of read buffer. The version number increases, if the read buffer queue has been modified the version of the read buffer
throws:
  IOException - If some other I/O error occurs



getWorkerpool
public Executor getWorkerpool()(Code)
return the worker pool which is used to process the call back methods the worker pool



indexOf
public int indexOf(String str) throws IOException(Code)
Returns the index of the first occurrence of the given string.
Parameters:
  str - any string if the string argument occurs as a substring within this object, thenthe index of the first character of the first such substring is returned;if it does not occur as a substring, -1 is returned.
throws:
  IOException - If some other I/O error occurs



indexOf
public int indexOf(String str, String encoding) throws IOException(Code)
Returns the index of the first occurrence of the given string.
Parameters:
  str - any string
Parameters:
  encoding - the encoding to use if the string argument occurs as a substring within this object, thenthe index of the first character of the first such substring is returned;if it does not occur as a substring, -1 is returned.
throws:
  IOException - If some other I/O error occurs
throws:
  MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found



isAutoflush
public boolean isAutoflush()(Code)
get autoflush true, if autoflush is activated



isOpen
public boolean isOpen()(Code)
return if the data source is open. Default is true true, if the data source is open



markReadPosition
public void markReadPosition()(Code)
Marks the read position in the connection. Subsequent calls to resetToReadMark() will attempt to reposition the connection to this point.



markWritePosition
public void markWritePosition()(Code)
Marks the write position in the connection.



readByteBufferByDelimiter
public ByteBuffer[] readByteBufferByDelimiter(String delimiter, String encoding) throws IOException, BufferUnderflowException(Code)
read a ByteBuffer by using a delimiter. The default encoding will be used to decode the delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes
Parameters:
  delimiter - the delimiter
Parameters:
  encoding - the encoding to use the ByteBuffer
throws:
  BufferUnderflowException - If not enough data is available
throws:
  IOException - If some other I/O error occurs



readByteBufferByDelimiter
public ByteBuffer[] readByteBufferByDelimiter(String delimiter, String encoding, int maxLength) throws IOException, BufferUnderflowException, MaxReadSizeExceededException(Code)
read a ByteBuffer by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes
Parameters:
  delimiter - the delimiter
Parameters:
  encoding - the encoding of the delimiter
Parameters:
  maxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown the ByteBuffer
throws:
  BufferUnderflowException - If not enough data is available
throws:
  MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
throws:
  IOException - If some other I/O error occurs



readBytesByDelimiter
public byte[] readBytesByDelimiter(String delimiter, String encoding) throws IOException, BufferUnderflowException(Code)
read a byte array by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes
Parameters:
  delimiter - the delimiter
Parameters:
  encoding - the encoding to use the read bytes
throws:
  BufferUnderflowException - If not enough data is available
throws:
  IOException - If some other I/O error occurs



readBytesByDelimiter
public byte[] readBytesByDelimiter(String delimiter, String encoding, int maxLength) throws IOException, BufferUnderflowException, MaxReadSizeExceededException(Code)
read a byte array by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes
Parameters:
  delimiter - the delimiter
Parameters:
  encoding - the encoding to use
Parameters:
  maxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown the read bytes
throws:
  BufferUnderflowException - If not enough data is available
throws:
  MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
throws:
  IOException - If some other I/O error occurs



readStringByDelimiter
public String readStringByDelimiter(String delimiter, String encoding) throws IOException, BufferUnderflowException, UnsupportedEncodingException, MaxReadSizeExceededException(Code)
read a string by using a delimiter
Parameters:
  delimiter - the delimiter
Parameters:
  encoding - the encoding to use the string
throws:
  MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
throws:
  IOException - If some other I/O error occurs
throws:
  BufferUnderflowException - If not enough data is available
throws:
  UnsupportedEncodingException - if the given encoding is not supported



readStringByDelimiter
public String readStringByDelimiter(String delimiter, String encoding, int maxLength) throws IOException, BufferUnderflowException, UnsupportedEncodingException, MaxReadSizeExceededException(Code)
read a string by using a delimiter
Parameters:
  delimiter - the delimiter
Parameters:
  encoding - the encoding to use
Parameters:
  maxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown the string
throws:
  BufferUnderflowException - If not enough data is available
throws:
  MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
throws:
  IOException - If some other I/O error occurs
throws:
  UnsupportedEncodingException - If the given encoding is not supported



readStringByLength
public String readStringByLength(int length, String encoding) throws IOException, BufferUnderflowException, UnsupportedEncodingException(Code)
read a string by using a length definition
Parameters:
  length - the amount of bytes to read.
Parameters:
  encoding - the encoding to use the string
throws:
  IOException - If some other I/O error occurs
throws:
  BufferUnderflowException - If not enough data is available
throws:
  UnsupportedEncodingException - if the given encoding is not supported
throws:
  IllegalArgumentException - , if the length parameter is negative



removeReadMark
public void removeReadMark()(Code)
remove the read mark



removeWriteMark
public void removeWriteMark()(Code)
remove the write mark



resetToReadMark
public boolean resetToReadMark()(Code)
Resets to the marked read position. If the connection has been marked, then attempt to reposition it at the mark. true, if reset was successful



resetToWriteMark
public boolean resetToWriteMark()(Code)
Resets to the marked write position. If the connection has been marked, then attempt to reposition it at the mark. true, if reset was successful



resumeRead
public void resumeRead() throws IOException(Code)
resume reading data from the underlying subsystem
throws:
  IOException - If some other I/O error occurs



setAutoflush
public void setAutoflush(boolean autoflush)(Code)
set autoflush. If autoflush is activated, each write call will cause a flush.

By default the autoflush is deactivated
Parameters:
  autoflush - true if autoflush should be activated



setEncoding
public void setEncoding(String encoding)(Code)
sets the encoding (used by string related methods like write(String) ...)
Parameters:
  encoding - the encoding



setFlushmode
public void setFlushmode(FlushMode flushMode)(Code)
set the flush mode

By setting the flush mode with ASYNC (default is SYNC) the data will be transferred to the underlying connection in a asynchronous way. In most cases there are high performance improvements. If the IReadWriteableConnection.write(ByteBuffer) or IReadWriteableConnection.write(ByteBuffer[]) method will be used, the flush mode FlushMode.ASYNC could have side-effects. Because the buffer will be written asynchronous, it could occur, that the passed-over buffers are not already written by returning from the write call.
Parameters:
  flushMode - FlushMode.ASYNC if flush should be performed asynchronous,FlushMode.SYNC if flush should be perform synchronous



setHandler
public void setHandler(IHandler handler) throws IOException(Code)
set the connection handler
Parameters:
  handler - the handler
throws:
  IOException - If some other I/O error occurs



setWriteTransferRate
public void setWriteTransferRate(int bytesPerSecond) throws ClosedChannelException, IOException(Code)
set the send delay time. WData to write will be buffered internally and be written to the underlying subsystem based on the given write rate. The write methods will not block for this time.
By default the write transfer rate is set with UNLIMITED

Reduced write transfer is only supported for FlushMode.ASYNC. see INonBlockingConnection#setFlushmode(org.xsocket.connection.IConnection.FlushMode))
Parameters:
  bytesPerSecond - the transfer rate of the outgoing data
throws:
  ClosedChannelException - If the underlying socket is already closed
throws:
  IOException - If some other I/O error occurs



suspendRead
public void suspendRead() throws IOException(Code)
suspend reading data from the underlying subsystem
throws:
  IOException - If some other I/O error occurs



transferFrom
public long transferFrom(FileChannel source) throws IOException, BufferOverflowException(Code)
transfer the data of the file channel to this data sink
Parameters:
  source - the source channel the number of transfered bytes
throws:
  BufferOverflowException - If the no enough space is available
throws:
  IOException - If some other I/O error occurs



write
public int write(String message, String encoding) throws IOException, BufferOverflowException(Code)
write a message
Parameters:
  message - the message to write
Parameters:
  encoding - the encoding which should be used th encode the chars into byte (e.g. `US-ASCII` or `UTF-8`) the number of written bytes
throws:
  BufferOverflowException - If the no enough space is available
throws:
  IOException - If some other I/O error occurs



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.