com.jguild.jrpm.io
Class RPMFile

java.lang.Object
  extended bycom.jguild.jrpm.io.RPMFile

public class RPMFile
extends java.lang.Object

This class allows IO access to an RPM file.

Version:
$Id: RPMFile.java,v 1.22 2004/05/06 20:59:22 mkuss Exp $

Constructor Summary
RPMFile()
          Creates a new empty RPMFile object.
RPMFile(java.io.File fh)
          Creates a new RPMFile object out of a file.
 
Method Summary
 void close()
          Release locked resources.
 RPMHeader getHeader()
          Get the header section of this rpm file.
static java.lang.String[] getKnownTagNames()
          Get all known tags of this rpm file.
 RPMLead getLead()
          Get the lead section of this rpm file
 java.lang.String[] getLocales()
          Return all known locales that are supported by this RPM file.
 RPMSignature getSignature()
          Get the signature section of this rpm file
 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
 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.
 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.
 void parse()
          Parse the RPMFile and will extract all informations.
 void setFile(java.io.File fh)
          Set the file this RPMFile should represent
 void setLocale(int pos)
          Set the locale as int for all I18N strings that are returned by getTag().
 void setLocale(java.lang.String locale)
          Set the locale as string for all I18N strings that are returned by getTag().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RPMFile

public RPMFile()
Creates a new empty RPMFile object.


RPMFile

public RPMFile(java.io.File fh)
Creates a new RPMFile object out of a file.

Parameters:
fh - The file object representing a rpm file
Method Detail

setFile

public void setFile(java.io.File fh)
Set the file this RPMFile should represent

Parameters:
fh - The file object representing a rpm file

parse

public void parse()
           throws java.io.IOException
Parse the RPMFile and will extract all informations. This must be called before any informations can be read from the rpm file.

Throws:
java.io.IOException - If an error occurs during read of the rpm file

getHeader

public RPMHeader getHeader()
Get the header section of this rpm file.

Returns:
The rpm header

getKnownTagNames

public static java.lang.String[] getKnownTagNames()
Get all known tags of this rpm file. This is equivalent to the --querytags option in rpm.

Returns:
An array of all tag names

getLead

public RPMLead getLead()
Get the lead section of this rpm file

Returns:
The rpm lead

setLocale

public void setLocale(int pos)
Set the locale as int for all I18N strings that are returned by getTag(). The position has to correspond with the same position in the array returned by getLocales().

Parameters:
pos - The position in the array returned by getLocales().

setLocale

public void setLocale(java.lang.String locale)
Set the locale as string for all I18N strings that are returned by getTag(). The string must match with a string returned by getLocales().

Parameters:
locale - A locale matching a locale returned by getLocales()
Throws:
java.lang.IllegalArgumentException - If the locale is not defined by getLocales().

getLocales

public java.lang.String[] getLocales()
Return all known locales that are supported by this RPM file. The array is read out of the RPM file with the tag "HEADERI18NTABLE". The RPM has one entry for all I18N strings defined by this tag.

Returns:
A string array of all defined locales

getSignature

public RPMSignature getSignature()
Get the signature section of this rpm file

Returns:
The rpm signature

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

getTagIdForName

public long getTagIdForName(java.lang.String tagname)
Read a tag with a given tag name.

Parameters:
tagname - A RPM tag name
Returns:
The id of the RPM tag
Throws:
java.lang.IllegalArgumentException - if the tag name was not found
See Also:
Header.getTagIdForName(String)

getTagIds

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

Returns:
All tag ids contained in this rpm file.

getTagNameForId

public java.lang.String getTagNameForId(long tagid)
Read a tag with a given tag id.

Parameters:
tagid - A RPM tag id
Returns:
The name of the RPM tag
Throws:
java.lang.IllegalArgumentException - if the tag id was not found
See Also:
Header.getTagNameForId(long)

getTagNames

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

Returns:
All tag names contained in this rpm file.

close

public void close()
Release locked resources.



Copyright © 2002-2005 Sourceforge. All Rights Reserved.