Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core
In directory usw-pr-cvs1:/tmp/cvs-serv17443/src/org/beepcore/beep/core
Modified Files:
Frame.java
Log Message:
changed to make a single call to write
Index: Frame.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/Frame.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** Frame.java 2001/11/08 05:51:34 1.11
--- Frame.java 2001/11/27 02:39:03 1.12
***************
*** 67,70 ****
--- 67,72 ----
private static final String CRLF = "\r\n";
+ private static final BufferSegment trailerBufferSegment =
+ new BufferSegment(TRAILER.getBytes());
/** BEEP message type of <code>Frame</code>. */
***************
*** 103,135 ****
private LinkedList payload = new LinkedList();
- /**
- * Initializes a new <code>Frame</code> representing a BEEP ANS frame.
- *
- * @param messageType indicates whether a <code>Frame</code> is a MSG,
- * RPY, ERR, ANS or NUL.
- * @param channel <code>Channel</code> on which the <code>Frame</code> was
- * sent.
- * @param msgno Message number of the <code>Frame</code>.
- * @param seqno Sequence number of the <code>Frame</code>.
- * @param ansno Answer number of the <code>Frame</code>.
- * @param payload Payload of the <code>Frame</code>.
- * @param last Indicates if this is the last <code>Frame</code> sent in a
- * sequence of frames.
- *
- * @see BufferSegment
- */
- // Frame(int messageType, Channel channel, int msgno, boolean last,
- // long seqno, int ansno, BufferSegment payload)
- // {
- // this.messageType = messageType;
- // this.channel = channel;
- // this.msgno = msgno;
- // this.seqno = seqno;
- // this.ansno = ansno;
- // this.payload.add(payload);
- // this.size = payload.getLength() - payload.getOffset();
- // this.last = last;
- // }
-
Frame(int messageType, Channel channel, int msgno, boolean last,
long seqno, int size, int ansno)
--- 105,108 ----
***************
*** 142,146 ****
this.size = size;
this.ansno = ansno;
- // this.payload = null;
}
--- 115,118 ----
***************
*** 159,174 ****
*
*/
! public Iterator getBytes()
{
this.size = 0;
Iterator i = this.payload.iterator();
while (i.hasNext()) {
! this.size += ((BufferSegment) i.next()).getLength();
}
! this.payload.addFirst(new BufferSegment(buildHeader()));
! this.payload.addLast(new BufferSegment(TRAILER.getBytes()));
! return this.payload.iterator();
}
--- 131,151 ----
*
*/
! public BufferSegment[] getBytes()
{
+ BufferSegment[] b = new BufferSegment[this.payload.size() + 2];
this.size = 0;
+ int j=1;
Iterator i = this.payload.iterator();
while (i.hasNext()) {
! b[j] = (BufferSegment) i.next();
! this.size += b[j].getLength();
! ++j;
}
+
+ b[0] = new BufferSegment(buildHeader());
+ b[b.length-1] = trailerBufferSegment;
! return b;
}
|