org.freecompany.redline.payload
Class Contents

java.lang.Object
  extended by org.freecompany.redline.payload.Contents

public class Contents
extends java.lang.Object

The contents of an RPM archive. These entries define the files and links that the RPM contains as well as headers those files require. Note that the RPM format requires that files in the archive be naturally ordered.


Field Summary
protected  java.util.Set<java.lang.String> files
           
protected  java.util.Set<CpioHeader> headers
           
protected  java.util.Map<CpioHeader,java.lang.Object> sources
           
 
Constructor Summary
Contents()
           
 
Method Summary
static void addBuiltinDirectory(java.lang.String directory)
          Add additional directory that is assumed to already exist on system where the RPM will be installed (e.g.
 void addDirectory(java.lang.String path)
          Adds a directory entry to the archive with the default permissions of 644.
 void addDirectory(java.lang.String path, Directive directive)
          Adds a directory entry to the archive with the default permissions of 644.
 void addDirectory(java.lang.String path, int permissions)
          Adds a directory entry to the archive with the specified permissions.
 void addDirectory(java.lang.String path, int permissions, Directive directive, java.lang.String uname, java.lang.String gname)
          Adds a directory entry to the archive with the specified permissions.
 void addDirectory(java.lang.String path, int permissions, Directive directive, java.lang.String uname, java.lang.String gname, boolean addParents)
          Adds a directory entry to the archive with the specified permissions.
 void addFile(java.lang.String path, java.io.File source)
          Adds a file entry to the archive with the default permissions of 644.
 void addFile(java.lang.String path, java.io.File source, int permissions)
          Adds a file entry to the archive with the specified permissions.
 void addFile(java.lang.String path, java.io.File source, int permissions, Directive directive)
          Adds a file entry to the archive with the specified permissions.
 void addFile(java.lang.String path, java.io.File source, int permissions, Directive directive, java.lang.String uname, java.lang.String gname)
          Adds a file entry to the archive with the specified permissions.
 void addFile(java.lang.String path, java.io.File source, int permissions, Directive directive, java.lang.String uname, java.lang.String gname, int dirmode)
          Adds a file entry to the archive with the specified permissions.
 void addFile(java.lang.String path, java.io.File source, int permissions, int dirmode)
          Adds a file entry to the archive with the specified permissions.
 void addLink(java.lang.String path, java.lang.String target)
          Adds a directory entry to the archive with the default permissions of 644.
 void addLink(java.lang.String path, java.lang.String target, int permissions)
          Adds a directory entry to the archive with the specified permissions.
protected  void addParents(java.io.File file, int permissions, java.lang.String uname, java.lang.String gname)
          Adds entries for parent directories of this file, so that they may be cleaned up when removing the package.
 void addURL(java.lang.String path, java.net.URL source, int permissions, Directive directive, java.lang.String uname, java.lang.String gname, int dirmode)
          Adds a URL entry to the archive with the specified permissions.
 java.lang.String[] getBaseNames()
          Gets the basenames header values.
 int[] getClasses()
          Gets the classes header values.
 int[] getColors()
          Gets the colors header values.
 java.lang.String[] getContexts()
          Gets the contexts header values.
 int[] getDependsN()
          Gets the dependsn header values.
 int[] getDependsX()
          Gets the dependsx header values.
 int[] getDevices()
          Gets the devices header values.
 int[] getDirIndexes()
          Gets the dirindexes headers values.
 java.lang.String[] getDirNames()
          Gets the dirnames headers values.
 int[] getFlags()
          Gets the flags header values.
 java.lang.String[] getGroups()
          Gets the groups header values.
 int[] getInodes()
          Gets the inodes header values.
 java.lang.String[] getLangs()
          Gets the langs header values.
 java.lang.String[] getLinkTos()
          Gets the linktos header values.
 java.lang.String[] getMD5s()
          Caclulates an MD5 hash for each file in the archive.
 short[] getModes()
          Gets the modes header values.
 int[] getMtimes()
          Gets the mtimes header values.
 short[] getRdevs()
          Gets the rdevs header values.
 int[] getSizes()
          Gets the sizes header values.
 java.lang.Object getSource(CpioHeader header)
          Retrieves the content for this archive entry, which may be a File if the entry is a regular file or a CharSequence containing the name of the target path if the entry is a link.
 int getTotalSize()
          Accumulated size of all files included in the archive.
 java.lang.String[] getUsers()
          Gets the users header values.
 int[] getVerifyFlags()
          Gets the verifyflags header values.
 java.lang.Iterable<CpioHeader> headers()
          Retrieve the archive headers.
protected static void listParents(java.util.List<java.lang.String> parents, java.io.File file)
          Generates a list of parent paths given a starting path.
 int size()
          Retrieve the size of this archive in number of files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

headers

protected final java.util.Set<CpioHeader> headers

files

protected final java.util.Set<java.lang.String> files

sources

protected final java.util.Map<CpioHeader,java.lang.Object> sources
Constructor Detail

Contents

public Contents()
Method Detail

addLink

public void addLink(java.lang.String path,
                    java.lang.String target)
Adds a directory entry to the archive with the default permissions of 644.

Parameters:
path - the destination path for the installed file.

addLink

public void addLink(java.lang.String path,
                    java.lang.String target,
                    int permissions)
Adds a directory entry to the archive with the specified permissions.

Parameters:
path - the destination path for the installed file.
permissions - the permissions flags.

addDirectory

public void addDirectory(java.lang.String path)
Adds a directory entry to the archive with the default permissions of 644.

Parameters:
path - the destination path for the installed file.

addDirectory

public void addDirectory(java.lang.String path,
                         Directive directive)
Adds a directory entry to the archive with the default permissions of 644.

Parameters:
path - the destination path for the installed file.
directive - directive indicating special handling for this directory.

addDirectory

public void addDirectory(java.lang.String path,
                         int permissions)
Adds a directory entry to the archive with the specified permissions.

Parameters:
path - the destination path for the installed file.
permissions - the permissions flags.

addDirectory

public void addDirectory(java.lang.String path,
                         int permissions,
                         Directive directive,
                         java.lang.String uname,
                         java.lang.String gname)
Adds a directory entry to the archive with the specified permissions.

Parameters:
path - the destination path for the installed file.
permissions - the permissions flags.
directive - directive indicating special handling for this directory.
uname - user owner for the given file
gname - group owner for the given file

addDirectory

public void addDirectory(java.lang.String path,
                         int permissions,
                         Directive directive,
                         java.lang.String uname,
                         java.lang.String gname,
                         boolean addParents)
Adds a directory entry to the archive with the specified permissions.

Parameters:
path - the destination path for the installed file.
permissions - the permissions flags.
directive - directive indicating special handling for this directory.
uname - user owner for the given file
gname - group owner for the given file
addParents - whether to add parent directories to the rpm

addFile

public void addFile(java.lang.String path,
                    java.io.File source)
             throws java.io.FileNotFoundException
Adds a file entry to the archive with the default permissions of 644.

Parameters:
path - the destination path for the installed file.
source - the local file to be included in the package.
Throws:
java.io.FileNotFoundException

addFile

public void addFile(java.lang.String path,
                    java.io.File source,
                    int permissions)
             throws java.io.FileNotFoundException
Adds a file entry to the archive with the specified permissions.

Parameters:
path - the destination path for the installed file.
source - the local file to be included in the package.
permissions - the permissions flags.
Throws:
java.io.FileNotFoundException

addFile

public void addFile(java.lang.String path,
                    java.io.File source,
                    int permissions,
                    int dirmode)
             throws java.io.FileNotFoundException
Adds a file entry to the archive with the specified permissions.

Parameters:
path - the destination path for the installed file.
source - the local file to be included in the package.
permissions - the permissions flags.
Throws:
java.io.FileNotFoundException

addFile

public void addFile(java.lang.String path,
                    java.io.File source,
                    int permissions,
                    Directive directive)
             throws java.io.FileNotFoundException
Adds a file entry to the archive with the specified permissions.

Parameters:
path - the destination path for the installed file.
source - the local file to be included in the package.
permissions - the permissions flags.
directive - directive indicating special handling for this file.
Throws:
java.io.FileNotFoundException

addFile

public void addFile(java.lang.String path,
                    java.io.File source,
                    int permissions,
                    Directive directive,
                    java.lang.String uname,
                    java.lang.String gname)
             throws java.io.FileNotFoundException
Adds a file entry to the archive with the specified permissions.

Parameters:
path - the destination path for the installed file.
source - the local file to be included in the package.
permissions - the permissions flags.
directive - directive indicating special handling for this file.
uname - user owner for the given file
gname - group owner for the given file
Throws:
java.io.FileNotFoundException

addFile

public void addFile(java.lang.String path,
                    java.io.File source,
                    int permissions,
                    Directive directive,
                    java.lang.String uname,
                    java.lang.String gname,
                    int dirmode)
             throws java.io.FileNotFoundException
Adds a file entry to the archive with the specified permissions.

Parameters:
path - the destination path for the installed file.
source - the local file to be included in the package.
permissions - the permissions flags.
directive - directive indicating special handling for this file.
uname - user owner for the given file
gname - group owner for the given file
Throws:
java.io.FileNotFoundException

addURL

public void addURL(java.lang.String path,
                   java.net.URL source,
                   int permissions,
                   Directive directive,
                   java.lang.String uname,
                   java.lang.String gname,
                   int dirmode)
            throws java.io.FileNotFoundException
Adds a URL entry to the archive with the specified permissions.

Parameters:
path - the destination path for the installed file.
source - the URL with the data to be added
permissions - the permissions flags.
directive - directive indicating special handling for this file.
uname - user owner for the given file
gname - group owner for the given file
Throws:
java.io.FileNotFoundException

addParents

protected void addParents(java.io.File file,
                          int permissions,
                          java.lang.String uname,
                          java.lang.String gname)
Adds entries for parent directories of this file, so that they may be cleaned up when removing the package.


addBuiltinDirectory

public static void addBuiltinDirectory(java.lang.String directory)
Add additional directory that is assumed to already exist on system where the RPM will be installed (e.g. /etc) and should not have an entry in the RPM.

Parameters:
directory -

size

public int size()
Retrieve the size of this archive in number of files. This count includes both directory entries and soft links.


headers

public java.lang.Iterable<CpioHeader> headers()
Retrieve the archive headers. The returned Iterable will iterate in the correct order for the final archive.


getSource

public java.lang.Object getSource(CpioHeader header)
Retrieves the content for this archive entry, which may be a File if the entry is a regular file or a CharSequence containing the name of the target path if the entry is a link. This is the value to be written to the archive as the body of the entry.


getTotalSize

public int getTotalSize()
Accumulated size of all files included in the archive.


getDirNames

public java.lang.String[] getDirNames()
Gets the dirnames headers values.


getDirIndexes

public int[] getDirIndexes()
Gets the dirindexes headers values.


getBaseNames

public java.lang.String[] getBaseNames()
Gets the basenames header values.


getSizes

public int[] getSizes()
Gets the sizes header values.


getModes

public short[] getModes()
Gets the modes header values.


getRdevs

public short[] getRdevs()
Gets the rdevs header values.


getMtimes

public int[] getMtimes()
Gets the mtimes header values.


getMD5s

public java.lang.String[] getMD5s()
                           throws java.io.FileNotFoundException,
                                  java.security.NoSuchAlgorithmException,
                                  java.io.IOException
Caclulates an MD5 hash for each file in the archive.

Throws:
java.io.FileNotFoundException
java.security.NoSuchAlgorithmException
java.io.IOException

getLinkTos

public java.lang.String[] getLinkTos()
Gets the linktos header values.


getFlags

public int[] getFlags()
Gets the flags header values.


getUsers

public java.lang.String[] getUsers()
Gets the users header values.


getGroups

public java.lang.String[] getGroups()
Gets the groups header values.


getColors

public int[] getColors()
Gets the colors header values.


getVerifyFlags

public int[] getVerifyFlags()
Gets the verifyflags header values.


getClasses

public int[] getClasses()
Gets the classes header values.


getDevices

public int[] getDevices()
Gets the devices header values.


getInodes

public int[] getInodes()
Gets the inodes header values.


getLangs

public java.lang.String[] getLangs()
Gets the langs header values.


getDependsX

public int[] getDependsX()
Gets the dependsx header values.


getDependsN

public int[] getDependsN()
Gets the dependsn header values.


getContexts

public java.lang.String[] getContexts()
Gets the contexts header values.


listParents

protected static void listParents(java.util.List<java.lang.String> parents,
                                  java.io.File file)
Generates a list of parent paths given a starting path.



Copyright © 2011. All Rights Reserved.