/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* 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. URLClassLoader uses the mapping
* information to determine where to fetch an extension class or
* resource from.
*
* @author Zhenghua Li
* @since 1.3
*/
public class JarIndex {
/**
* The hash map that maintains mappings from
*/
/**
* The hash map that maintains mappings from
*/
/*
* An ordered list of jar file names.
*/
/**
* The index file name.
*/
/**
* 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.
*/
private static final boolean metaInfFilenames =
/**
* Constructs a new, empty jar index.
*/
public JarIndex() {
}
/**
* Constructs a new index from the specified input stream.
*
* @param is the input stream containing the index data
*/
this();
}
/**
* Constructs a new index for the specified list of jar files.
*
* @param files the list of jar files to construct the index from.
*/
this();
}
/**
* Returns the jar index, or <code>null</code> if none.
*
* This single parameter version of the method is retained
* for binary compatibility with earlier releases.
*
* @param jar the JAR file to get the index from.
* @exception IOException if an I/O error has occurred.
*/
}
/**
* Returns the jar index, or <code>null</code> if none.
*
* @param jar the JAR file to get the index from.
* @exception IOException if an I/O error has occurred.
*/
/* If metaIndex is not null, check the meta index to see
if META-INF/INDEX.LIST is contained in jar file or not.
*/
return null;
}
// if found, then load the index
if (e != null) {
}
return index;
}
/**
* Returns the jar files that are defined in this index.
*/
return jarFiles;
}
/*
* Add the key, value pair to the hashmap, the value will
* be put in a linked list which is created if necessary.
*/
list = new LinkedList();
}
}
/**
* Returns the list of jar files that are mapped to the file.
*
* @param fileName the key of the mapping
*/
/* try the package name again */
int pos;
}
}
return jarFiles;
}
/**
* 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 linked 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.
*
* @param fileName the file name
* @param jarName the jar file that the file is mapped to
*
*/
int pos;
} else {
}
// add the mapping to indexMap
// add the mapping to jarMap
}
/**
* Same as add(String,String) except that it doesn't strip off from the
* last index of '/'. It just adds the filename.
*/
// add the mapping to indexMap
// add the mapping to jarMap
}
/**
* Go through all the jar files and construct the
* index table.
*/
return;
}
currentJar = files[i];
while(entries.hasMoreElements()) {
// Skip the META-INF directory, the index, and manifest.
// Any files in META-INF/ will be indexed explicitly
continue;
if (!metaInfFilenames) {
} else {
} else if (!entry.isDirectory()) {
// Add files under META-INF explicitly so that certain
// services, like ServiceLoader, etc, can be located
// with greater accuracy. Directories can be skipped
// since each file will be added explicitly.
}
}
}
}
}
/**
* Writes the index to the specified OutputStream
*
* @param out the output stream
* @exception IOException if an I/O error has occurred
*/
/* print out the jar file name */
}
}
}
}
}
/**
* Reads the index from the specified InputStream.
*
* @param is the input stream
* @exception IOException if an I/O error has occurred
*/
/* an ordered list of jar file names */
/* read until we see a .jar line */
continue;
currentJar = line;
} else {
}
}
}
/**
* Merges the current index into another index, taking into account
* the relative path of the current index.
*
* @param toIndex The destination index which the current index will
* merge into.
* @param path The relative path of the this index to the destination
* index.
*
*/
}
}
}
}
}