Java Doc for ConnectionBaseAdapter.java in  » 6.0-JDK-Modules » j2me » com » sun » cdc » io » 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 » 6.0 JDK Modules » j2me » com.sun.cdc.io 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.sun.cdc.io.ConnectionBaseAdapter

All known Subclasses:   com.sun.cdc.io.BufferedConnectionAdapter,  com.sun.j2me.io.ConnectionBaseAdapter,
ConnectionBaseAdapter
abstract public class ConnectionBaseAdapter implements ConnectionBaseInterface,StreamConnection(Code)
Protocol classes extend this class to gain some of the common functionality needed to implement a CDC Generic Connection.

The common functionality includes:

  • Supplies the input and output stream classes for a StreamConnection
  • Limits the number of streams opened according to mode, but the limit can be overridden. Read-write allows 1 input and 1 output, write-only allows 1 output, read-only allows 1 input
  • Only "disconnects" when the connection and all streams are closed
  • Throws I/O exceptions when used after being closed
  • Provides a more efficient implementation of InputStream.read(byte[]intint) , which is called by InputStream.read
  • Provides a more efficient implementation of OutputStream.write(byte[]intint) , which is called by OutputStream.write(int)

Class Relationship Diagram


version:
   3.0 9/1/2000


Field Summary
protected  booleanconnectionOpen
     Flag indicating if the connection is open.
protected static  intiStreams
     Number of input streams that were opened.
protected  intmaxIStreams
     Maximum number of open input streams.
protected  intmaxOStreams
     Maximum number of output streams.
protected static  intoStreams
     Number of output streams were opened.


Method Summary
public  intavailable()
     Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
protected  voidcheckForPermission()
     Overridden by Protocols to check for permissions. This implementation always throws a security exception. The subclass is responsible for checking permissions and maintaining the state (in private local fields) as to whether it was granted.
public  voidclose()
     Close the connection.
 voidcloseCommon()
     Disconnect if the connection and all the streams and the closed.
protected  voidcloseInputStream()
     Called once by each child input stream.
protected  voidcloseOutputStream()
     Called once by each child output stream.
abstract protected  voidconnect(String name, int mode, boolean timeouts)
     Connect to a target.
abstract protected  voiddisconnect()
     Free up the connection resources.
protected  voidensureNoStreamsOpen()
     Check if the streams are open.
protected  voidensureOpen()
     Check if the connection is open.
protected  voidflush()
     Forces any buffered output bytes to be written out.
public synchronized  voidmark(int readlimit)
     Marks the current position in input stream for a connection.
public  booleanmarkSupported()
     Tests if input stream for a connection supports the mark and reset methods.
public  DataInputStreamopenDataInputStream()
     Open and return a data input stream for a connection.
public  DataOutputStreamopenDataOutputStream()
     Open and return a data output stream for a connection.
public  InputStreamopenInputStream()
     Returns an input stream.
public  OutputStreamopenOutputStream()
     Returns an output stream.
public  ConnectionopenPrim(String name, int mode, boolean timeouts)
     Check for required permission and open a connection to a target.
public  ConnectionopenPrim(String name)
     Check for required permission and open a connection to a target. This method can be used with permissions greater than the current app.
abstract protected  intreadBytes(byte b, int off, int len)
     Reads up to len bytes of data from the input stream into an array of bytes, blocks until at least one byte is available.
Parameters:
  b - the buffer into which the data is read.
Parameters:
  off - the start offset in array bat which the data is written.
Parameters:
  len - the maximum number of bytes to read.
public synchronized  voidreset()
     Repositions input stream for a connection to the position at the time the mark method was last called on this input stream.
abstract protected  intwriteBytes(byte b, int off, int len)
     Writes len bytes from the specified byte array starting at offset off to this output stream.

Polling the native code is done here to allow for simple asynchronous native code to be written.


Field Detail
connectionOpen
protected boolean connectionOpen(Code)
Flag indicating if the connection is open.



iStreams
protected static int iStreams(Code)
Number of input streams that were opened.



maxIStreams
protected int maxIStreams(Code)
Maximum number of open input streams. Set this to zero to prevent openInputStream from giving out a stream in write-only mode.



maxOStreams
protected int maxOStreams(Code)
Maximum number of output streams. Set this to zero to prevent openOutputStream from giving out a stream in read-only mode.



oStreams
protected static int oStreams(Code)
Number of output streams were opened.





Method Detail
available
public int available() throws IOException(Code)
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or another thread. This classes implementation always returns 0. It is up to subclasses to override this method. the number of bytes that can be read from this input streamwithout blocking.
exception:
  IOException - if an I/O error occurs.



checkForPermission
protected void checkForPermission() throws SecurityException, InterruptedIOException(Code)
Overridden by Protocols to check for permissions. This implementation always throws a security exception. The subclass is responsible for checking permissions and maintaining the state (in private local fields) as to whether it was granted.
Parameters:
  token - security token of the calling class or null
Parameters:
  name - the URL of the connection without the protocol
exception:
  SecurityException - if permissions are not granted
exception:
  InterruptedIOException - if I/O associated with permissions is interrupted



close
public void close() throws IOException(Code)
Close the connection.
exception:
  IOException - if an I/O error occurs when closing theconnection.



closeCommon
void closeCommon() throws IOException(Code)
Disconnect if the connection and all the streams and the closed.
exception:
  IOException - if an I/O error occurs when closing theconnection.



closeInputStream
protected void closeInputStream() throws IOException(Code)
Called once by each child input stream. If the input stream is marked open, it will be marked closed and the if the connection and output stream are closed the disconnect method will be called.
exception:
  IOException - if the subclass throws one



closeOutputStream
protected void closeOutputStream() throws IOException(Code)
Called once by each child output stream. If the output stream is marked open, it will be marked closed and the if the connection and input stream are closed the disconnect method will be called.
exception:
  IOException - if the subclass throws one



connect
abstract protected void connect(String name, int mode, boolean timeouts) throws IOException(Code)
Connect to a target.
Parameters:
  name - URL for the connection, without the protocolpart
Parameters:
  mode - I/O access mode, see Connector
Parameters:
  timeouts - flag to indicate that the called wantstimeout exceptions
exception:
  IllegalArgumentException - If a parameter is invalid.
exception:
  ConnectionNotFoundException - If the connection cannot befound.
exception:
  IOException - If some other kind of I/O error occurs.



disconnect
abstract protected void disconnect() throws IOException(Code)
Free up the connection resources.
exception:
  IOException - if an I/O error occurs.



ensureNoStreamsOpen
protected void ensureNoStreamsOpen() throws IOException(Code)
Check if the streams are open.
exception:
  IOException - is thrown, if the stream is still open.



ensureOpen
protected void ensureOpen() throws IOException(Code)
Check if the connection is open.
exception:
  IOException - is thrown, if the stream is not open.



flush
protected void flush() throws IOException(Code)
Forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written that have been buffered by the connection, should immediately be written to their intended destination.

The flush method of ConnectionBaseAdapter does nothing.
exception:
  IOException - if an I/O error occurs.




mark
public synchronized void mark(int readlimit)(Code)
Marks the current position in input stream for a connection. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

The mark method of ConnectionBaseAdapter does nothing.

Subclasses should override this method if they support own mark/reset functionality.
Parameters:
  readlimit - the maximum limit of bytes that can be read beforethe mark position becomes invalid.
See Also:   java.io.InputStream.reset




markSupported
public boolean markSupported()(Code)
Tests if input stream for a connection supports the mark and reset methods.

The markSupported method of ConnectionBaseAdapter returns false.

Subclasses should override this method if they support own mark/reset functionality. true if input stream for this connection supportsthe mark and reset methods;false otherwise.
See Also:   java.io.InputStream.mark(int)
See Also:   java.io.InputStream.reset




openDataInputStream
public DataInputStream openDataInputStream() throws IOException(Code)
Open and return a data input stream for a connection. An input stream
exception:
  IOException - If an I/O error occurs



openDataOutputStream
public DataOutputStream openDataOutputStream() throws IOException(Code)
Open and return a data output stream for a connection. An input stream
exception:
  IOException - If an I/O error occurs



openInputStream
public InputStream openInputStream() throws IOException(Code)
Returns an input stream. an input stream for writing bytes to this port.
exception:
  IOException - if an I/O error occurs when creating theoutput stream.



openOutputStream
public OutputStream openOutputStream() throws IOException(Code)
Returns an output stream. an output stream for writing bytes to this port.
exception:
  IOException - if an I/O error occurs when creating theoutput stream.



openPrim
public Connection openPrim(String name, int mode, boolean timeouts) throws IOException(Code)
Check for required permission and open a connection to a target.
Parameters:
  name - URL for the connection, without thewithout the protocol part
Parameters:
  mode - I/O access mode, see Connector
Parameters:
  timeouts - flag to indicate that the callerwants timeout exceptions this Connection object
exception:
  IllegalArgumentException - If a parameter is invalid.
exception:
  ConnectionNotFoundException - If the connection cannotbe found.
exception:
  IOException - If some other kind of I/O error occurs.



openPrim
public Connection openPrim(String name) throws IOException(Code)
Check for required permission and open a connection to a target. This method can be used with permissions greater than the current app. Assume read/write and no timeouts.
Parameters:
  token - security token of the calling class
Parameters:
  name - URL for the connection, without thewithout the protocol part this Connection object
exception:
  IllegalArgumentException - If a parameter is invalid.
exception:
  ConnectionNotFoundException - If the connection cannotbe found.
exception:
  IOException - If some other kind of I/O error occurs.



readBytes
abstract protected int readBytes(byte b, int off, int len) throws IOException(Code)
Reads up to len bytes of data from the input stream into an array of bytes, blocks until at least one byte is available.
Parameters:
  b - the buffer into which the data is read.
Parameters:
  off - the start offset in array bat which the data is written.
Parameters:
  len - the maximum number of bytes to read. the total number of bytes read into the buffer, or-1 if there is no more data because the end ofthe stream has been reached.
exception:
  IOException - if an I/O error occurs.



reset
public synchronized void reset() throws IOException(Code)
Repositions input stream for a connection to the position at the time the mark method was last called on this input stream.

The method reset for ConnectionBaseAdapter class does nothing and always throws an IOException.

Subclasses should override this method if they support own mark/reset functionality.
exception:
  IOException - if this stream has not been marked or if themark has been invalidated.
See Also:   java.io.InputStream.reset
See Also:   java.io.InputStream.mark(int)
See Also:   java.io.IOException




writeBytes
abstract protected int writeBytes(byte b, int off, int len) throws IOException(Code)
Writes len bytes from the specified byte array starting at offset off to this output stream.

Polling the native code is done here to allow for simple asynchronous native code to be written. Not all implementations work this way (they block in the native code) but the same Java code works for both.
Parameters:
  b - the data.
Parameters:
  off - the start offset in the data.
Parameters:
  len - the number of bytes to write. number of bytes written
exception:
  IOException - if an I/O error occurs. In particular,an IOException is thrown if the outputstream is closed.




Methods inherited from java.lang.Object
public boolean equals(Object obj)(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

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