com.jguild.jrpm.io
Class Header

java.lang.Object
  extended bycom.jguild.jrpm.io.Header
Direct Known Subclasses:
RPMHeader, RPMSignature

public abstract class Header
extends java.lang.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  long size
          The size in bytes of this structure
 
Constructor Summary
Header(java.io.DataInputStream inputStream)
          Construct a header structure for the given input stream.
Header(java.io.DataInputStream inputStream, boolean rawHeader)
          Create a header structure from an input stream.
 
Method Summary
static java.lang.String[] getKnownTagNames()
          Read all known tag names for this header structure.
 long getSize()
          Get the size in bytes of this structure
 DataTypeIf getTag(long tag)
          Get a tag by id as a long
 DataTypeIf getTag(java.lang.Long tag)
          Get a tag by id as a Long
 DataTypeIf getTag(java.lang.String tagname)
          Get a tag by name
abstract  long getTagIdForName(java.lang.String tagname)
          Read a tag with a given tag name.
 long[] getTagIds()
          Get all tag ids contained in this rpm file.
abstract  java.lang.String getTagNameForId(long tagid)
          Read a tag with a given tag id.
 java.lang.String[] getTagNames()
          Get all tag names contained in this rpm file.
abstract  boolean isValidTag(long tagid)
          Test if the given tagid is associated with a valid tag
abstract  boolean isValidTag(java.lang.String tagname)
          Test if the given tagname is associated with a valid tag
 void setTag(long tag, DataTypeIf data)
          Set a tag by id as a long
 void setTag(java.lang.Long tag, DataTypeIf data)
          Set a tag by id as a Long
 void setTag(java.lang.String tagname, DataTypeIf data)
          Set a tag by id as a string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

size

protected long size
The size in bytes of this structure

Constructor Detail

Header

public Header(java.io.DataInputStream inputStream,
              boolean rawHeader)
       throws java.io.IOException
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:
java.io.IOException - if an error occurs on reading informations out of the stream

Header

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

Parameters:
inputStream -
Throws:
java.io.IOException
Method Detail

getKnownTagNames

public static java.lang.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(java.lang.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(java.lang.String tagname)
Get a tag by name

Parameters:
tagname - A tag name
Returns:
A data struct containing the data of this tag

setTag

public void setTag(java.lang.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(java.lang.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

getTagIds

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

Returns:
All tag ids contained in this rpm file.

getTagNames

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

Returns:
All tag names contained in this rpm file.

getTagIdForName

public abstract long getTagIdForName(java.lang.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:
java.lang.IllegalArgumentException - if the tag name was not found

getTagNameForId

public abstract java.lang.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:
java.lang.IllegalArgumentException - if the tag id was not found

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(java.lang.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


Copyright © 2002-2005 Sourceforge. All Rights Reserved.