comparison src/org/eclipse/jetty/io/AbstractBuffer.java @ 1046:a8c92b0a08ed

add JBuffer
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 07 Nov 2016 22:39:39 -0700
parents dd71a59fcf72
children
comparison
equal deleted inserted replaced
1045:48506d03e230 1046:a8c92b0a08ed
55 protected AbstractBuffer(int access) 55 protected AbstractBuffer(int access)
56 { 56 {
57 _access = access; 57 _access = access;
58 } 58 }
59 59
60 private byte[] asArray() 60 public final byte[] asArray()
61 { 61 {
62 byte[] bytes = new byte[remaining()]; 62 byte[] bytes = new byte[remaining()];
63 byte[] array = array(); 63 byte[] array = array();
64 if (array != null) 64 if (array != null)
65 System.arraycopy(array, getIndex(), bytes, 0, bytes.length); 65 System.arraycopy(array, getIndex(), bytes, 0, bytes.length);
427 LOG.warn("",e); 427 LOG.warn("",e);
428 return new String(asArray(), 0, remaining()); 428 return new String(asArray(), 0, remaining());
429 } 429 }
430 } 430 }
431 431
432 @Override
433 public final String toString(Charset charset)
434 {
435 try
436 {
437 byte[] bytes=array();
438 if (bytes!=null)
439 return new String(bytes,getIndex(),remaining(),charset);
440 return new String(asArray(), 0, remaining(),charset);
441 }
442 catch(Exception e)
443 {
444 LOG.warn("",e);
445 return new String(asArray(), 0, remaining());
446 }
447 }
448
449 /* ------------------------------------------------------------ */ 432 /* ------------------------------------------------------------ */
450 public String toDebugString() 433 public String toDebugString()
451 { 434 {
452 return getClass()+"@"+super.hashCode(); 435 return getClass()+"@"+super.hashCode();
453 } 436 }