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.HashSet<java.lang.String> files
           
protected  java.util.TreeSet<CpioHeader> headers
           
protected  java.util.HashMap<CpioHeader,java.lang.Object> sources
           
 
Constructor Summary
Contents()
           
 
Method Summary
 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 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.
 java.lang.String[] getBaseNames()
           
 int[] getClasses()
           
 int[] getColors()
           
 java.lang.String[] getContexts()
           
 int[] getDependsN()
           
 int[] getDependsX()
           
 int[] getDevices()
           
 int[] getDirIndexes()
           
 java.lang.String[] getDirNames()
           
 int[] getFlags()
           
 java.lang.String[] getGroups()
           
 int[] getInodes()
           
 java.lang.String[] getLangs()
           
 java.lang.String[] getLinkTos()
           
 java.lang.String[] getMD5s()
          Caclulates an MD5 hash for each file in the archive.
 short[] getModes()
           
 int[] getMtimes()
           
 short[] getRdevs()
           
 int[] getSizes()
           
 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()
           
 int[] getVerifyFlags()
           
 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.TreeSet<CpioHeader> headers

files

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

sources

protected final java.util.HashMap<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,
                    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

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.


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()

getDirIndexes

public int[] getDirIndexes()

getBaseNames

public java.lang.String[] getBaseNames()

getSizes

public int[] getSizes()

getModes

public short[] getModes()

getRdevs

public short[] getRdevs()

getMtimes

public int[] getMtimes()

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()

getFlags

public int[] getFlags()

getUsers

public java.lang.String[] getUsers()

getGroups

public java.lang.String[] getGroups()

getColors

public int[] getColors()

getVerifyFlags

public int[] getVerifyFlags()

getClasses

public int[] getClasses()

getDevices

public int[] getDevices()

getInodes

public int[] getInodes()

getLangs

public java.lang.String[] getLangs()

getDependsX

public int[] getDependsX()

getDependsN

public int[] getDependsN()

getContexts

public java.lang.String[] getContexts()

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.