Sunday, April 22, 2007

JAVA 認證心得 -- SCMAD (4)


  • Examples of valid URLs
  • ConnectionNotFoundException would be thrown only when the device does not provide implementation for the attempted connection type.
  • Class Connector

    public static Connection open(String url, {int mode}, {int timeout})

    - IllegalArgumentException - If a parameter is invalid.

    - ConnectionNotFoundException - If the requested connection cannot be make, or the protocol type does not exist.

    - IOException - If some other kind of I/O error occurs.

    - SecurityException – If the application does not have sufficient permissions.

    - InterruptedIOException – If the timeout parameter is true and a connection times out.

  • GCF provided by CLDC 1.1 at implement level, a minimum of one class is needed for implementing each supported protocol.
  • GCF API is a functional subset of the package.
  • The GCF defined by the CLDC Specification does not specify the actual supported network protocols or mandate implementations of any specific networking protocols.
  • If the associated streams are open, then Connection.close() will wait till they are closed. In this case, the Stream objects can be accessed, but accessing a method of the Connection interface (or its sub-interface) will throw IOException.
  • Closing an already closed connection has no effect. If newMessage() is called on a closed connection, this method always returns a Message instance irrespective of the type theat was passed in.
  • The SecurityInfo interface defines methods to access information about a secure network connection. Protocols that implement secure connections may use this interface to report the security parameters of the connection, such as protocol name, Server certificate, and Cipher suite name.
  • Interface ServerSocketConnection

    String getLocalAddress()

    Int getLocalPort()

  • Interface HttpConnection.

    Int getResponseCode()

  • The valid constants for opening a connection are

    Ø Connector.READ

    Ø Connector.WRITE

    Ø Connector.READ_WRITE (default mode)

  • In a CommConnection, if the requested baud rate is not supported on the platform, the system may use an alternate valid setting.
  • A CommConnection can specify the baud rate in two ways

    Ø Via the optional parameter “baudrate” in the connection String

    Ø Using the CommConnection.setBaudRate() method

  • The Datagram.receive() method is a blocking call.
  • HttpsConnection , SecureConnection <-> SecurityInfo getSecurityInfo()

    DatagramConnection <-> int getNominalLength(), int getMaximumLength()

    StreamConnectionNotifier <-> StreamConnection acceptAndOpen()

  • interface

    - getLength()->when sending, “length” is the number of bytes to send. Before receiving, “length” is the maximum number of bytes to receive. After receiving, “length” is the number of bytes that were received.

    Before writing on a datagram, its ”read/write pointer”, “offset”, and “length” has to be set to zero. This has to be done by calling reset() on the Datagram.

  • Datagram interface extends interfaces and Datagrams can be reused. Before reusing a datagram is to set back the “length” to the maximum using setLength as “Length” variable would have changed due to previous operations.
  • Http is a request-response protocol in which the parameters of request must be set before the request is sent.The connection exists in one of the following three states:

    Ø Setup, in which the request parameters can be set

    Ø Connected, in which request parameters have been sent and the response is expected.

    Ø Closed, the final state, in which the HTTP connection has been terminated.

  • There are six basic interface types that are address by the GCF

    Ø A basic serial input connection

    Ø A basic serial output connection

    Ø A datagram oriented connection

    Ø A circuit oriented connection

    Ø A notificaion mechanism to inform a server of client-sercer connections

    Ø A basic Web server connection

  • The CertificateException encapsulates an error that occurred while a Certificate is being used. If multiple errors are found within a Certificate the more significant error should be reported in the exception.
  • javax.microedition.pki.CertificateException
  • Class CertificateException

    - Certificate getCertificate()-> Get the Certificate that caused the exception

    - bye getReason() -> Get the reason code.

  • The valid identifiers for a particular device and OS can be queried through the method System.getProperty() using the key "microedition.commports". A comma separated list of ports is returned which can be combined with a comm: prefix as the URL string to be used to open a serial port connection. -> "comm:"[] ;

Read more!

No comments: