Name

ContentConnection

Synopsis

ContentConnection is a StreamConnection whose data is some kind of identifiable object. The type of object depends on the communicating entities and must either be known in advance or be identifiable from the value returned by the getType() method. A ContentConnection may convey one object, or a sequence of objects.

The getType() method returns a String that identifies the type of the data in the input stream. In most cases, the object type will be identified by its MIME type, but any arbitrary string that has meaning to both the sender and the receiver can be used. When the connection between sender and receiver is implemented using HTTP, the type is conveyed in the HTTP Content-Type header field.

The getLength() method returns the number of bytes that make up the object’s representation in the data stream. This method may return -1 if the protocol used to carry the data does not include a mechanism for conveying the length of the object. In this case, the receiver should continue to read data until an end-of-file indication is received or some characteristic of the data indicates that a complete object has been read. Where a stream may carry several objects in succession, the value returned by this method may be used to mark the boundary between them. When the connection between sender and receiver is implemented using HTTP, the length is conveyed in the HTTP Content-Length header field.

The getEncoding() method returns a String that indicates ...

Get J2ME in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.