public void writeUTF(final String s) throws IOException { final int len = UTFUtils.getShortUTFLength(s); final int position = this.position; final int bufsize = buffer.length; int remaining = bufsize - position; if (len > bufsize >> 1 || len + 2 > remaining) { // the string will take up more than half the buffer or it is bigger than the remaining space // so don't bother double-buffering this block flush(); if (len < 253) { serialMarshaller.write(TC_BLOCKDATA); serialMarshaller.write(len + 2); serialMarshaller.writeShort(len); UTFUtils.writeUTFBytes(serialMarshaller, s); } else { serialMarshaller.write(TC_BLOCKDATALONG); serialMarshaller.writeInt(len + 2); serialMarshaller.writeShort(len); UTFUtils.writeUTFBytes(serialMarshaller, s); } } else { // the string will fit in this buffer writeShort(len); UTFUtils.writeUTFBytes(this, s); } }
public void writeUTF(final String s) throws IOException { final int len = UTFUtils.getShortUTFLength(s); final int position = this.position; final int bufsize = buffer.length; int remaining = bufsize - position; if (len > bufsize >> 1 || len + 2 > remaining) { // the string will take up more than half the buffer or it is bigger than the remaining space // so don't bother double-buffering this block flush(); if (len < 253) { serialMarshaller.write(TC_BLOCKDATA); serialMarshaller.write(len + 2); serialMarshaller.writeShort(len); UTFUtils.writeUTFBytes(serialMarshaller, s); } else { serialMarshaller.write(TC_BLOCKDATALONG); serialMarshaller.writeInt(len + 2); serialMarshaller.writeShort(len); UTFUtils.writeUTFBytes(serialMarshaller, s); } } else { // the string will fit in this buffer writeShort(len); UTFUtils.writeUTFBytes(this, s); } }
public void writeUTF(final String s) throws IOException { final int len = UTFUtils.getShortUTFLength(s); final int position = this.position; final int bufsize = buffer.length; int remaining = bufsize - position; if (len > bufsize >> 1 || len + 2 > remaining) { // the string will take up more than half the buffer or it is bigger than the remaining space // so don't bother double-buffering this block flush(); if (len < 253) { serialMarshaller.write(TC_BLOCKDATA); serialMarshaller.write(len + 2); serialMarshaller.writeShort(len); UTFUtils.writeUTFBytes(serialMarshaller, s); } else { serialMarshaller.write(TC_BLOCKDATALONG); serialMarshaller.writeInt(len + 2); serialMarshaller.writeShort(len); UTFUtils.writeUTFBytes(serialMarshaller, s); } } else { // the string will fit in this buffer writeShort(len); UTFUtils.writeUTFBytes(this, s); } }
public void writeUTF(final String s) throws IOException { final int len = UTFUtils.getShortUTFLength(s); final int position = this.position; final int bufsize = buffer.length; int remaining = bufsize - position; if (len > bufsize >> 1 || len + 2 > remaining) { // the string will take up more than half the buffer or it is bigger than the remaining space // so don't bother double-buffering this block flush(); if (len < 253) { serialMarshaller.write(TC_BLOCKDATA); serialMarshaller.write(len + 2); serialMarshaller.writeShort(len); UTFUtils.writeUTFBytes(serialMarshaller, s); } else { serialMarshaller.write(TC_BLOCKDATALONG); serialMarshaller.writeInt(len + 2); serialMarshaller.writeShort(len); UTFUtils.writeUTFBytes(serialMarshaller, s); } } else { // the string will fit in this buffer writeShort(len); UTFUtils.writeUTFBytes(this, s); } }