org.apache.commons.compress.archivers.ar
Class ArArchiveInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.commons.compress.archivers.ArchiveInputStream
          extended by org.apache.commons.compress.archivers.ar.ArArchiveInputStream
All Implemented Interfaces:
java.io.Closeable

public class ArArchiveInputStream
extends ArchiveInputStream

Implements the "ar" archive format as an input stream.


Field Summary
private  boolean closed
           
private  ArArchiveEntry currentEntry
           
private  long entryOffset
           
private  java.io.InputStream input
           
private  byte[] namebuffer
           
private  long offset
           
 
Constructor Summary
ArArchiveInputStream(java.io.InputStream pInput)
          Constructs an Ar input stream with the referenced stream
 
Method Summary
private  int asInt(byte[] input)
           
private  int asInt(byte[] input, int base)
           
private  long asLong(byte[] input)
           
 void close()
           
private  java.lang.String getExtendedName(int offset)
          Get an extended name from the GNU extended name buffer.
 ArArchiveEntry getNextArEntry()
          Returns the next AR entry in this stream.
 ArchiveEntry getNextEntry()
          Returns the next Archive Entry in this Stream.
static boolean matches(byte[] signature, int length)
          Checks if the signature matches ASCII "!" followed by a single LF control character
 int read(byte[] b, int off, int len)
           
 
Methods inherited from class org.apache.commons.compress.archivers.ArchiveInputStream
canReadEntryData, count, count, getBytesRead, getCount, pushedBackBytes, read
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

input

private final java.io.InputStream input

offset

private long offset

closed

private boolean closed

currentEntry

private ArArchiveEntry currentEntry

namebuffer

private byte[] namebuffer

entryOffset

private long entryOffset
Constructor Detail

ArArchiveInputStream

public ArArchiveInputStream(java.io.InputStream pInput)
Constructs an Ar input stream with the referenced stream

Parameters:
pInput - the ar input stream
Method Detail

getNextArEntry

public ArArchiveEntry getNextArEntry()
                              throws java.io.IOException
Returns the next AR entry in this stream.

Returns:
the next AR entry.
Throws:
java.io.IOException - if the entry could not be read

getExtendedName

private java.lang.String getExtendedName(int offset)
                                  throws java.io.IOException
Get an extended name from the GNU extended name buffer.

Parameters:
offset - pointer to entry within the buffer
Returns:
the extended file name; without trailing "/" if present.
Throws:
java.io.IOException - if name not found or buffer not set up

asLong

private long asLong(byte[] input)

asInt

private int asInt(byte[] input)

asInt

private int asInt(byte[] input,
                  int base)

getNextEntry

public ArchiveEntry getNextEntry()
                          throws java.io.IOException
Description copied from class: ArchiveInputStream
Returns the next Archive Entry in this Stream.

Specified by:
getNextEntry in class ArchiveInputStream
Returns:
the next entry, or null if there are no more entries
Throws:
java.io.IOException - if the next entry could not be read

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

matches

public static boolean matches(byte[] signature,
                              int length)
Checks if the signature matches ASCII "!" followed by a single LF control character

Parameters:
signature - the bytes to check
length - the number of bytes to check
Returns:
true, if this stream is an Ar archive stream, false otherwise