Package org.terrier.structures
Class FilePosition
- java.lang.Object
- 
- 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 SummaryFields Modifier and Type Field Description byteBitsThe offset in bits within the pointed byte.longBytesThe offset within a file in bytes.protected static intsizeInBytesThe number of bytes a file position could be converted to - 8 for the byte's long, 1 for the bits
 - 
Constructor SummaryConstructors Constructor Description FilePosition()Default constructor.FilePosition(byte[] in)Create an instance based on a byte bufferFilePosition(long bytesPosition, byte bitsPosition)Creates an instance of the class from the given byte and bit offsets.FilePosition(BitFilePosition in)Create a new FilePosition based on an existing one
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuild(java.io.DataInput di)unseralize this object from the named dataoutput instancebooleanequals(java.lang.Object o)Is this FilePosition equal to another?longgetOffset()Return the number of bytes offset.bytegetOffsetBits()Return the number of bits offset.inthashCode()Define a hashcode for this - objects which defined equals(Object) should define hashCode() alsovoidsetOffset(long bytes, byte bits)Set the offset in number of bytes and number of bits.voidsetOffset(BitFilePosition pos)Sets the bit file position within this object to that represented by the specified bit file position.static intsizeInBytes()How large is this object when serializedvoidtoBytes(java.io.DataOutput dai)Seralize this object to the named dataoutput instancejava.lang.StringtoString()String representation of this object
 
- 
- 
- 
Field Detail- 
sizeInBytesprotected 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
 
 - 
Bytespublic long Bytes The offset within a file in bytes.
 - 
Bitspublic byte Bits The offset in bits within the pointed byte.
 
- 
 - 
Constructor Detail- 
FilePositionpublic FilePosition() Default constructor. Create an uninitialiased FilePosition
 - 
FilePositionpublic 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.
 
 - 
FilePositionpublic FilePosition(byte[] in) Create an instance based on a byte buffer
 - 
FilePositionpublic FilePosition(BitFilePosition in) Create a new FilePosition based on an existing one
 
- 
 - 
Method Detail- 
getOffsetpublic long getOffset() Return the number of bytes offset.- Specified by:
- getOffsetin interface- BitFilePosition
- Returns:
- the number of bytes offset.
 
 - 
getOffsetBitspublic byte getOffsetBits() Return the number of bits offset.- Specified by:
- getOffsetBitsin interface- BitFilePosition
- Returns:
- the number of bits offset.
 
 - 
setOffsetpublic void setOffset(long bytes, byte bits)Set the offset in number of bytes and number of bits.- Specified by:
- setOffsetin interface- BitFilePosition
- Parameters:
- bytes- the number of bytes to set.
- bits- the number of bits to set.
 
 - 
setOffsetpublic void setOffset(BitFilePosition pos) Sets the bit file position within this object to that represented by the specified bit file position.- Specified by:
- setOffsetin interface- BitFilePosition
- Parameters:
- pos- other bit file position to update the bit file position in this object.
 
 - 
sizeInBytespublic static int sizeInBytes() How large is this object when serialized
 - 
toBytespublic void toBytes(java.io.DataOutput dai) Seralize this object to the named dataoutput instance
 - 
buildpublic void build(java.io.DataInput di) unseralize this object from the named dataoutput instance
 - 
equalspublic boolean equals(java.lang.Object o) Is this FilePosition equal to another?- Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() Define a hashcode for this - objects which defined equals(Object) should define hashCode() also- Overrides:
- hashCodein class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() String representation of this object- Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-