org.terrier.structures
Class FilePosition

java.lang.Object
  extended by org.terrier.structures.FilePosition
All Implemented Interfaces:
BitFilePosition

public class FilePosition
extends java.lang.Object
implements BitFilePosition

Models a position within a file as the offset in bytes and the offset in bits in that byte. For example, an instance of the class FilePosition that points to the 10th bit of a file should be constructed with a byte offset of 1 and a bit offset of 2.

Author:
Craig Macdonald, Vassilis Plachouras & John Kane

Field Summary
 byte Bits
          The offset in bits within the pointed byte.
 long Bytes
          The offset within a file in bytes.
protected static int sizeInBytes
          The number of bytes a file position could be converted to - 8 for the byte's long, 1 for the bits
 
Constructor Summary
FilePosition()
          Default constructor.
FilePosition(BitFilePosition in)
          Create a new FilePosition based on an existing one
FilePosition(byte[] in)
          Create an instance based on a byte buffer
FilePosition(long bytesPosition, byte bitsPosition)
          Creates an instance of the class from the given byte and bit offsets.
 
Method Summary
 void build(java.io.DataInput di)
          unseralize this object from the named dataoutput instance
 boolean equals(java.lang.Object o)
          Is this FilePosition equal to another?
 long getOffset()
          Return the offset
 byte getOffsetBits()
          Return the offset bits
 int hashCode()
          Define a hashcode for this - objects which defined equals(Object) should define hashCode() also
 void setOffset(BitFilePosition pos)
          Set the offset
 void setOffset(long bytes, byte bits)
          Set the offset in bytes and bits
static int sizeInBytes()
          How large is this object when serialized
 void toBytes(java.io.DataOutput dai)
          Seralize this object to the named dataoutput instance
 java.lang.String toString()
          String representation of this object
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

sizeInBytes

protected static final int sizeInBytes
The number of bytes a file position could be converted to - 8 for the byte's long, 1 for the bits

See Also:
Constant Field Values

Bytes

public long Bytes
The offset within a file in bytes.


Bits

public byte Bits
The offset in bits within the pointed byte.

Constructor Detail

FilePosition

public FilePosition()
Default constructor. Create an uninitialiased FilePosition


FilePosition

public FilePosition(long bytesPosition,
                    byte bitsPosition)
Creates an instance of the class from the given byte and bit offsets.

Parameters:
bytesPosition - long the given byte offset.
bitsPosition - byte the given bit offset.

FilePosition

public FilePosition(byte[] in)
Create an instance based on a byte buffer


FilePosition

public FilePosition(BitFilePosition in)
Create a new FilePosition based on an existing one

Method Detail

getOffset

public long getOffset()
Return the offset

Specified by:
getOffset in interface BitFilePosition

getOffsetBits

public byte getOffsetBits()
Return the offset bits

Specified by:
getOffsetBits in interface BitFilePosition

setOffset

public void setOffset(long bytes,
                      byte bits)
Set the offset in bytes and bits

Specified by:
setOffset in interface BitFilePosition

setOffset

public void setOffset(BitFilePosition pos)
Set the offset

Specified by:
setOffset in interface BitFilePosition

sizeInBytes

public static int sizeInBytes()
How large is this object when serialized


toBytes

public void toBytes(java.io.DataOutput dai)
Seralize this object to the named dataoutput instance


build

public void build(java.io.DataInput di)
unseralize this object from the named dataoutput instance


equals

public boolean equals(java.lang.Object o)
Is this FilePosition equal to another?

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Define a hashcode for this - objects which defined equals(Object) should define hashCode() also

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
String representation of this object

Overrides:
toString in class java.lang.Object


Terrier 3.5. Copyright © 2004-2011 University of Glasgow