APIdia Launch Partner
Top Description Fields Constructors Methods
sun.tools.jar

pack-priv Class JarIndex

extends Object
Class Inheritance
Imports
java.io.*, java.nio.charset.StandardCharsets, java.util.*, java.util.jar.*, java.util.zip.*

This class is used to maintain mappings from packages, classes and resources to their enclosing JAR files. Mappings are kept at the package level except for class or resource files that are located at the root directory.
Author
Zhenghua Li
Since
1.3

Field Summary

Modifier and TypeField and Description
pack-priv static final String
INDEX_NAME

The index file name.

private final HashMap<String, List<String>>
indexMap

The hash map that maintains mappings from package/class/resource to jar file list(s)

private String[]
private final HashMap<String, List<String>>
jarMap

The hash map that maintains mappings from jar file to package/class/resource lists

private static final boolean
metaInfFilenames

true if, and only if, sun.misc.JarIndex.metaInfFilenames is set to true.

Constructor Summary

AccessConstructor and Description
public
JarIndex(String[]
the list of jar files to construct the index from.
files
)

Constructs a new index for the specified list of jar files.

Method Summary

Modifier and TypeMethod and Description
private void
add(String
the file name
fileName
,
String
the jar file that the file is mapped to
jarName
)

Add the mapping from the specified file to the specified jar file.

private void
addMapping(String jarItem, String jarName)

Same as add(String,String) except that it doesn't strip off from the last index of '/'.

private void
private void
parseJars(String[] files)

Go through all the jar files and construct the index table.

public void
write(OutputStream
the output stream
out
)

Writes the index to the specified OutputStream

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INDEX_NAMEback to summary
pack-priv static final String INDEX_NAME

The index file name.

indexMapback to summary
private final HashMap<String, List<String>> indexMap

The hash map that maintains mappings from package/class/resource to jar file list(s)

jarFilesback to summary
private String[] jarFiles
jarMapback to summary
private final HashMap<String, List<String>> jarMap

The hash map that maintains mappings from jar file to package/class/resource lists

metaInfFilenamesback to summary
private static final boolean metaInfFilenames

true if, and only if, sun.misc.JarIndex.metaInfFilenames is set to true. If true, the names of the files in META-INF, and its subdirectories, will be added to the index. Otherwise, just the directory names are added.

Constructor Detail

JarIndexback to summary
public JarIndex(String[] files) throws IOException

Constructs a new index for the specified list of jar files.

Parameters
files:String[]

the list of jar files to construct the index from.

Method Detail

addback to summary
private void add(String fileName, String jarName)

Add the mapping from the specified file to the specified jar file. If there were no mapping for the package of the specified file before, a new list will be created, the jar file is added to the list and a new mapping from the package to the jar file list is added to the hashmap. Otherwise, the jar file will be added to the end of the existing list.

Parameters
fileName:String

the file name

jarName:String

the jar file that the file is mapped to

addMappingback to summary
private void addMapping(String jarItem, String jarName)

Same as add(String,String) except that it doesn't strip off from the last index of '/'. It just adds the jarItem (filename or package) as it is received.

addToListback to summary
private void addToList(String key, String value, HashMap<String, List<String>> t)
parseJarsback to summary
private void parseJars(String[] files) throws IOException

Go through all the jar files and construct the index table.

writeback to summary
public void write(OutputStream out) throws IOException

Writes the index to the specified OutputStream

Parameters
out:OutputStream

the output stream

Exceptions
IOException:
if an I/O error has occurred