Xindice API
version 1.1

org.apache.xindice.util
Class ByteArrayInput

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.ByteArrayInputStream
              |
              +--org.apache.xindice.util.ByteArrayInput

public final class ByteArrayInput
extends ByteArrayInputStream

ByteArrayInput is a wrapper around ByteArrayInputStream that allows one access to the underlying array and position pointer.

Version:
$Revision: 518460 $, $Date: 2007-03-14 23:47:19 -0400 (Wed, 14 Mar 2007) $

Fields inherited from class java.io.ByteArrayInputStream
buf, count, mark, pos
 
Constructor Summary
ByteArrayInput(byte[] buf)
           
ByteArrayInput(byte[] buf, int pos, int length)
           
 
Method Summary
 byte[] getArray()
          getArray returns the Byte Array.
 InputStream getInputStream()
          getInputStream returns a newly created ByteArrayInput based on this instance's data and current position.
 int getPos()
          getPos returns the current read position in the array.
 void setPos(int pos)
          setPos sets the current read position in the array.
 
Methods inherited from class java.io.ByteArrayInputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.io.InputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayInput

public ByteArrayInput(byte[] buf)

ByteArrayInput

public ByteArrayInput(byte[] buf,
                      int pos,
                      int length)
Method Detail

getPos

public int getPos()
getPos returns the current read position in the array. This value is not a relative offset from the start of the original stream, but an absolute position in the array itself.
Returns:
The Array Position

setPos

public void setPos(int pos)
            throws IOException
setPos sets the current read position in the array. This value is not a relative offset from the start of the original stream, but an absolute position in the array itself. As such, you can seek back to a position before the originating position of the InputStream.
Parameters:
pos - The Array Position
Throws:
IOException - if the position is out of range

getArray

public byte[] getArray()
getArray returns the Byte Array.
Returns:
The Byte Array

getInputStream

public InputStream getInputStream()
getInputStream returns a newly created ByteArrayInput based on this instance's data and current position. This is a good alternative to mark and reset because it allows multiple threads to safely access the byte array at one time.
Returns:
The New ByteArrayInput object

Xindice API
version 1.1

Copyright (c) 1999-2007 The Apache Software Foundation. All Rights Reserved.