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


java.lang.Object
   com.sun.midp.io.j2me.ProtocolBase

All known Subclasses:   com.sun.midp.io.j2me.sms.Protocol,  com.sun.midp.io.j2me.mms.Protocol,  com.sun.midp.io.j2me.cbs.Protocol,
ProtocolBase
abstract public class ProtocolBase implements MessageConnection,ConnectionBaseInterface,StreamConnection(Code)
Base class for SMS/CBS/MMS message connection implementation. Protocol itself is not instantiated. Instead, the application calls Connector.open with an URL string and obtains a javax.wireless.messaging.MessageConnection MessageConnection object. It is an instance of MessageConnection that is instantiated. The Generic Connection Framework mechanism in CLDC will return a Protocol object, which is the implementation of MessageConnection. The Protocol object represents a connection to a low-level transport mechanism.

Optional packages, such as Protocol, cannot reside in small devices. The Generic Connection Framework allows an application to reach the optional packages and classes indirectly. For example, an application can be written with a string that is used to open a connection. Inside the implementation of Connector, the string is mapped to a particular implementation: Protocol, in this case. This allows the implementation to be optional even though the interface, MessageConnection, is required.

Closing the connection frees an instance of MessageConnection.

The Protocol class contains methods to open and close the connection to the low-level transport mechanism. The messages passed on the transport mechanism are defined by the MessageObject MessageObject class. Connections can be made in either client mode or server mode.

  • Client mode connections are for sending messages only. They are created by passing a string identifying a destination address to the Connector.open() method.
  • Server mode connections are for receiving and sending messages. They are created by passing a string that identifies a port, or equivalent, on the local host to the Connector.open() method.
The class also contains methods to send, receive, and construct Message objects.

This class declares that it implements StreamConnection so it can intercept calls to Connector.open*Stream() to throw an IllegalArgumentException.



Field Summary
protected  StringADDRESS_PREFIX
     Prefic for addressed message connections.
protected  StringappID
     Connection parameter from the URL.
protected  ObjectcloseLock
    
protected  intconnHandle
    
protected  Stringhost
     Machine name - the parsed target address from the URL.
volatile  MessageListenerm_listener
     Message listener for async notifications.
 Threadm_listenerThread
     Listener thread.
protected  intm_mode
     Connector mode.
protected  MIDletSuitemidletSuite
     Handle to the MIDlet suite containing this MIDlet.
protected  booleanopen
     Indicates whether the connection is open or closed.
protected  booleanopenPermission
     Indicates whether a trusted application is allowed to open the message connection.
protected  booleanreadPermission
     Indicates whether a trusted application is allowed to read from the message connection.
protected  booleanwritePermission
     Indicates whether a trusted application is allowed to write to the message connection.

Constructor Summary
public  ProtocolBase()
     Creates a message connection protocol handler.

Method Summary
abstract protected  voidcheckReceivePermission()
     Checks internal setting of receive permission.
abstract protected  intclose00(int connHandle, int deRegister)
     Close connection.
Parameters:
  connHandle - handle returned by open0
Parameters:
  deRegister - Deregistration appID when parameter is 1.
public  voidensureOpen()
     Ensures that the connection is open.
abstract protected  StringgetAppID()
     Gets the connection parameter in string mode.
protected  voidio2InterruptedIOExc(IOException ex, String name)
     Generates InterruptedIOException when connection is closed.
abstract public  MessagenewMessage(String type)
     Construct a new message object from the given type.
Parameters:
  type - MULTIPART_MESSAGE is the only type permitted.
abstract public  MessagenewMessage(String type, String addr)
     Constructs a new message object from the given type and address.
Parameters:
  type - TEXT_MESSAGE orBINARY_MESSAGE.
Parameters:
  addr - the destination address of the message.
abstract public  Messagereceive()
     Receives the bytes that have been sent over the connection, constructs a Message object, and returns it.
abstract public  voidsend(Message dmsg)
     Sends a message over the connection.
abstract protected  voidsetAppID(String newValue)
     Sets the connection parameter in string mode.
public  voidsetMessageListener(MessageListener listener)
     Registers a MessageListener object.
abstract protected  intunblock00(int msid)
     Unblock the receive thread.
Parameters:
  msid - The MIDlet suite ID.
abstract protected  intwaitUntilMessageAvailable00(int handle)
    

Field Detail
ADDRESS_PREFIX
protected String ADDRESS_PREFIX(Code)
Prefic for addressed message connections.



appID
protected String appID(Code)
Connection parameter from the URL.



closeLock
protected Object closeLock(Code)
Used to protect read-modify operation on open field during close()



connHandle
protected int connHandle(Code)
Local handle to connection



host
protected String host(Code)
Machine name - the parsed target address from the URL.



m_listener
volatile MessageListener m_listener(Code)
Message listener for async notifications.



m_listenerThread
Thread m_listenerThread(Code)
Listener thread.



m_mode
protected int m_mode(Code)
Connector mode.



midletSuite
protected MIDletSuite midletSuite(Code)
Handle to the MIDlet suite containing this MIDlet.



open
protected boolean open(Code)
Indicates whether the connection is open or closed. If it is closed, subsequent operations should throw an exception.



openPermission
protected boolean openPermission(Code)
Indicates whether a trusted application is allowed to open the message connection. Set to true if the permission check passes. Note: return true to override Security Permissions



readPermission
protected boolean readPermission(Code)
Indicates whether a trusted application is allowed to read from the message connection. Set to true if the permission check passes. Note: return true to override Security Permissions



writePermission
protected boolean writePermission(Code)
Indicates whether a trusted application is allowed to write to the message connection. Set to true if the permission check passes. Note: return true to override Security Permissions




Constructor Detail
ProtocolBase
public ProtocolBase()(Code)
Creates a message connection protocol handler.




Method Detail
checkReceivePermission
abstract protected void checkReceivePermission() throws InterruptedIOException(Code)
Checks internal setting of receive permission. Called from receive and setMessageListener methods.
exception:
  InterruptedIOException - if permission dialogwas preempted



close00
abstract protected int close00(int connHandle, int deRegister)(Code)
Close connection.
Parameters:
  connHandle - handle returned by open0
Parameters:
  deRegister - Deregistration appID when parameter is 1. 0 on success, -1 on failure



ensureOpen
public void ensureOpen() throws IOException(Code)
Ensures that the connection is open.
exception:
  IOException - if the connection is closed



getAppID
abstract protected String getAppID()(Code)
Gets the connection parameter in string mode. string that contains a parameter



io2InterruptedIOExc
protected void io2InterruptedIOExc(IOException ex, String name) throws IOException, InterruptedIOException(Code)
Generates InterruptedIOException when connection is closed.
Parameters:
  ex - input IOException
Parameters:
  name - name of operation: sending or receiving
exception:
  IOException - if the connection is not closed



newMessage
abstract public Message newMessage(String type)(Code)
Construct a new message object from the given type.
Parameters:
  type - MULTIPART_MESSAGE is the only type permitted. A new MMS Message object.



newMessage
abstract public Message newMessage(String type, String addr)(Code)
Constructs a new message object from the given type and address.
Parameters:
  type - TEXT_MESSAGE orBINARY_MESSAGE.
Parameters:
  addr - the destination address of the message. a new Message object.



receive
abstract public Message receive() throws IOException(Code)
Receives the bytes that have been sent over the connection, constructs a Message object, and returns it.

If there are no Messages waiting on the connection, this method will block until a message is received, or the MessageConnection is closed. a Message object.
exception:
  java.io.IOException - if an error occurs while receiving amessage.
exception:
  java.io.InterruptedIOException - if during this method call thisMessageConnection object is closed.
exception:
  java.lang.SecurityException - if the application doesn't havepermission to receive messages on the given port.




send
abstract public void send(Message dmsg) throws IOException(Code)
Sends a message over the connection. This method extracts the data payload from the Message object so that it can be sent as a datagram.
Parameters:
  dmsg - a Message object
exception:
  java.io.IOException - if the message could not be sent orbecause of network failure
exception:
  java.lang.IllegalArgumentException - if the message containsinvalid information or is incomplete, or the message's payloadexceeds the maximal length for the given protocol.
exception:
  java.io.InterruptedIOException - either if thisConnection object is closed during the execution of thissend method or if a timeout occurs while trying to sendthe message.
exception:
  java.lang.NullPointerException - if the parameter isnull.
exception:
  java.lang.SecurityException - if the application doesn't havepermission for sending the message.



setAppID
abstract protected void setAppID(String newValue)(Code)
Sets the connection parameter in string mode.
Parameters:
  newValue - new value of connection parameter



setMessageListener
public void setMessageListener(MessageListener listener) throws IOException(Code)
Registers a MessageListener object.

The platform will notify this listener object when a message has been received to this MessageConnection.

If the queue of this MessageConnection contains some incoming messages that the application haven't read before the call of this method, the newly registered listener will be notified immediately exactly once for each such message in the queue.

There can be at most one listener object registered for a MessageConnection object at any given point in time. Setting a new listener will implicitly de-register the possibly previously set listener.

Passing null as the parameter de-registers the currently registered listener, if any.


Parameters:
  listener - MessageListener object to be registered.If null,the possibly currently registered listener will bede-registered and will not receive notifications.
exception:
  java.lang.SecurityException - if the application does nothave a permission to receive messages using the given portnumber
exception:
  java.io.IOException - if it is requested to registera listener on a client connection or if the connectionhas been closed



unblock00
abstract protected int unblock00(int msid) throws IOException(Code)
Unblock the receive thread.
Parameters:
  msid - The MIDlet suite ID. returns handle to the connection.



waitUntilMessageAvailable00
abstract protected int waitUntilMessageAvailable00(int handle) throws IOException(Code)
Waits until message available
Parameters:
  handle - handle to connection 0 on success, -1 on failure
exception:
  IOException - if an I/O error occurs



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.