org.apache.lucene.store
Class IndexInput

java.lang.Object
  extended by org.apache.lucene.store.IndexInput
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
BufferedIndexInput

public abstract class IndexInput
extends java.lang.Object
implements java.lang.Cloneable

Abstract base class for input from a file in a Directory. A random-access input stream. Used for all Lucene index input operations.

See Also:
Directory

Constructor Summary
IndexInput()
           
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this stream.
abstract  void close()
          Closes the stream to futher operations.
abstract  long getFilePointer()
          Returns the current position in this file, where the next read will occur.
abstract  long length()
          The number of bytes in the file.
abstract  byte readByte()
          Reads and returns a single byte.
abstract  void readBytes(byte[] b, int offset, int len)
          Reads a specified number of bytes into an array at the specified offset.
 void readChars(char[] buffer, int start, int length)
          Reads UTF-8 encoded characters into an array.
 int readInt()
          Reads four bytes and returns an int.
 long readLong()
          Reads eight bytes and returns a long.
 java.lang.String readString()
          Reads a string.
 int readVInt()
          Reads an int stored in variable-length format.
 long readVLong()
          Reads a long stored in variable-length format.
abstract  void seek(long pos)
          Sets current position in this file, where the next read will occur.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexInput

public IndexInput()
Method Detail

readByte

public abstract byte readByte()
                       throws java.io.IOException
Reads and returns a single byte.

Throws:
java.io.IOException
See Also:
IndexOutput.writeByte(byte)

readBytes

public abstract void readBytes(byte[] b,
                               int offset,
                               int len)
                        throws java.io.IOException
Reads a specified number of bytes into an array at the specified offset.

Parameters:
b - the array to read bytes into
offset - the offset in the array to start storing bytes
len - the number of bytes to read
Throws:
java.io.IOException
See Also:
IndexOutput.writeBytes(byte[],int)

readInt

public int readInt()
            throws java.io.IOException
Reads four bytes and returns an int.

Throws:
java.io.IOException
See Also:
IndexOutput.writeInt(int)

readVInt

public int readVInt()
             throws java.io.IOException
Reads an int stored in variable-length format. Reads between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported.

Throws:
java.io.IOException
See Also:
IndexOutput.writeVInt(int)

readLong

public long readLong()
              throws java.io.IOException
Reads eight bytes and returns a long.

Throws:
java.io.IOException
See Also:
IndexOutput.writeLong(long)

readVLong

public long readVLong()
               throws java.io.IOException
Reads a long stored in variable-length format. Reads between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.

Throws:
java.io.IOException

readString

public java.lang.String readString()
                            throws java.io.IOException
Reads a string.

Throws:
java.io.IOException
See Also:
IndexOutput.writeString(String)

readChars

public void readChars(char[] buffer,
                      int start,
                      int length)
               throws java.io.IOException
Reads UTF-8 encoded characters into an array.

Parameters:
buffer - the array to read characters into
start - the offset in the array to start storing characters
length - the number of characters to read
Throws:
java.io.IOException
See Also:
IndexOutput.writeChars(String,int,int)

close

public abstract void close()
                    throws java.io.IOException
Closes the stream to futher operations.

Throws:
java.io.IOException

getFilePointer

public abstract long getFilePointer()
Returns the current position in this file, where the next read will occur.

See Also:
seek(long)

seek

public abstract void seek(long pos)
                   throws java.io.IOException
Sets current position in this file, where the next read will occur.

Throws:
java.io.IOException
See Also:
getFilePointer()

length

public abstract long length()
The number of bytes in the file.


clone

public java.lang.Object clone()
Returns a clone of this stream.

Clones of a stream access the same data, and are positioned at the same point as the stream they were cloned from.

Expert: Subclasses must ensure that clones may be positioned at different points in the input from each other and from the stream they were cloned from.

Overrides:
clone in class java.lang.Object


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.