From activemq-commits-return-3822-apmail-geronimo-activemq-commits-archive=geronimo.apache.org@geronimo.apache.org Wed Nov 01 17:14:05 2006 Return-Path: Delivered-To: apmail-geronimo-activemq-commits-archive@www.apache.org Received: (qmail 77161 invoked from network); 1 Nov 2006 17:14:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Nov 2006 17:14:04 -0000 Received: (qmail 27226 invoked by uid 500); 1 Nov 2006 17:14:15 -0000 Delivered-To: apmail-geronimo-activemq-commits-archive@geronimo.apache.org Received: (qmail 27206 invoked by uid 500); 1 Nov 2006 17:14:15 -0000 Mailing-List: contact activemq-commits-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-commits@geronimo.apache.org Received: (qmail 27197 invoked by uid 99); 1 Nov 2006 17:14:15 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Nov 2006 09:14:15 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Nov 2006 09:14:03 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 008BA1A9846; Wed, 1 Nov 2006 09:13:39 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r469986 - in /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data: StoreByteArrayInputStream.java StoreByteArrayOutputStream.java Date: Wed, 01 Nov 2006 17:13:39 -0000 To: activemq-commits@geronimo.apache.org From: rajdavies@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061101171340.008BA1A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rajdavies Date: Wed Nov 1 09:13:39 2006 New Revision: 469986 URL: http://svn.apache.org/viewvc?view=rev&rev=469986 Log: support for ByteSequence Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/StoreByteArrayInputStream.java incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/StoreByteArrayOutputStream.java Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/StoreByteArrayInputStream.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/StoreByteArrayInputStream.java?view=diff&rev=469986&r1=469985&r2=469986 ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/StoreByteArrayInputStream.java (original) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/StoreByteArrayInputStream.java Wed Nov 1 09:13:39 2006 @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.UTFDataFormatException; +import org.apache.activemq.util.ByteSequence; /** * Optimized ByteArrayInputStream that can be used more than once * @@ -29,15 +30,27 @@ public final class StoreByteArrayInputStream extends InputStream implements DataInput{ private byte[] buf; private int pos; + private int offset; /** - * Creates a WireByteArrayInputStream. + * Creates a StoreByteArrayInputStream. * * @param buf the input buffer. */ public StoreByteArrayInputStream(byte buf[]){ this.buf=buf; this.pos=0; + this.offset = 0; + } + + /** + * Creates a StoreByteArrayInputStream. + * + * @param sequence the input buffer. + */ + public StoreByteArrayInputStream(ByteSequence sequence){ + this.buf=sequence.getData(); + this.offset=this.pos=sequence.getOffset(); } /** @@ -47,8 +60,12 @@ this(new byte[0]); } + /** + * + * @return the size + */ public int size(){ - return pos; + return pos-offset; } /** @@ -59,13 +76,23 @@ } /** - * reset the WireByteArrayInputStream to use an new byte array + * reset the StoreByteArrayInputStream to use an new byte array * * @param newBuff */ public void restart(byte[] newBuff){ buf=newBuff; pos=0; + } + + /** + * reset the StoreByteArrayInputStream to use an new ByteSequence + * @param sequence + * + */ + public void restart(ByteSequence sequence){ + this.buf=sequence.getData(); + this.pos=sequence.getOffset(); } /** Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/StoreByteArrayOutputStream.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/StoreByteArrayOutputStream.java?view=diff&rev=469986&r1=469985&r2=469986 ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/StoreByteArrayOutputStream.java (original) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/data/StoreByteArrayOutputStream.java Wed Nov 1 09:13:39 2006 @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.UTFDataFormatException; +import org.apache.activemq.util.ByteSequence; /** * Optimized ByteArrayOutputStream * @@ -59,6 +60,14 @@ buf=new byte[size]; pos=0; } + + /** + * Get a ByteSequence from the stream + * @return the byte sequence + */ + public ByteSequence toByteSequence() { + return new ByteSequence(buf, 0, pos); + } /** * Writes the specified byte to this byte array output stream. @@ -117,6 +126,8 @@ public int size(){ return pos; } + + public void writeBoolean(boolean v){ ensureEnoughBuffer(1);