uk.org.retep.util.io.tar
Class TarHeader

java.lang.Object
  extended by uk.org.retep.util.io.tar.TarHeader
Direct Known Subclasses:
GnuHeader.DumpDir, GnuHeader.MultiVolume, GnuHeader.SparseFile, StandardHeader.EndOfArchive, TarHeader.NamedHeader

public abstract class TarHeader
extends java.lang.Object

Base class for all TarHeader's

Author:
peter

Nested Class Summary
static class TarHeader.FileHeader
          Base class for file entries
static class TarHeader.NamedHeader
          Base class of all TarHeader's that use the name field.
 
Field Summary
static int BLOCK_SIZE
          The size of a TarHeader block
protected  java.lang.String chksum
           
static int CHKSUM_SIZE
           
protected  int devmajor
           
static int DEVMAJOR_SIZE
           
protected  int devminor
           
static int DEVMINOR_SIZE
           
protected  int gid
           
static int GID_SIZE
           
protected  java.lang.String gname
           
static int GNAME_SIZE
           
protected  java.lang.String linkname
           
static int LINKNAME_SIZE
           
protected  int mode
           
static int MODE_SIZE
           
protected  long mtime
           
static int MTIME_SIZE
           
protected  java.lang.String name
           
static int NAME_SIZE
           
protected  java.lang.String prefix
           
static int PREFIX_SIZE
           
protected  TarHeader prevHeader
          The TarHeader to write prior to this one
protected  long size
           
static int SIZE_SIZE
           
protected  TarHeader succHeader
          The TarHeader to write after this one
protected  int uid
           
static int UID_SIZE
           
protected  java.lang.String uname
           
static int UNAME_SIZE
           
protected  java.lang.String version
           
 
Constructor Summary
TarHeader()
           
 
Method Summary
 java.nio.ByteBuffer allocateTarHeader()
          Allocate a ByteBuffer capable of containing this header
protected
<T extends TarHeader.FileHeader>
T
chain()
           
protected  void checksum(java.nio.ByteBuffer buffer, int start, int end, int cpos)
          Add the checksum
 void get(java.nio.ByteBuffer buffer)
           
protected  int getAdditionalSize()
          Subclasses must implement this if they override the putAdditional(java.nio.ByteBuffer) method.
static int getBlockSize(int size)
          Returns the size padded out to fit a block
 TarHeader getPrevHeader()
           
 TarHeader getSuccHeader()
           
 int getTarHeaderSize()
          The size this TarHeader requires.
abstract  TarHeaderType getTarHeaderType()
          The TarHeaderType of this instance
 void put(java.nio.ByteBuffer buffer)
          Write the header to the ByteBuffer
protected  void putAdditional(java.nio.ByteBuffer buffer)
          Subclasses can use this to write additional data after the header
 void setPrevHeader(TarHeader prevHeader)
           
 void setSuccHeader(TarHeader succHeader)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCK_SIZE

public static final int BLOCK_SIZE
The size of a TarHeader block

See Also:
Constant Field Values

NAME_SIZE

public static final int NAME_SIZE
See Also:
Constant Field Values

MODE_SIZE

public static final int MODE_SIZE
See Also:
Constant Field Values

UID_SIZE

public static final int UID_SIZE
See Also:
Constant Field Values

GID_SIZE

public static final int GID_SIZE
See Also:
Constant Field Values

SIZE_SIZE

public static final int SIZE_SIZE
See Also:
Constant Field Values

MTIME_SIZE

public static final int MTIME_SIZE
See Also:
Constant Field Values

CHKSUM_SIZE

public static final int CHKSUM_SIZE
See Also:
Constant Field Values

LINKNAME_SIZE

public static final int LINKNAME_SIZE
See Also:
Constant Field Values

UNAME_SIZE

public static final int UNAME_SIZE
See Also:
Constant Field Values

GNAME_SIZE

public static final int GNAME_SIZE
See Also:
Constant Field Values

DEVMAJOR_SIZE

public static final int DEVMAJOR_SIZE
See Also:
Constant Field Values

DEVMINOR_SIZE

public static final int DEVMINOR_SIZE
See Also:
Constant Field Values

PREFIX_SIZE

public static final int PREFIX_SIZE
See Also:
Constant Field Values

name

protected java.lang.String name

mode

protected int mode

uid

protected int uid

gid

protected int gid

size

protected long size

mtime

protected long mtime

chksum

protected java.lang.String chksum

version

protected java.lang.String version

linkname

protected java.lang.String linkname

uname

protected java.lang.String uname

gname

protected java.lang.String gname

devmajor

protected int devmajor

devminor

protected int devminor

prefix

protected java.lang.String prefix

prevHeader

protected TarHeader prevHeader
The TarHeader to write prior to this one


succHeader

protected TarHeader succHeader
The TarHeader to write after this one

Constructor Detail

TarHeader

public TarHeader()
Method Detail

getTarHeaderType

public abstract TarHeaderType getTarHeaderType()
The TarHeaderType of this instance

Returns:
TarHeaderType of this instance

get

public void get(java.nio.ByteBuffer buffer)

put

public void put(java.nio.ByteBuffer buffer)
Write the header to the ByteBuffer

Parameters:
buffer - ByteBuffer to write to

checksum

protected final void checksum(java.nio.ByteBuffer buffer,
                              int start,
                              int end,
                              int cpos)
Add the checksum

Parameters:
buffer - ByteBuffer
start - initial position
end - end position (exclusive)
cpos - position to write the checksum

getPrevHeader

public final TarHeader getPrevHeader()

setPrevHeader

public final void setPrevHeader(TarHeader prevHeader)

getSuccHeader

public final TarHeader getSuccHeader()

setSuccHeader

public final void setSuccHeader(TarHeader succHeader)

putAdditional

protected void putAdditional(java.nio.ByteBuffer buffer)
Subclasses can use this to write additional data after the header

Parameters:
buffer -

getAdditionalSize

protected int getAdditionalSize()
Subclasses must implement this if they override the putAdditional(java.nio.ByteBuffer) method. It must return the number of bytes that method would write.

Returns:
0 in the default implementation

getBlockSize

public static int getBlockSize(int size)
Returns the size padded out to fit a block

Parameters:
size -
Returns:

getTarHeaderSize

public int getTarHeaderSize()
The size this TarHeader requires. In most cases this is the standard BLOCK_SIZE. If this header has another header attached to it then it's size is also included.

Returns:

allocateTarHeader

public java.nio.ByteBuffer allocateTarHeader()
Allocate a ByteBuffer capable of containing this header

Returns:

chain

protected final <T extends TarHeader.FileHeader> T chain()


Copyright © 1998-2010 Retep Development Group. All Rights Reserved.