com.jguild.jrpm.io

Class RPMFile

public class RPMFile extends Object

This class allows IO access to an RPM file.

UNKNOWN: Implement equals()

Field Summary
static Loggerlogger
Constructor Summary
RPMFile()
Creates a new empty RPMFile object.
RPMFile(File fh)
Creates a new RPMFile object out of a file.
Method Summary
voidclose()
Release locked resources.
RPMHeadergetHeader()
Get the header section of this rpm file.
static String[]getKnownTagNames()
Get all known tags of this rpm file.
RPMLeadgetLead()
Get the lead section of this rpm file
String[]getLocales()
Return all known locales that are supported by this RPM file.
RPMSignaturegetSignature()
Get the signature section of this rpm file
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
longgetTagIdForName(String tagname)
Read a tag with a given tag name.
long[]getTagIds()
Get all tag ids contained in this rpm file.
StringgetTagNameForId(long tagid)
Read a tag with a given tag id.
String[]getTagNames()
Get all tag names contained in this rpm file.
static RPMFileloadUsingNative(File file)
Load an RPM file using the native rpm executables.
voidparse()
Parse the RPMFile and will extract all informations.
voidsetFile(File fh)
Set the file this RPMFile should represent
voidsetLocale(int pos)
Set the locale as int for all I18N strings that are returned by getTag().
voidsetLocale(String locale)
Set the locale as string for all I18N strings that are returned by getTag().
StringtoXML()
Same as doing toXML(true).
StringtoXML(boolean excludePayload)
Returns an XML version of this file
voidtoXML(Writer writer, boolean excludePayload)
Outputs this rpm in an XML format to the specified i/o writer.

Field Detail

logger

public static final Logger logger

Constructor Detail

RPMFile

public RPMFile()
Creates a new empty RPMFile object.

RPMFile

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

Parameters: fh The file object representing a rpm file

Method Detail

close

public void close()
Release locked resources.

getHeader

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

Returns: The rpm header

getKnownTagNames

public static 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

getLocales

public 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(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 long getTagIdForName(String tagname)
Read a tag with a given tag name.

Parameters: tagname A RPM tag name

Returns: The id of the RPM tag

Throws: IllegalArgumentException if the tag name was not found

See Also: getTagIdForName

getTagIds

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

Returns: All tag ids contained in this rpm file.

getTagNameForId

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

See Also: Header

getTagNames

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

Returns: All tag names contained in this rpm file.

loadUsingNative

public static RPMFile loadUsingNative(File file)
Load an RPM file using the native rpm executables.

Parameters: file RPM file.

parse

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

Throws: IOException If an error occurs during read of the rpm file

setFile

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

Parameters: fh The file object representing a rpm file

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(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: IllegalArgumentException If the locale is not defined by getLocales().

toXML

public String toXML()
Same as doing toXML(true).

Returns: String containing the XML representation of this RPM.

See Also: RPMFile

toXML

public String toXML(boolean excludePayload)
Returns an XML version of this file

Parameters: excludePayload If this is true, the payload will not be included in the XML.

Returns: XML rpm.

toXML

public void toXML(Writer writer, boolean excludePayload)
Outputs this rpm in an XML format to the specified i/o writer.

Parameters: writer Writer stream. excludePayload If this is true, the payload will not be included in the XML.

Throws: IOException If an error occurred writing to the writer.