net.sf.rej.gui.hexeditor
Class DataRow

java.lang.Object
  extended by net.sf.rej.gui.hexeditor.DataRow

public class DataRow
extends java.lang.Object

Stores the data of the hex editor. Each object of this class is a row in a JList and the custom renderer renders the data contained in these objects. Each row shares the DataProvider object.

Author:
Sami Koivu

Constructor Summary
DataRow(DataProvider data, int offset)
          Initializes this object with the given data and an offset from which to start reading the data.
 
Method Summary
 int getAbsolute(int index)
          Returns the absolute position of the given index of this row.
 char getAsciiData(int index)
          Returns the byte in the given index as a char value.
 java.lang.String getHexData(int index)
          Returns a 2 digit hexadecimal value of the byte in the given index of this row.
 java.lang.String getOffsetString()
          Returns a 6 digit hexadecimal number indicating the beginning offset of this row.
 boolean isDataAvailable(int index)
          Checks availability of data in the given index.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataRow

public DataRow(DataProvider data,
               int offset)
Initializes this object with the given data and an offset from which to start reading the data.

Parameters:
data - the data contained in this row.
offset - the offset from which to read the data.
Method Detail

isDataAvailable

public boolean isDataAvailable(int index)
Checks availability of data in the given index.

Parameters:
index - an index between 0 and row-width inclusive.
Returns:
whether or not that data is available. false indicates that the index is after the end of the data.

getOffsetString

public java.lang.String getOffsetString()
Returns a 6 digit hexadecimal number indicating the beginning offset of this row.

Returns:
hexadecimal offset String.

getHexData

public java.lang.String getHexData(int index)
Returns a 2 digit hexadecimal value of the byte in the given index of this row.

Parameters:
index - the index of the byte queried.
Returns:
a hexadecimal value String, such as "ca".

getAsciiData

public char getAsciiData(int index)
Returns the byte in the given index as a char value. The following operations are performed on the char. If it's ascii value is lower than 0x20 (space character) it is replaced by a dot. If it's value is higher than 0xe0 it is replaced by a dot.

Parameters:
index - the inded of the queried ascii character.
Returns:
a char of the byte in the given position.

getAbsolute

public int getAbsolute(int index)
Returns the absolute position of the given index of this row.

Parameters:
index - an index into this row.
Returns:
the absolute offset value. For example, of this DataRow was initialized with the offset of 200 and the the absolute offset of the index 7 is queried, 207 will be returned.