/** Produces a formatted string as specified by the conversion pattern. */ public String format(LoggingEvent event) { // Reset working stringbuffer if(sbuf.capacity() > MAX_CAPACITY) { sbuf = new StringBuffer(BUF_SIZE); } else { sbuf.setLength(0); } PatternConverter c = head; while(c != null) { c.format(sbuf, event); c = c.next; } return sbuf.toString(); } }
public String format(LoggingEvent event) { if(sbuf.capacity() > MAX_CAPACITY) { sbuf = new StringBuffer(BUF_SIZE); } else {
public String format( LoggingEvent event ) { if ( sbuf.capacity() > MAX_CAPACITY ) { sbuf = new StringBuffer( BUF_SIZE ); } else {
if(buf.capacity() > UPPER_LIMIT) { buf = new StringBuffer(DEFAULT_SIZE); } else {
public String format( LoggingEvent event ) { if ( sbuf.capacity() > MAX_CAPACITY ) { sbuf = new StringBuffer( BUF_SIZE ); } else {
/** Produces a formatted string as specified by the conversion pattern. */ public String format(LoggingEvent event) { // Reset working stringbuffer if(sbuf.capacity() > MAX_CAPACITY) { sbuf = new StringBuffer(BUF_SIZE); } else { sbuf.setLength(0); } PatternConverter c = head; while(c != null) { c.format(sbuf, event); c = c.next; } return sbuf.toString(); } }
/** Produces a formatted string as specified by the conversion pattern. */ public String format(LoggingEvent event) { // Reset working stringbuffer if(sbuf.capacity() > MAX_CAPACITY) { sbuf = new StringBuffer(BUF_SIZE); } else { sbuf.setLength(0); } PatternConverter c = head; while(c != null) { c.format(sbuf, event); c = c.next; } return sbuf.toString(); } }
public String format(LoggingEvent event) { if(sbuf.capacity() > MAX_CAPACITY) { sbuf = new StringBuffer(BUF_SIZE); } else {
public String format(LoggingEvent event) { if(sbuf.capacity() > MAX_CAPACITY) { sbuf = new StringBuffer(BUF_SIZE); } else {
if(buf.capacity() > UPPER_LIMIT) { buf = new StringBuffer(DEFAULT_SIZE); } else {
/** * Return the current capacity of the buffer (i.e., the number of * characters left before truncation will occur). * * @return The capacity. A 0 means no more room is left, and all further * inserted or appended characters will cause truncation. * * @see #length */ public int capacity() { return buf.capacity(); }
StringBuffer buf3 = new StringBuffer("a"); System.out.println(buf3.capacity());
// initial capacity (of the array behind the scenes) will be 16. StringBuffer buff1 = new StringBuffer("tuts point"); // The above constructor increases the capacity by 16 + stringArgument.length = 16 + 10 = 26 ( hence the output) System.out.println("Old Capacity of buff1 = " + buff1.capacity()); // 26 ->check buff1.ensureCapacity(28); // here 28 is minimumcapacity. // the above line of code calls expandCapacity() of AbstractStringBuilder which does this: //`(value.length + 1) * 2` i.e, 26+1 * 2 = 54 . Hence the output. System.out.println("New Capacity of buff1 = " + buff1.capacity()); //54 --> check
public String convert(E event) { if (buf.capacity() > MAX_CAPACITY) { buf = new StringBuffer(INITIAL_BUF_SIZE); } else { buf.setLength(0); } for (Converter<E> c = childConverter; c != null; c = c.next) { c.write(buf, event); } return buf.toString(); }
public ByteBuffer toNative(StringBuffer parameter, ToNativeContext context) { if (parameter == null) { return null; } else { ByteBuffer buf = ParameterFlags.isIn(parameterFlags) ? charset.encode(CharBuffer.wrap(parameter)) : ByteBuffer.allocate(parameter.capacity() + 1); if ((ParameterFlags.isOut(parameterFlags) && buf.capacity() < parameter.capacity() + 1) || !buf.hasArray()) { byte[] array = new byte[parameter.capacity() + 1]; buf.get(array, 0, buf.remaining()); return ByteBuffer.wrap(array); } else { return buf; } } }
public ByteBuffer toNative(StringBuffer parameter, ToNativeContext context) { if (parameter == null) { return null; } else { ByteBuffer buf = ParameterFlags.isIn(parameterFlags) ? charset.encode(CharBuffer.wrap(parameter)) : ByteBuffer.allocate(parameter.capacity() + 1); if ((ParameterFlags.isOut(parameterFlags) && buf.capacity() < parameter.capacity() + 1) || !buf.hasArray()) { byte[] array = new byte[parameter.capacity() + 1]; buf.get(array, 0, buf.remaining()); return ByteBuffer.wrap(array); } else { return buf; } } }
public ByteBuffer toNative(StringBuffer parameter, ToNativeContext context) { if (parameter == null) { return null; } else { ByteBuffer buf = ParameterFlags.isIn(parameterFlags) ? charset.encode(CharBuffer.wrap(parameter)) : ByteBuffer.allocate(parameter.capacity() + 1); if ((ParameterFlags.isOut(parameterFlags) && buf.capacity() < parameter.capacity() + 1) || !buf.hasArray()) { byte[] array = new byte[parameter.capacity() + 1]; buf.get(array, 0, buf.remaining()); return ByteBuffer.wrap(array); } else { return buf; } } }