KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xsocket > datagram > UserDatagram


1 // $Id: UserDatagram.java 1532 2007-07-17 11:04:50Z grro $
2
/*
3  * Copyright (c) xsocket.org, 2006 - 2007. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Please refer to the LGPL license at: http://www.gnu.org/copyleft/lesser.txt
20  * The latest copy of this software may be found on http://www.xsocket.org/
21  */

22 package org.xsocket.datagram;
23
24 import java.io.IOException JavaDoc;
25 import java.io.UnsupportedEncodingException JavaDoc;
26 import java.net.InetAddress JavaDoc;
27 import java.net.InetSocketAddress JavaDoc;
28 import java.net.SocketAddress JavaDoc;
29 import java.nio.BufferOverflowException JavaDoc;
30 import java.nio.BufferUnderflowException JavaDoc;
31 import java.nio.ByteBuffer JavaDoc;
32
33
34 import org.xsocket.DataConverter;
35 import org.xsocket.IDataSink;
36 import org.xsocket.IDataSource;
37 import org.xsocket.MaxReadSizeExceededException;
38
39
40
41
42 /**
43  * a datagram packet
44  *
45  *
46  * @author grro@xsocket.org
47  */

48 public final class UserDatagram implements IDataSource, IDataSink {
49     
50     private SocketAddress JavaDoc remoteSocketAddress = null;
51     private ByteBuffer JavaDoc data = null;
52     private String JavaDoc defaultEncoding = "UTF-8";
53         
54     
55     /**
56      * constructor. creates an empty packet
57      *
58      * @param size the packet size
59      */

60     public UserDatagram(int size) {
61         init(remoteSocketAddress, ByteBuffer.allocate(size), size);
62     }
63     
64     
65     /**
66      * constructor. creates an empty packet by setting the target remote address
67      *
68      * @param remoteHost the destination hostname
69      * @param remotePort the destination port number
70      * @param size the packet size
71      */

72     public UserDatagram(String JavaDoc remoteHost, int remotePort, int size) {
73         init(new InetSocketAddress JavaDoc(remoteHost, remotePort), ByteBuffer.allocate(size), size);
74     }
75     
76     
77     /**
78      * constructor. creates an empty packet by setting the target remote address
79      *
80      * @param remoteAddress the destination address
81      * @param remotePort the destination port number
82      * @param size the packet size
83      */

84     public UserDatagram(InetAddress JavaDoc remoteAddress, int remotePort, int size) {
85         init(new InetSocketAddress JavaDoc(remoteAddress, remotePort), ByteBuffer.allocate(size), size);
86     }
87     
88     /**
89      * constructor. creates an empty packet by setting the target remote address
90      *
91      * @param address the destination address
92      * @param size the packet size
93      */

94     public UserDatagram(SocketAddress JavaDoc address, int size) {
95         init(address, ByteBuffer.allocate(size), size);
96     }
97     
98     
99     /**
100      * constructor. creates packet, and sets the content with the given buffer
101      *
102      * @param data the data which will be written into the buffer
103      */

104     public UserDatagram(ByteBuffer JavaDoc data) {
105         this(null, data);
106     }
107     
108
109     /**
110      * constructor. creates packet by setting the target remote address,
111      * and sets the content with the given buffer
112      *
113      * @param remoteSocketAddress the destination address
114      * @param data the data which will be written into the buffer
115      */

116     public UserDatagram(SocketAddress JavaDoc remoteSocketAddress, ByteBuffer JavaDoc data) {
117         this(remoteSocketAddress, data, "UTF-8");
118     }
119
120     
121     /**
122      * constructor. creates packet by setting the target remote address,
123      * and sets the content with the given buffer
124      *
125      * @param remoteSocketAddress the destination address
126      * @param data the data which will be written into the buffer
127      * @param defaultEncoding the default encoding to use
128      */

129     UserDatagram(SocketAddress JavaDoc remoteSocketAddress, ByteBuffer JavaDoc data, String JavaDoc defaultEncoding) {
130         init(remoteSocketAddress, data, data.limit());
131         this.defaultEncoding = defaultEncoding;
132     }
133
134     
135     /**
136      * constructor. creates packet sets the content with the given byte array
137      *
138      * @param data the data which will be written into the buffer
139      */

140     public UserDatagram(byte[] data) {
141         this(null, data);
142     }
143         
144     
145     /**
146      * constructor. creates packet by setting the target remote address,
147      * and sets the content with the given byte array
148      *
149      * @param remoteHost the destination hostname
150      * @param remotePort the destination port number
151      * @param data the data which will be written into the buffer
152      */

153     public UserDatagram(String JavaDoc remoteHost, int remotePort, byte[] data) {
154         this(new InetSocketAddress JavaDoc(remoteHost, remotePort), data);
155     }
156     
157     
158
159     
160     /**
161      * constructor. creates packet by setting the target remote address,
162      * and sets the content with the given byte array
163      *
164      * @param remoteSocketAddress the destination address
165      * @param data the data which will be written into the buffer
166      */

167     public UserDatagram(SocketAddress JavaDoc remoteSocketAddress, byte[] data) {
168         ByteBuffer JavaDoc buffer = ByteBuffer.wrap(data);
169         buffer.position(buffer.limit());
170         init(remoteSocketAddress, buffer, data.length);
171     }
172     
173     
174     
175     private void init(SocketAddress JavaDoc remoteSocketAddress, ByteBuffer JavaDoc data, int packetSize) {
176         this.remoteSocketAddress =remoteSocketAddress;
177         this.data = data;
178     }
179     
180     
181     /**
182      * prepares the packet to send
183      *
184      */

185     void prepareForSend() {
186         data.clear();
187     }
188     
189
190     /**
191      * set the remote socket address
192      * @param remoteSocketAddress the remote socket address
193      */

194     void setRemoteAddress(SocketAddress JavaDoc remoteSocketAddress) {
195         this.remoteSocketAddress = remoteSocketAddress;
196     }
197     
198     
199     /**
200      * return the underlying data buffer
201      *
202      * @return the underlying data buffer
203      */

204     protected ByteBuffer JavaDoc getData() {
205         return data;
206     }
207
208         
209     /**
210      * Returns the socket address of the machine to which this packet is being sent
211      * or from which the packet was received.
212      *
213      * @return the socket address
214      */

215     public SocketAddress JavaDoc getRemoteSocketAddress() {
216         return remoteSocketAddress;
217     }
218     
219     
220     /**
221      * Returns the address of the machine to which this packet is being sent
222      * or from which the packet was received.
223      *
224      * @return the address
225      */

226     public InetAddress JavaDoc getRemoteAddress() {
227         if (remoteSocketAddress instanceof InetSocketAddress JavaDoc) {
228             return ((InetSocketAddress JavaDoc) remoteSocketAddress).getAddress();
229         } else {
230             return null;
231         }
232     }
233     
234     
235     /**
236      * Returns the port number of the machine to which this packet is being sent
237      * or from which the packet was received.
238      *
239      * @return the port number
240      */

241     public int getRemotePort() {
242         if (remoteSocketAddress instanceof InetSocketAddress JavaDoc) {
243             return ((InetSocketAddress JavaDoc) remoteSocketAddress).getPort();
244         } else {
245             return -1;
246         }
247     }
248     
249     
250     /**
251      * read a byte
252      *
253      * @return the byte value
254      * @throws BufferUnderflowException if the buffer's limit has been reached
255      * @throws IOException If some other I/O error occurs
256      */

257     public byte readByte() throws IOException JavaDoc, BufferUnderflowException JavaDoc {
258         return data.get();
259     }
260     
261     
262
263     
264     /**
265      * read a ByteBuffer by using a length defintion
266      *
267      * @param length the amount of bytes to read
268      * @return the ByteBuffer
269      * @throws BufferUnderflowException if the buffer's limit has been reached
270      * @throws IOException If some other I/O error occurs
271      */

272     public ByteBuffer JavaDoc readByteBufferByLength(int length) throws IOException JavaDoc, BufferUnderflowException JavaDoc {
273         int savedLimit = data.limit();
274         int savedPosition = data.position();
275         
276         data.limit(data.position() + length);
277         ByteBuffer JavaDoc sliced = data.slice();
278         
279         data.position(savedPosition + length);
280         data.limit(savedLimit);
281         return sliced;
282     }
283     
284     
285
286     
287     /**
288      * read bytes by using a length defintion
289      *
290      * @param length the amount of bytes to read
291      * @return the read bytes
292      * @throws BufferUnderflowException if the buffer's limit has been reached
293      * @throws IOException If some other I/O error occurs
294      */

295     public byte[] readBytesByLength(int length) throws IOException JavaDoc, BufferUnderflowException JavaDoc {
296         return DataConverter.toBytes(readByteBufferByLength(length));
297     }
298
299     
300     
301     
302     /**
303      * read a string by using a length definition
304      *
305      * @param length the amount of bytes to read
306      * @param encoding the encoding to use
307      * @return the string
308      * @throws IOException If some other I/O error occurs
309      * @throws BufferUnderflowException if the buffer's limit has been reached
310      * @throws UnsupportedEncodingException if the given encoding is not supported
311      */

312     public String JavaDoc readStringByLength(int length, String JavaDoc encoding) throws IOException JavaDoc, BufferUnderflowException JavaDoc, UnsupportedEncodingException JavaDoc {
313         return DataConverter.toString(readByteBufferByLength(length), encoding);
314     }
315
316     
317     
318     /**
319      * read a string by using a length definition and the connection default encoding
320      *
321      * @param length the amount of bytes to read
322      * @return the string
323      * @throws IOException If some other I/O error occurs
324      * @throws BufferUnderflowException if the buffer's limit has been reached
325      * @throws UnsupportedEncodingException if the given encoding is not supported
326      */

327     public String JavaDoc readStringByLength(int length) throws IOException JavaDoc, BufferUnderflowException JavaDoc, UnsupportedEncodingException JavaDoc {
328         return readStringByLength(length, defaultEncoding);
329     }
330     
331
332     
333     /**
334      * read a double
335      *
336      * @return the double value
337 c * @throws IOException If some other I/O error occurs
338      */

339     public double readDouble() throws IOException JavaDoc, BufferUnderflowException JavaDoc {
340         return data.getDouble();
341     }
342     
343     
344     
345     
346     /**
347      * read an int
348      *
349      * @return the int value
350      * @throws BufferUnderflowException if the buffer's limit has been reached
351      * @throws IOException If some other I/O error occurs
352      */

353     public int readInt() throws IOException JavaDoc, BufferUnderflowException JavaDoc {
354         return data.getInt();
355     }
356     
357     
358     
359     /**
360      * read an short
361      *
362      * @return the short value
363      * @throws BufferUnderflowException if the buffer's limit has been reached
364      * @throws IOException If some other I/O error occurs
365      */

366     public short readShort() throws IOException JavaDoc, BufferUnderflowException JavaDoc {
367         return data.getShort();
368     }
369     
370     
371     /**
372      * read a long
373      *
374      * @return the long value
375      * @throws BufferUnderflowException if the buffer's limit has been reached
376      * @throws IOException If some other I/O error occurs
377      */

378     public long readLong() throws IOException JavaDoc, BufferUnderflowException JavaDoc {
379         return data.getLong();
380     }
381
382         
383
384     /**
385      * read all remaining data as ByteBuffer
386      *
387      * @return the ByteBuffer
388      * @throws IOException If some other I/O error occurs
389      */

390     public ByteBuffer JavaDoc readByteBuffer() throws IOException JavaDoc {
391         ByteBuffer JavaDoc sliced = data.slice();
392         data.position(data.limit());
393         return sliced;
394     }
395
396     
397     
398     /**
399      * reads the remaining data as byte array
400      *
401      * @return the byte array
402      * @throws IOException If some other I/O error occurs
403      */

404     public byte[] readBytes() throws IOException JavaDoc {
405         return DataConverter.toBytes(readByteBuffer());
406     }
407     
408     
409     
410     /**
411      * read the remaining data as String
412      *
413      * @return the string
414      * @throws IOException If some other I/O error occurs
415      * @throws UnsupportedEncodingException if the default encoding is not supported
416      */

417     public String JavaDoc readString() throws IOException JavaDoc, UnsupportedEncodingException JavaDoc {
418         return readString(defaultEncoding);
419     }
420     
421     
422     
423     
424     /**
425      * read the remaining data as String
426      *
427      * @param encoding the encoding to use
428      * @return the string
429      * @throws IOException If some other I/O error occurs
430      * @throws UnsupportedEncodingException if the default encoding is not supported
431      */

432     public String JavaDoc readString(String JavaDoc encoding) throws IOException JavaDoc, UnsupportedEncodingException JavaDoc {
433         return DataConverter.toString(readByteBuffer(), encoding);
434     }
435
436     
437     /**
438      * read a string by using a delimiter and the connection default encoding
439      *
440      * @param delimiter the delimiter
441      * @return the string
442      * @throws IOException If some other I/O error occurs
443      * @throws BufferUnderflowException if the buffer's limit has been reached
444      * @throws UnsupportedEncodingException if the default encoding is not supported
445      */

446     public String JavaDoc readStringByDelimiter(String JavaDoc delimiter) throws IOException JavaDoc, BufferUnderflowException JavaDoc, UnsupportedEncodingException JavaDoc {
447         return readStringByDelimiter(delimiter, defaultEncoding, Integer.MAX_VALUE);
448     }
449     
450     
451     
452     /**
453      * read a string by using a delimiter and the connection default encoding
454      *
455      * @param delimiter the delimiter
456      * @param maxLength the max length of bytes that should be read. If the limit will be exceeded a MaxReadSizeExceededException will been thrown
457      * @return the string
458      * @throws IOException If some other I/O error occurs
459      * @throws MaxReadSizeExceededException If the max read length has been exceeded and the delimiter hasnít been found
460      * @throws BufferUnderflowException if the buffer's limit has been reached
461      * @throws UnsupportedEncodingException if the default encoding is not supported
462      */

463     public String JavaDoc readStringByDelimiter(String JavaDoc delimiter, int maxLength) throws IOException JavaDoc, BufferUnderflowException JavaDoc, UnsupportedEncodingException JavaDoc, MaxReadSizeExceededException {
464         return readStringByDelimiter(delimiter, defaultEncoding, maxLength);
465     }
466     
467     /**
468      * read a string by using a delimiter
469      *
470      * @param delimiter the delimiter
471      * @param encoding the encodin to use
472      * @param maxLength the max length of bytes that should be read. If the limit will be exceeded a MaxReadSizeExceededException will been thrown
473      * @return the string
474      * @throws IOException If some other I/O error occurs
475      * @throws BufferUnderflowException if the buffer's limit has been reached
476      * @throws MaxReadSizeExceededException If the max read length has been exceeded and the delimiter hasnít been found
477      * @throws UnsupportedEncodingException if the given encoding is not supported
478      */

479     public String JavaDoc readStringByDelimiter(String JavaDoc delimiter, String JavaDoc encoding, int maxLength) throws IOException JavaDoc, BufferUnderflowException JavaDoc, UnsupportedEncodingException JavaDoc, MaxReadSizeExceededException {
480         ByteBuffer JavaDoc buffer = readByteBufferByDelimiter(delimiter, maxLength);
481         return DataConverter.toString(buffer, encoding);
482     }
483
484     
485     /**
486      * read a ByteBuffer by using a delimiter
487      *
488      * For performance reasons, the ByteBuffer readByteBuffer method is
489      * generally preferable to get bytes
490      *
491      * @param delimiter the delimiter
492      * @param maxLength the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
493      * @return the ByteBuffer
494      * @throws BufferUnderflowException if the buffer's limit has been reached
495      * @throws MaxReadSizeExceededException If the max read length has been exceeded and the delimiter hasnít been found
496      * @throws IOException If some other I/O error occurs
497      */

498     public ByteBuffer JavaDoc readByteBufferByDelimiter(String JavaDoc delimiter, int maxLength) throws IOException JavaDoc, BufferUnderflowException JavaDoc, MaxReadSizeExceededException {
499         byte[] delimiterBytes = delimiter.getBytes();
500         int startPos = findDelimiter(data, delimiterBytes, maxLength);
501         if (startPos >= 0) {
502             int savedLimit = data.limit();
503             data.limit(startPos);
504             ByteBuffer JavaDoc result = data.slice();
505             data.limit(savedLimit);
506             data.position(startPos + delimiterBytes.length);
507
508             return result;
509         } else {
510             throw new BufferUnderflowException JavaDoc();
511         }
512     }
513
514
515     
516     /**
517      * read a byte array by using a delimiter
518      *
519      * For performance reasons, the ByteBuffer readByteBuffer method is
520      * generally preferable to get bytes
521      *
522      * @param delimiter the delimiter
523      * @param maxLength the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
524      * @return the read bytes
525      * @throws BufferUnderflowException if the buffer's limit has been reached
526      * @throws MaxReadSizeExceededException If the max read length has been exceeded and the delimiter hasnít been found
527      * @throws IOException If some other I/O error occurs
528      */

529     public byte[] readBytesByDelimiter(String JavaDoc delimiter,int maxLength) throws IOException JavaDoc, BufferUnderflowException JavaDoc, MaxReadSizeExceededException {
530         ByteBuffer JavaDoc buffer = readByteBufferByDelimiter(delimiter, maxLength);
531         return DataConverter.toBytes(buffer);
532     }
533     
534     
535     private static int findDelimiter(ByteBuffer JavaDoc buffer, byte[] delimiter, int maxLength) throws MaxReadSizeExceededException {
536         int result = -1;
537         
538         int delimiterPosition = 0;
539         
540         // iterator over buffer content
541
for (int pos = buffer.position(); pos < buffer.limit(); pos++) {
542             
543             byte b = buffer.get(pos);
544             if (b == delimiter[delimiterPosition]) {
545                 delimiterPosition++;
546                 if (delimiterPosition == delimiter.length) {
547                     result = (pos - delimiterPosition + 1);
548                     break;
549                 }
550             } else {
551                 delimiterPosition = 0;
552             }
553             
554         }
555         
556         if (result > maxLength) {
557             throw new MaxReadSizeExceededException();
558         }
559         
560         return result;
561     }
562     
563     
564     
565
566     /**
567      * writes a byte to the packet
568      *
569      * @param b the byte to write
570      * @return the number of send bytes
571      * @throws BufferOverflowException if the buffer's limit has been reached
572      * @throws IOException If some other I/O error occurs
573      */

574     public int write(byte b) throws IOException JavaDoc, BufferOverflowException JavaDoc {
575         data.put(b);
576         return 1;
577     }
578     
579
580     /**
581      * writes a short to the packet
582      *
583      * @param s the short to write
584      * @return the number of send bytes
585      * @throws BufferOverflowException if the buffer's limit has been reached
586      * @throws IOException If some other I/O error occurs
587      */

588     public int write(short s) throws IOException JavaDoc, BufferOverflowException JavaDoc {
589         data.putShort(s);
590         return 2;
591     }
592     
593     
594     /**
595      * writes bytes to the packet
596      *
597      * @param bytes the bytes to write
598      * @return the number of send bytes
599      * @throws BufferOverflowException if the buffer's limit has been reached
600      * @throws IOException If some other I/O error occurs
601      */

602     public int write(byte... bytes) throws IOException JavaDoc, BufferOverflowException JavaDoc {
603         data.put(bytes);
604         return bytes.length;
605     }
606     
607     
608
609     /**
610      * writes bytes to the packet
611      *
612      * @param bytes the bytes to write
613      * @param offset The offset of the subarray to be used; must be non-negative and no larger than array.length. The new buffer's position will be set to this value.
614      * @param length The length of the subarray to be used; must be non-negative and no larger than array.length - offset. The new buffer's limit will be set to offset + length.
615      * @return the number of send bytes
616      * @throws BufferOverflowException if the buffer's limit has been reached
617      * @throws IOException If some other I/O error occurs
618      */

619     public int write(byte[] bytes, int offset, int length) throws IOException JavaDoc, BufferOverflowException JavaDoc {
620         data.put(bytes, offset, length);
621         return length;
622     }
623     
624     
625     /**
626      * writes a byte buffer to the packet
627      *
628      * @param buffer the bytes to write
629      * @return the number of send bytes
630      * @throws BufferOverflowException if the buffer's limit has been reached
631      * @throws IOException If some other I/O error occurs
632      */

633     public int write(ByteBuffer JavaDoc buffer) throws IOException JavaDoc, BufferOverflowException JavaDoc {
634         int length = buffer.remaining();
635         data.put(buffer);
636         return length;
637     }
638     
639     
640     
641     /**
642      * writes a byte array to the packet
643      *
644      * @param buffers the bytes to write
645      * @return the number of send bytes
646      * @throws BufferOverflowException if the buffer's limit has been reached
647      * @throws IOException If some other I/O error occurs
648      */

649     public long write(ByteBuffer JavaDoc[] buffers) throws IOException JavaDoc, BufferOverflowException JavaDoc {
650         int length = 0;
651         for (ByteBuffer JavaDoc buffer : buffers) {
652             length += write(buffer);
653         }
654         return length;
655     }
656     
657     
658
659     
660     /**
661      * writes a double to the packet
662      *
663      * @param d the int value to write
664      * @return the number of send bytes
665      * @throws BufferOverflowException if the buffer's limit has been reached
666      * @throws IOException If some other I/O error occurs
667      */

668     public int write(double d) throws IOException JavaDoc, BufferOverflowException JavaDoc {
669         data.putDouble(d);
670         return 8;
671     }
672     
673     
674     /**
675      * writes a int to the packet
676      *
677      * @param i the int value to write
678      * @return the number of send bytes
679      * @throws BufferOverflowException if the buffer's limit has been reached
680      * @throws IOException If some other I/O error occurs
681      */

682     public int write(int i) throws IOException JavaDoc, BufferOverflowException JavaDoc {
683         data.putInt(i);
684         return 4;
685     }
686     
687     
688     /**
689      * writes a long to the packet
690      *
691      * @param l the int value to write
692      * @return the number of send bytes
693      * @throws BufferOverflowException if the buffer's limit has been reached
694      * @throws IOException If some other I/O error occurs
695      */

696     public int write(long l) throws IOException JavaDoc, BufferOverflowException JavaDoc {
697         data.putLong(l);
698         return 8;
699     }
700     
701     
702     /**
703      * write a message
704      *
705      * @param message the message to write
706      * @return the number of send bytes
707      * @throws IOException If some other I/O error occurs
708      * @throws BufferOverflowException if the buffer's limit has been reached
709      */

710     public int write(String JavaDoc message) throws IOException JavaDoc, BufferOverflowException JavaDoc {
711         return write(message, defaultEncoding);
712     }
713     
714     
715     /**
716      * write a message
717      *
718      * @param message the message to write
719      * @param encoding the encoding which should be used th encode the chars into byte (e.g. 'US-ASCII' or 'UTF-8')
720      * @return the number of send bytes
721      * @throws IOException If some other I/O error occurs
722      * @throws BufferOverflowException if the buffer's limit has been reached
723      */

724     public int write(String JavaDoc message, String JavaDoc encoding) throws IOException JavaDoc, BufferOverflowException JavaDoc {
725         byte[] bytes = message.getBytes(encoding);
726         data.put(bytes);
727         
728         return bytes.length;
729     }
730     
731     
732     /**
733      * get the packet size
734      *
735      * @return the packet size
736      */

737     public int getSize() {
738         return data.limit();
739     }
740
741     /**
742      * get the remaining, unwritten packet size
743      *
744      * @return the remaining, unwritten packet size
745      */

746     public int getRemaining() {
747         return data.remaining();
748     }
749
750     
751     
752     @Override JavaDoc
753     public String JavaDoc toString() {
754         StringBuilder JavaDoc sb = new StringBuilder JavaDoc();
755         
756         if (remoteSocketAddress != null) {
757             sb.append("remoteAddress=" + remoteSocketAddress.toString() + " ");
758         } else {
759             sb.append("remoteAddress=null ");
760         }
761         
762         if (data != null) {
763             sb.append("data=" + DataConverter.toHexString(new ByteBuffer JavaDoc[] {data.duplicate()}, 500) + " ");
764         } else {
765             sb.append("data=null ");
766         }
767         
768         return sb.toString();
769     }
770 }
Popular Tags