?? datagram.html
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Wed Sep 24 14:57:48 PDT 2003 -->
<TITLE>
MID Profile: Interface Datagram
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Datagram.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<strong>MID Profile</strong></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../javax/microedition/io/ContentConnection.html"><B>PREV CLASS</B></A>
<A HREF="../../../javax/microedition/io/DatagramConnection.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="Datagram.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.microedition.io</FONT>
<BR>
Interface Datagram</H2>
<DL>
<DT><B>All Superinterfaces:</B> <DD><A HREF="../../../java/io/DataInput.html">DataInput</A>, <A HREF="../../../java/io/DataOutput.html">DataOutput</A></DD>
</DL>
<HR>
<DL>
<DT>public interface <B>Datagram</B><DT>extends <A HREF="../../../java/io/DataInput.html">DataInput</A>, <A HREF="../../../java/io/DataOutput.html">DataOutput</A></DL>
<P>
This is the generic datagram interface. It represents an object that will act as the holder of data to be sent or received from a datagram connection. <p> The DataInput and DataOutput interfaces are extended by this interface to provide a simple way to read and write binary data in and out of the datagram buffer. An additional function reset() may be called to reset the read/write point to the beginning of the buffer. <p> It should be noted that in the interests of reducing space and speed concerns, these mechanisms are very simple. In order to use them correctly the following restrictions should be observed: <p> 1) The use of the standard DataInput and DataOutput interfaces is done in order to provide a familiar API for reading and writing data into and out of a Datagram buffer. It should be understood however that this is not an API to a Java stream and does not exhibit all of the features normally associated with one. The most important difference here is that a Java stream is either an InputStream or an OutputStream. The interface presented here is, essentially, both at the same time. As the datagram object does not have a mode for reading and writing, it is necessary for the application programmer to realize that no automatic detection of the wrong mode usage can be done. <p> 2) The DataInput and DataOutput interfaces will not work with any arbitrary settings of the Datagram state variables. The main restriction here is that the <I>offset</I> state variable must at all times be zero. Datagrams may be used in the normal way where the offset is non-zero but when this is done the DataInput and DataOutput interfaces cannot be used. <p> 3) The DataInput and DataOutput read() and write() functions work by using an invisible state variable of the Datagram object. Before any data is read from or written to the datagram buffer, this state variable must be zeroed using the reset() function. This variable is not the <I>offset</I> state variable but an additional state variable used only for the read() and write() functions. <p> 4) Before data is to be received into the datagram's buffer, the <I>offset</I> state variable and the <I>length</I> state variable must first be set up to the part of the buffer the data should be written to. If the intention is to use the read() functions, the offset must be zero. After receive() is called, the data can be read from the buffer using the read() functions until an EOF condition is found. This will occur when the number of characters represented by the length parameter have been read. <p> 5) To write data into the buffer prior to a send() operation, the reset() function should first be called. This will zero the read/write pointer along with the offset and length parameters of the Datagram object. Then the data can be written using the write() functions. When this process is complete, the <I>length</I> state variable will be set to the correct value for the send() function of the datagram's connection, and so the send operation can take place. An IndexOutOfBoundsException will be thrown if the number of characters written exceeds the size of the buffer.
<P>
<DL>
<DT><B>Since: </B><DD>CLDC 1.0</DD>
</DL>
<HR>
<P>
<!-- ======== INNER CLASS SUMMARY ======== -->
<!-- =========== FIELD SUMMARY =========== -->
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../java/lang/String.html">String</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/io/Datagram.html#getAddress()">getAddress</A></B>()</CODE>
<BR>
Get the address in the datagram.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> byte[]</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/io/Datagram.html#getData()">getData</A></B>()</CODE>
<BR>
Get the buffer.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/io/Datagram.html#getLength()">getLength</A></B>()</CODE>
<BR>
Get the length.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/io/Datagram.html#getOffset()">getOffset</A></B>()</CODE>
<BR>
Get the offset.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/io/Datagram.html#reset()">reset</A></B>()</CODE>
<BR>
Zero the read/write pointer as well as the offset and length parameters.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/io/Datagram.html#setAddress(javax.microedition.io.Datagram)">setAddress</A></B>(<A HREF="../../../javax/microedition/io/Datagram.html">Datagram</A> reference)</CODE>
<BR>
Set datagram address, copying the address from another datagram.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/io/Datagram.html#setAddress(java.lang.String)">setAddress</A></B>(<A HREF="../../../java/lang/String.html">String</A> addr)</CODE>
<BR>
Set datagram address.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/io/Datagram.html#setData(byte[], int, int)">setData</A></B>(byte[] buffer, int offset, int len)</CODE>
<BR>
Set the buffer, offset and length.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/io/Datagram.html#setLength(int)">setLength</A></B>(int len)</CODE>
<BR>
Set the length.</TD>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -