/*
0002 * Java2Web - A configurable Java to HTML source code converter.
0003 * Copyright (c) 2006 Alexander Hristov.
0004 *
0005 * This program is free software; you can redistribute it and/or
0006 * modify it under the terms of the GNU General Public License
0007 * as published by the Free Software Foundation; either version 2
0008 * of the License, or (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License
0016 * along with this program; if not, write to the Free Software
0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018 *
0019 */
/**
0030 * This class handless a repository of known to the system. This repository is later used in order
0031 * to convert simple class names to fully qualified ones, thus determining which javadoc link them
0032 * to.
0033 * @author Alexander Hristov
0034 *
0035 */
0036publicclassClassResolver {
0037
/**
0038 * Hashmap linking simple class names to the possible fully qualified ones. For example: <br/>
0039 * (Date -> (java.sql.Date, java.util.Date))
0040 *
0041 */
/**
0051 * Adds a fully qualified class name to the list of classes recognized by the resolver
0052 * @param className Fully qualified class name
0053 */
0054publicvoidaddClass(StringclassName) {
0055intdot=className.lastIndexOf(".");
0056if (dot==-1) thrownewIllegalArgumentException("The class name must be fully qualified, and it is not ("+className+")");
0057StringsimpleClassName=className.substring(dot+1);
0058ArrayList<String>possibilities=classes.get(simpleClassName);
0059if (possibilities==null) {
0060possibilities=newArrayList<String>();
0061classes.put(simpleClassName,possibilities);
0062 }
0063possibilities.add(className);
0064 }
00650066
/**
0067 * Reads all classes from a single javadoc package directory
0068 * @param rootPath Root path of the javadoc tree (E.g. "c:\java\doc")
0069 * @param packageName Package name whose contents we want to read (E.G "java.lang")
0070 * @return number of classes read
0071 */
/**
0089 * Reads all classes in all packages described in the package-list file of the specified root path.
0090 * Does nothing if the specified path does not contain a package-list file
0091 * @param rootPath Root path of the javadoc tree (E.g. "c:\java\doc")
0092 * @return number of classes read
0093 * @throws IOException If an I/O error occurs
0094 */
/**
0113 * Adds an import to the list of imports recognized by the resolver.
0114 * @param importSequence what was imported. NEITHER the "import" keyword NOR the ending
0115 * semicolon must NOT be included.
0116 */
/**
0133 * Given a simple class name, analyzing the available classes AND the imports, determines which is
0134 * the fully qualified class name
0135 * @param className Simple unqualified class name (e.g.:"String")
0136 * @return Fully qualified class name ("java.lang.String") OR null if the class could not be resolved
0137 */