dict.common
Class DictEntryRef

java.lang.Object
  extended by dict.common.DictEntryRef

public class DictEntryRef
extends java.lang.Object

Reference to a dictionary entry in the dictionary file. Contains a start position and the length of the whole dictionary entry in a file. For example for a file obtained from dict.cc it is the position of the begin of the line in the file and the length of the line in bytes.


Field Summary
private  int m_beg
          The position of the begin of the entry.
private  short m_fileno
          Index number of the dictionary file for which this entry reference is designated.
private  short m_len
          The length of the entry in bytes.
 
Constructor Summary
DictEntryRef(long from, long to, int fileno)
          Initializes the entry for the given positions.
 
Method Summary
 int getBeg()
          The position of the begin of the entry.
 short getFileNo()
          Returns the index number of the dictionary file.
 int getLen()
          The length of the entry in bytes.
 java.lang.String readRelative(java.io.InputStream aStream, int aType, DictEntryRef aPrev)
          Reads entry from the given stream at the position relative to the previous dict entry ref.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_beg

private int m_beg
The position of the begin of the entry. We use int in order to spare memory. Files having length exceeding the maximal value of int won't surely fit into small Java ME driven devices.


m_len

private short m_len
The length of the entry in bytes. We use short in orer to spare memory. Entries having lengths near to or exceeding the limits of short won't anyway fit into small Java ME driven devices.


m_fileno

private short m_fileno
Index number of the dictionary file for which this entry reference is designated.

Constructor Detail

DictEntryRef

public DictEntryRef(long from,
                    long to,
                    int fileno)
Initializes the entry for the given positions.

Parameters:
from - position of the begin of the entry in the dictionary file.
to - position of the end of the entry in the dictionary file.
fileno - index of the dictionary file
Method Detail

getBeg

public final int getBeg()
The position of the begin of the entry.

Returns:
m_beg

getLen

public final int getLen()
The length of the entry in bytes.

Returns:
m_len

getFileNo

public final short getFileNo()
Returns the index number of the dictionary file.


readRelative

public final java.lang.String readRelative(java.io.InputStream aStream,
                                           int aType,
                                           DictEntryRef aPrev)
Reads entry from the given stream at the position relative to the previous dict entry ref. For example, if the position (getBeg()) of the previous dict entry ref. is 100, the length of the previous entry was 20, and the position of this entry is 200, the the stream will be scrolled by 80 and the reading starts there. If the previous entry is null, then the reading starts at getBeg(), as usual.

Parameters:
aStream - the stream to read entries from
aType - the type of the entry, needed in order to use the correct character encoding for the dictionary file.
aPrev - the previous dictionary entry, may be also null.
Returns:
the whole entry from the dictionary resource according to the start position and length stored in this object. An empty string, if the read process fails.