|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.at4j.tar.TarFile
public class TarFile
A TarFile is an Archive containing TarEntry:s loaded
from a file. Tar entries may be files, directories or symbolic links. They
contain metadata about the file system entity that was used to create the tar
entry such as its time of last modification and its owner user and group
id:s.
The Tar file format is fairly simple, but it has evolved through a few versions since it was first defined. The following formats are supported by this object:
TarEntry objects.UstarEntry objects.UstarEntry objects.PaxEntry
objects.
The entries in a Tar archive are positioned in a directory hierarchy. Parent
directories of entries may be absent. In that case they are represented by
TarDirectoryEntry objects using default directory settings.
If the file used to create this object is in a locking
FileSystem, it is locked for reading by this object
until it is close():d.
A TarFile object should be safe to use concurrently from several
parallel threads without any external synchronization.
Note on character encodings: By default, metadata about Tar entries is encoded using the default character encoding of the platform where the tar file is created. This makes it necessary for those reading Tar files to know which character encoding that was used when the archive was created. This is often, but not always, Codepage 437 on Windows or UTF-8 on Unix. The only exception to this rule is the Pax variables that are always encoded using UTF-8. If Tar entries in a Pax compatible archive contains non-ASCII characters, the Tar entry path is (often) stored in the Pax header, making the archive portable between different platforms.
The Tar file format is described well in the Gnu Tar manual.
This object has a main method that, when run, prints out the contents of a Tar file passed to it as an argument.
TarExtractor| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
TarFile(RandomlyAccessibleFile f)
Create a new Tar file archive object that reads data from the supplied file. |
|
TarFile(RandomlyAccessibleFile f,
Charset entryNameCharset)
Create a new Tar file archive object that reads data from the supplied file. |
|
| Method Summary | |
|---|---|
protected void |
assertNotClosed()
This method throws an IllegalStateException if this object has
been closed. |
void |
clear()
|
void |
close()
Close this Tar file. |
boolean |
containsKey(Object key)
Does the Tar archive contain the specified key (which should be an AbsoluteLocation object)? |
boolean |
containsValue(Object value)
Does the Tar archive contain the specified value (which should be some kind of TarEntry object)? |
Set<Map.Entry<AbsoluteLocation,TarEntry>> |
entrySet()
Get a read only set containing the entries in the Tar archive. |
protected void |
finalize()
|
TarEntry |
get(Object key)
Get the TarEntry stored at the specified absolute location in the
Tar file. |
TarDirectoryEntry |
getRootEntry()
Get the root directory entry for the Tar file. |
boolean |
isEmpty()
This method always returns false since a Tar archive always has
its root directory entry. |
Set<AbsoluteLocation> |
keySet()
Get a read only set containing all the AbsoluteLocation:s where
Tar entries are stored in the Tar file. |
static void |
main(String[] args)
|
TarEntry |
put(AbsoluteLocation key,
TarEntry value)
|
void |
putAll(Map<? extends AbsoluteLocation,? extends TarEntry> m)
|
TarEntry |
remove(Object key)
|
int |
size()
Get the number of Tar entries in the archive. |
Collection<TarEntry> |
values()
Get a read only collection containing all TarEntry objects in the
Tar file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public TarFile(RandomlyAccessibleFile f)
If the file is in a locking FileSystem, it is locked
for reading by this method. The read lock is released when this object is
close():d. If this method returns with an error, the file is not
locked.
f - The Tar file.TarFile(RandomlyAccessibleFile, Charset)
public TarFile(RandomlyAccessibleFile f,
Charset entryNameCharset)
If the file is in a locking FileSystem, it is locked
for reading by this method. The read lock is released when this object is
close():d. If this method returns with an error, the file is not
locked.
f - The Tar file.entryNameCharset - The charset to use for interpreting text metadata
in the Tar file.TarFile(RandomlyAccessibleFile)| Method Detail |
|---|
protected void assertNotClosed()
throws IllegalStateException
IllegalStateException if this object has
been closed.
IllegalStateException - If this object has been closed.public TarDirectoryEntry getRootEntry()
/ in the Tar file.
This entry is never present in the Tar file itself, so the returned
object is always a TarDirectoryEntry (and not some subclass of
that object).
getRootEntry in interface Archive<TarEntry,TarDirectoryEntry>
public void clear()
throws UnsupportedOperationException
clear in interface Map<AbsoluteLocation,TarEntry>UnsupportedOperationException - Always.
public boolean containsKey(Object key)
throws IllegalStateException
AbsoluteLocation object)?
containsKey in interface Map<AbsoluteLocation,TarEntry>key - The key to search for.
true if the supplied key is present in the Tar file.
IllegalStateException - If the Tar file has been closed.
public boolean containsValue(Object value)
throws IllegalStateException
TarEntry object)?
containsValue in interface Map<AbsoluteLocation,TarEntry>value - The value to search for.
true if the Tar file contains the specified value.
IllegalStateException - If the Tar file has been closed.
public Set<Map.Entry<AbsoluteLocation,TarEntry>> entrySet()
throws IllegalStateException
entrySet in interface Map<AbsoluteLocation,TarEntry>IllegalStateException - If the Tar archive has been closed.
public TarEntry get(Object key)
throws IllegalStateException
TarEntry stored at the specified absolute location in the
Tar file.
get in interface Map<AbsoluteLocation,TarEntry>key - The AbsoluteLocation where the Tar entry is stored.
null if no Tar entry is stored at the
specified location.
IllegalStateException - If the Tar archive has been closed.
public boolean isEmpty()
throws IllegalStateException
false since a Tar archive always has
its root directory entry.
isEmpty in interface Map<AbsoluteLocation,TarEntry>false, always.
IllegalStateException - If the Tar archive has been closed.
public Set<AbsoluteLocation> keySet()
throws IllegalStateException
AbsoluteLocation:s where
Tar entries are stored in the Tar file.
keySet in interface Map<AbsoluteLocation,TarEntry>IllegalStateException - If the Tar archive has been closed.
public TarEntry put(AbsoluteLocation key,
TarEntry value)
throws UnsupportedOperationException
put in interface Map<AbsoluteLocation,TarEntry>UnsupportedOperationException - Always.
public void putAll(Map<? extends AbsoluteLocation,? extends TarEntry> m)
throws UnsupportedOperationException
putAll in interface Map<AbsoluteLocation,TarEntry>UnsupportedOperationException - Always.
public TarEntry remove(Object key)
throws UnsupportedOperationException
remove in interface Map<AbsoluteLocation,TarEntry>UnsupportedOperationException - Always.
public int size()
throws IllegalStateException
size in interface Map<AbsoluteLocation,TarEntry>IllegalStateException - If the Tar archive has been closed.
public Collection<TarEntry> values()
throws IllegalStateException
TarEntry objects in the
Tar file.
values in interface Map<AbsoluteLocation,TarEntry>IllegalStateException - If the Tar archive has been closed.public void close()
This method can safely be called several times.
close in interface Archive<TarEntry,TarDirectoryEntry>
protected void finalize()
throws Throwable
finalize in class ObjectThrowablepublic static void main(String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||