com.jguild.jrpm.io

Class Header

public abstract class Header extends Object

This class represents the abstract definition of a header structur. It can be either a signature or a header. The tags of such a structure can be accessed by either their tag id or by their tag name. Also all available and all read tag names in this structure can be accessed.

Version: $Id: Header.java,v 1.10 2004/09/09 09:52:33 pnasrat Exp $

Author: kuss

Field Summary
protected longsize
The size in bytes of this structure.
Constructor Summary
Header(DataInputStream inputStream, boolean rawHeader)
Create a header structure from an input stream.
Header(DataInputStream inputStream)
Construct a header structure for the given input stream.
Method Summary
static String[]getKnownTagNames()
Read all known tag names for this header structure.
longgetSize()
Get the size in bytes of this structure
DataTypeIfgetTag(Long tag)
Get a tag by id as a Long
DataTypeIfgetTag(long tag)
Get a tag by id as a long
DataTypeIfgetTag(String tagname)
Get a tag by name
abstract longgetTagIdForName(String tagname)
Read a tag with a given tag name.
long[]getTagIds()
Get all tag ids contained in this rpm file.
abstract StringgetTagNameForId(long tagid)
Read a tag with a given tag id.
String[]getTagNames()
Get all tag names contained in this rpm file.
abstract booleanisValidTag(long tagid)
Test if the given tagid is associated with a valid tag
abstract booleanisValidTag(String tagname)
Test if the given tagname is associated with a valid tag
voidsetTag(Long tag, DataTypeIf data)
Set a tag by id as a Long
voidsetTag(long tag, DataTypeIf data)
Set a tag by id as a long
voidsetTag(String tagname, DataTypeIf data)
Set a tag by id as a string

Field Detail

size

protected long size
The size in bytes of this structure.

Constructor Detail

Header

public Header(DataInputStream inputStream, boolean rawHeader)
Create a header structure from an input stream.

The header structure of a signature or a header can be read and also the index entries containing the tags for this rpm section (signature or header).

Unless we have a raw header from headerUnload or the database, a header is read consisting of the following fields:

 byte magic[3];      (3  byte)  (8e ad e8)
 int version;        (1  byte)
 byte reserved[4];   (4  byte)
 long num_index;     (4  byte)
 long num_data;      (4  byte)
 

Afterwards the index entries are read and then the tags and the correspondig data entries are read.

Parameters: inputStream An inputstream containing rpm file informations rawHeader Are we a raw header (from headerUnload or rpmdb)

Throws: IOException if an error occurs on reading informations out of the stream

Header

public Header(DataInputStream inputStream)
Construct a header structure for the given input stream.

Parameters: inputStream

Throws: IOException

Method Detail

getKnownTagNames

public static String[] getKnownTagNames()
Read all known tag names for this header structure.

Returns: An array of tag names

getSize

public long getSize()
Get the size in bytes of this structure

Returns: The size in bytes.

getTag

public DataTypeIf getTag(Long tag)
Get a tag by id as a Long

Parameters: tag A tag id as a Long

Returns: A data struct containing the data of this tag

getTag

public DataTypeIf getTag(long tag)
Get a tag by id as a long

Parameters: tag A tag id as a long

Returns: A data struct containing the data of this tag

getTag

public DataTypeIf getTag(String tagname)
Get a tag by name

Parameters: tagname A tag name

Returns: A data struct containing the data of this tag

getTagIdForName

public abstract long getTagIdForName(String tagname)
Read a tag with a given tag name. The tag will be read out of the class defined in getTagEnum().

Parameters: tagname A RPM tag name

Returns: The id of the RPM tag

Throws: IllegalArgumentException if the tag name was not found

getTagIds

public long[] getTagIds()
Get all tag ids contained in this rpm file.

Returns: All tag ids contained in this rpm file.

getTagNameForId

public abstract String getTagNameForId(long tagid)
Read a tag with a given tag id. The tag will be read out of the class defined in getTagEnum().

Parameters: tagid A RPM tag id

Returns: The name of the RPM tag

Throws: IllegalArgumentException if the tag id was not found

getTagNames

public String[] getTagNames()
Get all tag names contained in this rpm file.

Returns: All tag names contained in this rpm file.

isValidTag

public abstract boolean isValidTag(long tagid)
Test if the given tagid is associated with a valid tag

Parameters: tagid The id of a tag

Returns: TRUE if the tagid is valid

isValidTag

public abstract boolean isValidTag(String tagname)
Test if the given tagname is associated with a valid tag

Parameters: tagname The name of a tag

Returns: TRUE if the tagname is valid

setTag

public void setTag(Long tag, DataTypeIf data)
Set a tag by id as a Long

Parameters: tag A tag id as a Long data A data struct containing the data of this tag

setTag

public void setTag(long tag, DataTypeIf data)
Set a tag by id as a long

Parameters: tag A tag id as a long data A data struct containing the data of this tag

setTag

public void setTag(String tagname, DataTypeIf data)
Set a tag by id as a string

Parameters: tagname A tag id as a string data A data struct containing the data of this tag