⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 invertedindex.java

📁 This code sample shows how to write a simple Javadoc 1.2 Doclet. Used with Javadoc, it can generate
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		    bf.append(token);
		    if (token.endsWith(".")) break;
		    inwht = false;
		}
	    }
	}
	return bf.toString();
    }

    public String getPageFileName(char c) {
	return PAGE_PREFIX + Character.toLowerCase(c) + PAGE_SUFFIX;
    }

    String lastPageOutName = null;
    public boolean setPageOut(TEntry e, File outputDir, String base, 
			      DocErrorReporter rep) {
	boolean ret = true;
	File nf = null;
	StringBuffer lbuf;
	if (e != null) {
	    String nam = getPageFileName(e.word.charAt(0));
	    if (lastPageOutName != null && nam.equals(lastPageOutName)) 
		return ret;
	    lastPageOutName = nam;
	    nf = new File(outputDir, lastPageOutName);
	}
	try {
	    if (pageOut != null) {
		pageOut.print("</table><br><ul>");
		pageOut.println(mostRecentLinkLine);
		pageOut.println("<p><a href='#top'>Back to top</a></p>");
		pageOut.println("</ul>");
		writeLines(pageOut, footerLines);
		pageOut.close();
	    }
	    if (nf != null) {
		pageOut = new PrintWriter(new FileWriter(nf));
		writeLines(pageOut, headerLines);
		pageOut.println("<h2><a name=top></a>Inverted Index: " +
				Character.toUpperCase(e.word.charAt(0)) +
				"</h2>");
		pageOut.println("<ul>");
		int px = charlist.indexOf(new Character(e.word.charAt(0)));
		lbuf = new StringBuffer();
		if (px > 0) {
		    char pc = ((Character)(charlist.get(px - 1))).charValue();
		    lbuf.append("<a href='");
		    lbuf.append(getPageFileName(pc));
		    lbuf.append("'>Previous Page: " + 
				Character.toUpperCase(pc) + 
				"</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
		    lbuf.append('\n');
		}
		lbuf.append("<a href='");
		lbuf.append(TOC_PAGE_NAME);
		lbuf.append("'>Main Page</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
		if (px < (charlist.size() - 1)) {
		    char pc = ((Character)(charlist.get(px + 1))).charValue();
		    lbuf.append("<a href='");
		    lbuf.append(getPageFileName(pc));
		    lbuf.append("'>Next Page: " + 
				    Character.toUpperCase(pc) + 
				    "</a>");
		    lbuf.append('\n');
		}
		mostRecentLinkLine = lbuf.toString();
		pageOut.println(mostRecentLinkLine);
		pageOut.println("</ul>");
	    }
	    linesPer = 0;
	}
	catch (IOException ie) {
	    rep.printError("Could not open file: " + ie);
	    ret = false;
	}
	return ret;
    }

    public String linkFor(TEntry entry, String base) {
	// this is how it seems to work for JDK 1.2
	String ret;
	if (((ProgramElementDoc)(entry.doc)).containingClass() != null) {
	    // assume inner class nesting never more than 1 deep
	    // (this is probably not a good way to do this...)
	    ret = base + "/" + entry.name.replace('.','/') + ".html";
	    int rix = ret.lastIndexOf('/');
	    ret = ret.substring(0,rix) + "." + ret.substring(rix+1);
	}
	else {
	    ret = base + "/" + entry.name.replace('.','/') + ".html";
	}
	return ret;
    }

    public String linkFor(PackageDoc doc, String base) {
	// this is how it seems to work for JDK 1.2
	String ret;
	ret = base + "/" + doc.name().replace('.','/') + "/package-summary.html";
	return ret;
    }

    public void writeLines(PrintWriter pw, String [] lines) {
	int tp;
	for(int ix = 0; ix < lines.length; ix++) {
	    tp = lines[ix].indexOf("%t");
	    if (tp >= 0) {
		pw.print(lines[ix].substring(0,tp));
		pw.print(title);
		pw.println(lines[ix].substring(tp+2));
	    }
	    else {
		pw.println(lines[ix]);
	    }
	}
	return;
    }

    // header and footer for all pages
    static String headerLines[] = {
	"<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">",
	"<html>",
	"<head>",
	"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">",
	"<meta name=\"GENERATOR\" content=\"Java Inverted Index Doclet 0.1\">",
	"<title>%t Doc Inverted Index</title>",
	"</head>",
	"<body bgcolor=\"white\">",
	"<table BORDER=0 CELLSPACING=4 CELLPADDING=3 WIDTH=\"98%\" BGCOLOR=\"#3366FF\" >",
	"<tr>",
	"<td><b><font face=\"Arial, Helvetica\"><font color=\"#FFFFFF\"><font size=+2>%t Class",
	"Documentation Inverted Index</font></font></font></b></td>",
	"</tr>",
	"</table>"
    };


    static String footerLines[] = {
	"<p> &nbsp; </p>",
	"<table BORDER=0 CELLSPACING=4 CELLPADDING=3 WIDTH=\"98%\" BGCOLOR=\"#3366FF\" >",
	"<tr>",
	"<td> &nbsp; </td>",
	"</tr>",
	"</table><ul>",
	"<font size=-1>This page generated by the ",
	reverseIndexDoclet.nameAndVersion,
	"</font>",
	"<br><font size=-1>For more information, or to obtain a copy of the doclet,",
	"mail to <a href=\"mailto:ziring@home.com\">Neal Ziring</a>.</font>",
	"</ul><br>",
	"<ul>",
	"<p><font size=-1>Java, Java 2D, and JDBC are a trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.</font></p>",
	"</ul>",
	"</body>",
	"</html>"
    };    

    static String helpLines[] = {
	"<center>",
	"Back to: &nbsp;&nbsp;<a href='InvIndex.html'>Main Page</a> &nbsp;&nbsp; &nbsp;&nbsp;",
	"<a href='InvIndexConcord.html'>Word Index</a>",
	"</center>",
	"<p>",
	"<h1>Doclet Inverted Index FAQ</h1>",
	"<ul>",
	"<h2>How Do I Use the Inverted Index?</h2>",
	"<p>",
	"The inverted index for the %t class documentation has been ",
	"created to help you find classes that are related to ",
	"certain concepts.  In particular, you can look up a word",
	"in the inverted index, and find all the classes whose",
	"description mention that word.",
	"<p>",
	"For example, let's assume you need to find classes",
	"that have something to do with building raster images.  You",
	"would go to the <b>R</b> section of the inverted index,",
	"and scroll down looking for the word 'raster' in boldface",
	"type.  Alternatively, you could use the word list page",
	"to jump right to the correct section of the inverted index.",
	"<p>",
	"<h2>Where Did this Idea Come From?</h2>",
	"<p>",
	"The inverted index was used for Unix documentation",
	"since the days of Unix Version 6, or perhaps even",
	"earlier.  It provides a simple and easy way to",
	"do keyword searching, without the latency of a",
	"true search engine.",
	"<p>",
	"<h2>How Does the Inverted Index Link to Real %t Documentation?</h2>",
	"<p>",
	"At the time the inverted index was generated, the base URL of",
	"a full %t documentation set was supplied.  This base URL is",
	"used to compute a full URL for the class documentation for",
	"all the %t classes and package in the HTML that the index",
	"generator doclet writes out.",
	"<p>",
	"<h2>Can I Make My Own Inverted Indices?</h2>",
	"<p>",
	"Sure!  This inverted index was generated by a simple",
	"Javadoc Doclet.  If you have the JDK 1.2.1 or later, then",
	"you have a version of Javadoc that can use this doclet.",
	"Mail to <a href='mailto:ziring@home.com'>Neal Ziring</a>",
	"to obtain a copy of the doclet, or search for the ",
	"term 'Inverted Index Doclet' in your favorite Java-oriented",
	"resource directory.",
	"</ul>",
	"<center>",
	"Back to: &nbsp;<a href='InvIndex.html'>Main Page</a>&nbsp;&nbsp;&nbsp;&nbsp;",
	"<a href='InvIndexConcord.html'>Word Index</a>",
	"</center>",
    };


    // list of words to ignore.
    static final String [] nonwordList = {
	"a", "A", 
	"all", "All",
	"among", "Among",
	"an", "An",
	"and", "And", 
	"are", "Are", 
	"as", "As", 
	"attempt", "Attempt",
	"attempting", "Attempting",
	"be", "Be", 
	"between", "Between",
	"by", "By", 
	"called", "Called", 
	"can", "Can", 
	"cannot", "Cannot", 
	"class",
	"common", "Common",
	"could", "Could", 
	"defines", "Defines",
	"defined", "Defined",
	"define", "Define",
	"did", "Did",
	"did't", "Didn't",
	"does", "Does", 
	"doesn't", "doesn'T", 
	"each", "Each", 
	"etc", "Etc",
	"even",
	"false", "False",
	"first", "First", 
	"for", "For", 
	"from", "From", 
	"get", "Get",
	"give", "Give",
	"gives", "Gives",
	"go", "Go",
	"gone", "Gone",
	"has", "Has",
	"have", "Have",
	"had", "Had",
	"haven't" , "Haven't",
	"i.e.", "I.e.",
	"if", "If", 
	"implement", "Implement", 
	"in", "In", 
	"io", "IO", "I/O",
	"into", "Into",
	"is", "Is", 
	"it", "It", 
	"its", "Its", 
	"last", "Last", 
	"least", "Least", 
	"may", "May",
	"most", "Most", 
	"must", "Must", 
	"not", "Not", 
	"of", "Of", 
	"on", "On", 
	"one", "One",
	"onto", "Onto", 
	"or", "Or", 
	"over", "Over",
	"represents", "Represents",
	"such", "Such",
	"so", "So",
	"see", "See",
	"some",
	"support", "Support",
	"supports", "Supports",
	"take", "Take",
	"takes", "Takes",
	"that", "That",
	"the", "The", 
	"them", "Them", 
	"then", "Then", 
	"there", "There", 
	"these", "These", 
	"this", "This",
	"those", "Those", 
	"though", "Through",
	"to", "To", 
	"too", "Too", 
	"true", "True",
	"two", "Two",
	"type", "Type", 
	"under", "Under", 
	"use", "Use", 
	"used", "Used", 
	"uses", "Uses", 
	"useful", "Useful", 
	"usefully", "Usefully", 
	"via", "Via", 
	"was", "Was",
	"wasn't", "Wasn't",
	"well", "Well", 
	"well-known", "Well-known", 
	"what", "What", 
	"what's", "What's", 
	"when", "When", 
	"whenever", "Whenever", 
	"where", "Where", 
	"which", "Which",
	"while", "While",
	"who", "Who", 
	"whose", "Whose", 
	"will", "Will",
	"won't", "Won't",
	"why", "Why", 
	"with", "With",
	"you", "You",
	"your", "Your",
    };

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -