uk.me.parabola.imgfmt.app
Class CommonHeader

java.lang.Object
  extended by uk.me.parabola.imgfmt.app.CommonHeader
Direct Known Subclasses:
LBLHeader, MDRHeader, NETHeader, NODHeader, RGNHeader, SRTHeader, TREHeader, TYPHeader

public abstract class CommonHeader
extends java.lang.Object

The header that is common to all application files within the .img file. It basically contains two things of interest, the size of the header and its type. The type is usually of the form 'GARMIN.YYY' where YYY is the file extension of the type eg TRE, LBL, RGN etc.

Author:
Steve Ratcliffe

Field Summary
protected static int COMMON_HEADER_LEN
           
 
Constructor Summary
protected CommonHeader(int headerLength, java.lang.String type)
           
 
Method Summary
 int getHeaderLength()
           
protected abstract  void readFileHeader(ImgFileReader reader)
          Read the rest of the header.
 void readHeader(ImgFileReader reader)
          Read the common header.
protected abstract  void writeFileHeader(ImgFileWriter writer)
          Write the rest of the header.
 void writeHeader(ImgFileWriter writer)
          Writes out the header that is common to all the file types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMON_HEADER_LEN

protected static final int COMMON_HEADER_LEN
See Also:
Constant Field Values
Constructor Detail

CommonHeader

protected CommonHeader(int headerLength,
                       java.lang.String type)
Method Detail

writeHeader

public final void writeHeader(ImgFileWriter writer)
Writes out the header that is common to all the file types. It should be called by the sync() methods of subclasses when they are ready.

Parameters:
writer - Used to write the header.

readHeader

public final void readHeader(ImgFileReader reader)
                      throws ReadFailedException
Read the common header. It starts at the beginning of the file.

Parameters:
reader - Used to read the header.
Throws:
ReadFailedException

readFileHeader

protected abstract void readFileHeader(ImgFileReader reader)
                                throws ReadFailedException
Read the rest of the header. Specific to the given file. It is guaranteed that the file position will be set to the correct place before this is called.

Parameters:
reader - The header is read from here.
Throws:
ReadFailedException

writeFileHeader

protected abstract void writeFileHeader(ImgFileWriter writer)
Write the rest of the header. It is guaranteed that the writer will be set to the correct position before calling.

Parameters:
writer - The header is written here.

getHeaderLength

public int getHeaderLength()