|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.tools.javac.file.ZipFileIndex
public class ZipFileIndex
This class implements building of index of a zip archive and access to it's context.
It also uses prebuild index if available. It supports invocations where it will
serialize an optimized zip index file to disk.
In oreder to use secondary index file make sure the option "usezipindex" is in the Options object,
when JavacFileManager is invoked. (You can pass "-XDusezipindex" on the command line.
Location where to look for/generate optimized zip index files can be provided using
"-XDcachezipindexdir=
Nested Class Summary | |
---|---|
(package private) static class |
ZipFileIndex.DirectoryEntry
------------------------------------------------------------------------ DirectoryEntry class ------------------------------------------------------------------------- |
(package private) static class |
ZipFileIndex.Entry
|
private class |
ZipFileIndex.ZipDirectory
|
Field Summary | |
---|---|
private java.util.Set<RelativePath.RelativeDirectory> |
allDirs
|
private java.util.Map<RelativePath.RelativeDirectory,ZipFileIndex.DirectoryEntry> |
directories
|
private ZipFileIndex.Entry[] |
entries
|
private boolean |
hasPopulatedData
|
private static java.util.zip.Inflater |
inflater
|
private long |
lastReferenceTimeStamp
|
private static java.util.concurrent.locks.ReentrantLock |
lock
|
private static java.lang.String |
MAX_CHAR
|
private static java.lang.String |
MIN_CHAR
|
private static boolean |
NON_BATCH_MODE
|
static long |
NOT_MODIFIED
|
private java.lang.String |
preindexedCacheLocation
|
private boolean |
readFromIndex
|
private java.util.Map<java.lang.String,java.lang.ref.SoftReference<RelativePath.RelativeDirectory>> |
relativeDirectoryCache
|
(package private) RelativePath.RelativeDirectory |
symbolFilePrefix
|
private int |
symbolFilePrefixLength
|
private boolean |
triedToReadIndex
|
private boolean |
usePreindexedCache
|
private boolean |
writeIndex
|
private java.io.File |
zipFile
|
private static java.util.Map<java.io.File,ZipFileIndex> |
zipFileIndexCache
|
private long |
zipFileLastModified
|
private java.io.File |
zipIndexFile
|
private java.io.RandomAccessFile |
zipRandomFile
|
Constructor Summary | |
---|---|
private |
ZipFileIndex(java.io.File zipFile,
RelativePath.RelativeDirectory symbolFilePrefix,
boolean writeIndex,
boolean useCache,
java.lang.String cacheLocation)
|
Method Summary | |
---|---|
private void |
checkIndex()
Here we need to make sure that the ZipFileIndex is valid. |
private void |
cleanupState()
|
static void |
clearCache()
|
static void |
clearCache(long timeNotUsed)
|
void |
close()
|
private void |
closeFile()
|
boolean |
contains(RelativePath path)
Tests if a specific path exists in the zip. |
protected void |
finalize()
|
private static int |
get2ByteLittleEndian(byte[] buf,
int pos)
return the two bytes buf[pos], buf[pos+1] as an unsigned integer in little endian format. |
private static int |
get4ByteLittleEndian(byte[] buf,
int pos)
return the 4 bytes buf[i..i+3] as an integer in little endian format. |
java.util.Set<RelativePath.RelativeDirectory> |
getAllDirectories()
|
java.util.List<java.lang.String> |
getDirectories(RelativePath.RelativeDirectory path)
|
static ZipFileIndex |
getExistingZipIndex(java.io.File zipFile)
|
List<java.lang.String> |
getFiles(RelativePath.RelativeDirectory path)
Returns a javac List of filenames within an absolute path in the ZipFileIndex. |
private byte[] |
getHeader(ZipFileIndex.Entry entry)
|
private java.io.File |
getIndexFile()
|
long |
getLastModified(RelativePath.RelativeFile path)
|
private RelativePath.RelativeDirectory |
getRelativeDirectory(java.lang.String path)
|
java.io.File |
getZipFile()
|
static ZipFileIndex |
getZipFileIndex(java.io.File zipFile,
RelativePath.RelativeDirectory symbolFilePrefix,
boolean useCache,
java.lang.String cacheLocation,
boolean writeIndex)
|
static java.util.List<ZipFileIndex> |
getZipFileIndexes()
Returns a list of all ZipFileIndex entries |
static java.util.List<ZipFileIndex> |
getZipFileIndexes(boolean openedOnly)
Returns a list of all ZipFileIndex entries |
long |
getZipFileLastModified()
Returns the last modified timestamp of a zip file. |
(package private) ZipFileIndex.Entry |
getZipIndexEntry(RelativePath path)
Returns the ZipFileIndexEntry for an absolute path, if there is one. |
private int |
inflate(byte[] src,
byte[] dest)
|
boolean |
isDirectory(RelativePath path)
|
boolean |
isOpen()
|
private boolean |
isUpToDate()
|
int |
length(RelativePath.RelativeFile path)
|
private void |
openFile()
|
byte[] |
read(RelativePath.RelativeFile path)
|
int |
read(RelativePath.RelativeFile path,
byte[] buffer)
|
(package private) byte[] |
read(ZipFileIndex.Entry entry)
|
(package private) int |
read(ZipFileIndex.Entry entry,
byte[] buffer)
|
private byte[] |
readBytes(ZipFileIndex.Entry entry)
|
private int |
readBytes(ZipFileIndex.Entry entry,
byte[] buffer)
|
private boolean |
readIndex()
|
static void |
removeFromCache(java.io.File file)
|
static void |
setOpenedIndexes(java.util.List<ZipFileIndex> indexes)
Sets already opened list of ZipFileIndexes from an outside client of the compiler. |
java.lang.String |
toString()
|
private boolean |
writeIndex()
|
boolean |
writeZipIndex()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String MIN_CHAR
private static final java.lang.String MAX_CHAR
public static final long NOT_MODIFIED
private static java.util.Map<java.io.File,ZipFileIndex> zipFileIndexCache
private static java.util.concurrent.locks.ReentrantLock lock
private static boolean NON_BATCH_MODE
private java.util.Map<RelativePath.RelativeDirectory,ZipFileIndex.DirectoryEntry> directories
private java.util.Set<RelativePath.RelativeDirectory> allDirs
private java.io.File zipFile
private long zipFileLastModified
private java.io.RandomAccessFile zipRandomFile
private ZipFileIndex.Entry[] entries
private boolean readFromIndex
private java.io.File zipIndexFile
private boolean triedToReadIndex
final RelativePath.RelativeDirectory symbolFilePrefix
private int symbolFilePrefixLength
private boolean hasPopulatedData
private long lastReferenceTimeStamp
private boolean usePreindexedCache
private java.lang.String preindexedCacheLocation
private boolean writeIndex
private java.util.Map<java.lang.String,java.lang.ref.SoftReference<RelativePath.RelativeDirectory>> relativeDirectoryCache
private static java.util.zip.Inflater inflater
Constructor Detail |
---|
private ZipFileIndex(java.io.File zipFile, RelativePath.RelativeDirectory symbolFilePrefix, boolean writeIndex, boolean useCache, java.lang.String cacheLocation) throws java.io.IOException
java.io.IOException
Method Detail |
---|
public static java.util.List<ZipFileIndex> getZipFileIndexes()
public static java.util.List<ZipFileIndex> getZipFileIndexes(boolean openedOnly)
openedOnly
- If true it returns a list of only opened ZipFileIndex entries, otherwise
all ZipFileEntry(s) are included into the list.
public boolean isOpen()
public static ZipFileIndex getZipFileIndex(java.io.File zipFile, RelativePath.RelativeDirectory symbolFilePrefix, boolean useCache, java.lang.String cacheLocation, boolean writeIndex) throws java.io.IOException
java.io.IOException
public static ZipFileIndex getExistingZipIndex(java.io.File zipFile)
public static void clearCache()
public static void clearCache(long timeNotUsed)
public static void removeFromCache(java.io.File file)
public static void setOpenedIndexes(java.util.List<ZipFileIndex> indexes) throws java.lang.IllegalStateException
java.lang.IllegalStateException
public java.lang.String toString()
toString
in class java.lang.Object
protected void finalize()
finalize
in class java.lang.Object
private boolean isUpToDate()
private void checkIndex() throws java.io.IOException
java.io.IOException
private void openFile() throws java.io.FileNotFoundException
java.io.FileNotFoundException
private void cleanupState()
public void close()
private void closeFile()
ZipFileIndex.Entry getZipIndexEntry(RelativePath path)
public List<java.lang.String> getFiles(RelativePath.RelativeDirectory path)
public java.util.List<java.lang.String> getDirectories(RelativePath.RelativeDirectory path)
public java.util.Set<RelativePath.RelativeDirectory> getAllDirectories()
public boolean contains(RelativePath path)
path
- A path within the zip.
public boolean isDirectory(RelativePath path) throws java.io.IOException
java.io.IOException
public long getLastModified(RelativePath.RelativeFile path) throws java.io.IOException
java.io.IOException
public int length(RelativePath.RelativeFile path) throws java.io.IOException
java.io.IOException
public byte[] read(RelativePath.RelativeFile path) throws java.io.IOException
java.io.IOException
byte[] read(ZipFileIndex.Entry entry) throws java.io.IOException
java.io.IOException
public int read(RelativePath.RelativeFile path, byte[] buffer) throws java.io.IOException
java.io.IOException
int read(ZipFileIndex.Entry entry, byte[] buffer) throws java.io.IOException
java.io.IOException
private byte[] readBytes(ZipFileIndex.Entry entry) throws java.io.IOException
java.io.IOException
private int readBytes(ZipFileIndex.Entry entry, byte[] buffer) throws java.io.IOException
java.io.IOException
private byte[] getHeader(ZipFileIndex.Entry entry) throws java.io.IOException
java.io.IOException
private int inflate(byte[] src, byte[] dest)
private static int get2ByteLittleEndian(byte[] buf, int pos)
private static int get4ByteLittleEndian(byte[] buf, int pos)
public long getZipFileLastModified() throws java.io.IOException
java.io.IOException
private boolean readIndex()
private boolean writeIndex()
public boolean writeZipIndex()
private java.io.File getIndexFile()
public java.io.File getZipFile()
private RelativePath.RelativeDirectory getRelativeDirectory(java.lang.String path)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |