public class PaxTarEntryStrategy extends UstarEntryStrategy
UstarEntryStrategy
creates a special Pax
header before the regular ustar header. The Pax header contains metadata
variables. Pax variables are always encoded in UTF-8 in the Tar file, which
should make them (the only part of the Tar file that is) portable across
different platforms.
If the Tar entry path is too long to fit in the regular ustar header, the full path is set in the Pax header variable "path" and a truncated path is used in the ustar header.
If it is detected that the path name of the entry contains non-ASCII characters, the "path" variable is added even if the path name is short enough to fit in the ustar header.
By default, this strategy adds the "mtime" (last entity modification time)
and perhaps the "path" Pax variables to the headers that it creates. By
adding PaxVariableProvider
objects to the strategy, more variables
can be set.
Constructor and Description |
---|
PaxTarEntryStrategy()
Create a new strategy object that will use the platform's default
character encoding to encode text values in the Tar entries.
|
PaxTarEntryStrategy(Charset cs)
Create a new strategy object that will use the supplied charset for
encoding test values in the Tar entries.
|
Modifier and Type | Method and Description |
---|---|
PaxTarEntryStrategy |
addPaxVariableProvider(PaxVariableProvider p)
Add one Pax variable provider.
|
int |
getProcessId()
Get the process id.
|
PaxTarEntryStrategy |
setProcessId(int processId)
Set the process id of the current process (optional).
|
void |
writeDirectory(org.entityfs.DataSink out,
DirectoryAdapter<?> da,
org.entityfs.el.AbsoluteLocation location,
TarEntrySettings effectiveSettings,
Date lastModified)
Override the inherited implementation to add a Pax header before the
ustar header.
|
void |
writeFile(org.entityfs.DataSink out,
org.entityfs.ReadableFile f,
org.entityfs.el.AbsoluteLocation location,
TarEntrySettings effectiveSettings,
Date lastModified)
Override the inherited implementation to add a Pax header before the
ustar header.
|
void |
writeFileFromStream(org.entityfs.RandomAccess out,
InputStream is,
org.entityfs.el.AbsoluteLocation location,
TarEntrySettings effectiveSettings,
Date lastModified)
Override the inherited implementation to add a Pax header before the
ustar header.
|
getHeader, setFileNameInHeader
addChecksumToHeader, getFileName, getTextEncodingCharset, goToNextBlockBoundary, writeFileToArchive, zeroPadLeft
public PaxTarEntryStrategy()
PaxTarEntryStrategy(Charset)
public PaxTarEntryStrategy(Charset cs)
cs
- The charset.PaxTarEntryStrategy()
public PaxTarEntryStrategy setProcessId(int processId) throws IllegalArgumentException
1000
is used. (There are no good
platform-independent ways of discovering a Java process' process id.)processId
- The process id.this
IllegalArgumentException
- If the process id is zero or negative.public int getProcessId()
setProcessId(int)
public PaxTarEntryStrategy addPaxVariableProvider(PaxVariableProvider p)
p
- A Pax variable provider.this
public void writeFile(org.entityfs.DataSink out, org.entityfs.ReadableFile f, org.entityfs.el.AbsoluteLocation location, TarEntrySettings effectiveSettings, Date lastModified)
writeFile
in interface TarEntryStrategy
writeFile
in class V7TarEntryStrategy
out
- The DataSink
to write to. This may be a
RandomAccess
object. When this method is called, the DataSink
is positioned at the start of the entry to write. If this
method returns successfully, the DataSink
should be positioned at
the next block boundary after the written entry (the Tar file is divided
into 512-byte blocks).f
- The file to add to the archive. If this file is in a locking
FileSystem
, it is locked for reading by the caller before this
method is called.location
- The absolute location of the entry in the Tar archive.effectiveSettings
- The effective settings for the entry.lastModified
- The time when the file entity was last modified.public void writeFileFromStream(org.entityfs.RandomAccess out, InputStream is, org.entityfs.el.AbsoluteLocation location, TarEntrySettings effectiveSettings, Date lastModified)
writeFileFromStream
in interface TarEntryStrategy
writeFileFromStream
in class V7TarEntryStrategy
out
- The RandomAccess
to write to. When this method is
called, the RandomAccess
is positioned at the start of the entry
to write. If this method returns successfully, the RandomAccess
should be positioned at the next block boundary after the written entry
(the Tar file is divided into 512-byte blocks).is
- The stream containing the file's data.location
- The absolute location of the entry in the Tar archive.effectiveSettings
- The effective settings for the entry.lastModified
- The time when the file entity was last modified.public void writeDirectory(org.entityfs.DataSink out, DirectoryAdapter<?> da, org.entityfs.el.AbsoluteLocation location, TarEntrySettings effectiveSettings, Date lastModified)
writeDirectory
in interface TarEntryStrategy
writeDirectory
in class V7TarEntryStrategy
out
- The DataSink
to write to. This may be a
RandomAccess
object. When this method is called, the DataSink
is positioned at the start of the entry to write. If this
method returns successfully, the DataSink
should be positioned at
the next block boundary after the written entry (the Tar file is divided
into 512-byte blocks).da
- The directory to add to the Tar file.location
- The absolute location of the entry in the Tar archive.effectiveSettings
- The effective settings for the entry.lastModified
- The time when the directory entity was last modified.