@@ -0,0 +1,1630 @@
+// Copyright (c) 2006- Facebook%0A// Distributed under the Thrift Software License%0A//%0A// See accompanying file LICENSE or visit the Thrift site at:%0A// http://developers.facebook.com/thrift/%0A%0Apackage com.facebook.thrift.transport;%0A%0Aimport com.facebook.thrift.TByteArrayOutputStream;%0Aimport java.io.UnsupportedEncodingException;%0A%0A/**%0A * Memory buffer-based implementation of the TTransport interface.%0A *%0A * @author Chad Walters %3Cchad@powerset.com%3E%0A */%0Apublic class TMemoryBuffer extends TTransport %7B%0A%0A  /**%0A   *%0A   */%0A  public TMemoryBuffer(int size) %7B%0A    arr_ = new TByteArrayOutputStream(size);%0A  %7D%0A%0A  @Override%0A  public boolean isOpen() %7B%0A    return true;%0A  %7D%0A%0A  @Override%0A  public void open() %7B%0A    /* Do nothing */%0A  %7D%0A%0A  @Override%0A  public void close() %7B%0A    /* Do nothing */%0A  %7D%0A%0A  @Override%0A  public int read(byte%5B%5D buf, int off, int len) %7B%0A    byte%5B%5D src = arr_.get();%0A    int amtToRead = (len %3E arr_.len() - pos_ ? arr_.len() - pos_ : len);%0A    if (amtToRead %3E 0) %7B%0A      System.arraycopy(src, pos_, buf, off, amtToRead);%0A      pos_ += amtToRead;%0A    %7D%0A    return amtToRead;%0A  %7D%0A%0A  @Override%0A  public void write(byte%5B%5D buf, int off, int len) %7B%0A    arr_.write(buf, off, len);%0A  %7D%0A%0A  /**%0A   * Output the contents of the memory buffer as a String, using the supplied%0A   * encoding%0A   * @param enc  the encoding to use%0A   * @return the contents of the memory buffer as a String%0A   */%0A  public String toString(String enc) throws UnsupportedEncodingException %7B%0A    return arr_.toString(enc);%0A  %7D%0A%0A  // The contents of the buffer%0A  private TByteArrayOutputStream arr_;%0A%0A  // Position to read next byte from%0A  private int pos_;%0A%7D%0A%0A

Add Java memory buffer transport implementation.