|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
com.sun.cdc.io.j2me.UniversalOutputStream
com.sun.cdc.io.j2me.datagram.DatagramObject
public class DatagramObject
This class is required because the J2SE Datagram class is final.
| Constructor Summary | |
|---|---|
DatagramObject(DatagramPacket dpkt)
|
|
DatagramObject(int p)
|
|
| Method Summary | |
|---|---|
String |
getAddress()
Get the address of the datagram. |
byte[] |
getData()
Get the contents of the data buffer. |
int |
getLength()
Get the length of the datagram. |
int |
getOffset()
Get the offset. |
int |
read()
|
boolean |
readBoolean()
See the general contract of the readBoolean
method of DataInput. |
byte |
readByte()
See the general contract of the readByte
method of DataInput. |
char |
readChar()
See the general contract of the readChar
method of DataInput. |
double |
readDouble()
Reads eight input bytes and returns a double value. |
float |
readFloat()
Reads four input bytes and returns a float value. |
void |
readFully(byte[] b)
See the general contract of the readFully
method of DataInput. |
void |
readFully(byte[] b,
int off,
int len)
See the general contract of the readFully
method of DataInput. |
int |
readInt()
See the general contract of the readInt
method of DataInput. |
String |
readLine()
See the general contract of the readLine
method of DataInput. |
long |
readLong()
See the general contract of the readLong
method of DataInput. |
short |
readShort()
See the general contract of the readShort
method of DataInput. |
int |
readUnsignedByte()
See the general contract of the readUnsignedByte
method of DataInput. |
int |
readUnsignedShort()
See the general contract of the readUnsignedShort
method of DataInput. |
String |
readUTF()
See the general contract of the readUTF
method of DataInput. |
void |
reset()
Zero the read/write pointer as well as the
offset and length state variables. |
void |
setAddress(Datagram reference)
Set datagram address, copying the address from another datagram. |
void |
setAddress(String addr)
Set datagram address. |
void |
setData(byte[] buffer,
int offset,
int len)
Set the buffer, offset and length
state variables. |
void |
setLength(int len)
Set the length state variable. |
long |
skip(long n)
|
int |
skipBytes(int n)
See the general contract of the skipBytes
method of DataInput. |
void |
write(int ch)
Writes the specified byte to this output stream. |
| Methods inherited from class com.sun.cdc.io.j2me.UniversalOutputStream |
|---|
checkError, close, flush, print, print, print, print, print, print, print, println, println, println, println, println, println, println, println, seek, setEncoding, setTimeout, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF |
| Methods inherited from class java.io.OutputStream |
|---|
write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.io.DataOutput |
|---|
write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF |
| Constructor Detail |
|---|
public DatagramObject(DatagramPacket dpkt)
public DatagramObject(int p)
| Method Detail |
|---|
public String getAddress()
Datagram
getAddress in interface Datagram"datagram://{host}:{port}", or null if no address was set.
Datagram.setAddress(java.lang.String)public byte[] getData()
Datagram
Depending on the implementation, this operation may return
the internal buffer or a copy of it. However, the user
must not assume that the contents of the internal data
buffer can be manipulated by modifying the data returned by
this operation. Rather, the setData operation
should be used for changing the contents of the internal
buffer.
getData in interface DatagramDatagram.setData(byte[], int, int)public int getOffset()
Datagram
getOffset in interface Datagrampublic int getLength()
Datagram
getLength in interface DatagramDatagram.setLength(int)
public void setAddress(String addr)
throws IOException,
IllegalArgumentException
Datagram"datagram://{host}:{port}".
Note that if the address of a datagram is not specified, then it defaults to that of the connection.
setAddress in interface Datagramaddr - the new target address as a URL
IOException - if a some kind of I/O error occurs
IllegalArgumentException - if the address is not validDatagram.getAddress()
public void setAddress(Datagram reference)
throws IllegalArgumentException
Datagram
setAddress in interface Datagramreference - to the datagram whose address will be copied as
the new target address for this datagram.
IllegalArgumentException - if the address is not validDatagram.getAddress()
public void setData(byte[] buffer,
int offset,
int len)
throws IllegalArgumentException
Datagrambuffer, offset and length
state variables. Depending on the implementation, this operation may
copy the buffer or just set the state variable buffer
to the value of the buffer argument. However,
the user must not assume that the contents of the internal data
buffer can be manipulated by modifying the buffer passed on to
this operation.
setData in interface Datagrambuffer - the data bufferoffset - the offset into the data bufferlen - the length of the data in the buffer
IllegalArgumentException - if the length or offset
or offset plus length fall outside the
buffer, or if the buffer parameter is invalidDatagram.getData()public void setLength(int len)
Datagramlength state variable.
setLength in interface Datagramlen - the new length of the datagramDatagram.getLength()public void reset()
Datagramread/write pointer as well as the
offset and length state variables.
reset in interface Datagram
public long skip(long n)
throws EOFException
EOFException
public int read()
throws IOException
IOException
public void write(int ch)
throws IOException
OutputStreamwrite is that one byte is written
to the output stream. The byte to be written is the eight
low-order bits of the argument b. The 24
high-order bits of b are ignored.
Subclasses of OutputStream must provide an
implementation for this method.
write in interface DataOutputwrite in class OutputStreamch - the byte.
IOException - if an I/O error occurs. In particular,
an IOException may be thrown if the
output stream has been closed.
public final void readFully(byte[] b)
throws IOException
readFully
method of DataInput.
Bytes for this operation are read from the contained input stream.
readFully in interface DataInputb - the buffer into which the data is read.
EOFException - if this input stream reaches the end before
reading all the bytes.
IOException - if an I/O error occurs.
public final void readFully(byte[] b,
int off,
int len)
throws IOException
readFully
method of DataInput.
Bytes for this operation are read from the contained input stream.
readFully in interface DataInputb - the buffer into which the data is read.off - the start offset of the data.len - the number of bytes to read.
EOFException - if this input stream reaches the end before
reading all the bytes.
IOException - if an I/O error occurs.
public final int skipBytes(int n)
throws IOException
skipBytes
method of DataInput.
Bytes for this operation are read from the contained input stream.
skipBytes in interface DataInputn - the number of bytes to be skipped.
IOException - if an I/O error occurs.
public final boolean readBoolean()
throws IOException
readBoolean
method of DataInput.
Bytes for this operation are read from the contained input stream.
readBoolean in interface DataInputboolean value read.
EOFException - if this input stream has reached the end.
IOException - if an I/O error occurs.
public final byte readByte()
throws IOException
readByte
method of DataInput.
Bytes for this operation are read from the contained input stream.
readByte in interface DataInputbyte.
EOFException - if this input stream has reached the end.
IOException - if an I/O error occurs.
public final int readUnsignedByte()
throws IOException
readUnsignedByte
method of DataInput.
Bytes for this operation are read from the contained input stream.
readUnsignedByte in interface DataInputEOFException - if this input stream has reached the end.
IOException - if an I/O error occurs.
public final short readShort()
throws IOException
readShort
method of DataInput.
Bytes for this operation are read from the contained input stream.
readShort in interface DataInputEOFException - if this input stream reaches the end before
reading two bytes.
IOException - if an I/O error occurs.
public final int readUnsignedShort()
throws IOException
readUnsignedShort
method of DataInput.
Bytes for this operation are read from the contained input stream.
readUnsignedShort in interface DataInputEOFException - if this input stream reaches the end before
reading two bytes.
IOException - if an I/O error occurs.
public final char readChar()
throws IOException
readChar
method of DataInput.
Bytes for this operation are read from the contained input stream.
readChar in interface DataInputEOFException - if this input stream reaches the end before
reading two bytes.
IOException - if an I/O error occurs.
public final int readInt()
throws IOException
readInt
method of DataInput.
Bytes for this operation are read from the contained input stream.
readInt in interface DataInputint.
EOFException - if this input stream reaches the end before
reading four bytes.
IOException - if an I/O error occurs.
public final float readFloat()
throws IOException
DataInputfloat value. It does this
by first constructing an int
value in exactly the manner
of the readInt
method, then converting this int
value to a float in
exactly the manner of the method Float.intBitsToFloat.
This method is suitable for reading
bytes written by the writeFloat
method of interface DataOutput.
readFloat in interface DataInputfloat value read.
EOFException - if this stream reaches the end before reading
all the bytes.
IOException - if an I/O error occurs.
public final double readDouble()
throws IOException
DataInputdouble value. It does this
by first constructing a long
value in exactly the manner
of the readlong
method, then converting this long
value to a double in exactly
the manner of the method Double.longBitsToDouble.
This method is suitable for reading
bytes written by the writeDouble
method of interface DataOutput.
readDouble in interface DataInputdouble value read.
EOFException - if this stream reaches the end before reading
all the bytes.
IOException - if an I/O error occurs.
public final long readLong()
throws IOException
readLong
method of DataInput.
Bytes for this operation are read from the contained input stream.
readLong in interface DataInputlong.
EOFException - if this input stream reaches the end before
reading eight bytes.
IOException - if an I/O error occurs.
public final String readUTF()
throws IOException
readUTF
method of DataInput.
Bytes for this operation are read from the contained input stream.
readUTF in interface DataInputEOFException - if this input stream reaches the end before
reading all the bytes.
IOException - if an I/O error occurs.DataInputStream.readUTF(java.io.DataInput)
public final String readLine()
throws IOException
readLine
method of DataInput.
Bytes for this operation are read from the contained input stream.
readLine in interface DataInputEOFException - if this input stream reaches the end before
reading all the bytes.
IOException - if an I/O error occurs.DataInputStream.readLine()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||