Util.java revision 605
535N/A * The contents of this file are subject to the terms of the 535N/A * Common Development and Distribution License (the "License"). 535N/A * You may not use this file except in compliance with the License. 535N/A * language governing permissions and limitations under the License. 535N/A * When distributing Covered Code, include this CDDL HEADER in each 1408N/A * If applicable, add the following below this CDDL HEADER, with the 535N/A * fields enclosed by brackets "[]" replaced with your own identifying 535N/A * information: Portions Copyright [yyyy] [name of copyright owner] 535N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 535N/A * Use is subject to license terms. 535N/A * File for useful functions 535N/A * Return a string which represents a <code>CharSequence</code> in HTML. 535N/A * @param q a character sequence 535N/A * @return a string representing the character sequence in HTML 1408N/A // Util class, should not be constructed 535N/A * Append a character sequence to an <code>Appendable</code> object. Escape 535N/A * special characters for HTML. 535N/A * @param q a character sequence 535N/A * @param out the object to append the character sequence to 535N/A * @exception IOException if an I/O error occurs 535N/A * Append a character sequence to a <code>StringBuilder</code> 535N/A * object. Escape special characters for HTML. This method is identical to 535N/A * <code>htmlize(CharSequence,Appendable)</code>, except that it is 535N/A * guaranteed not to throw <code>IOException</code> because it uses a 535N/A * <code>StringBuilder</code>. 535N/A * @param q a character sequence 535N/A * @param out the object to append the character sequence to 535N/A * @see #htmlize(CharSequence, Appendable) 535N/A // StringBuilder's append methods are not declared to throw 535N/A // IOException, so this should never happen. 535N/A * Append a character to a an <code>Appendable</code> object. If the 535N/A * character has special meaning in HTML, append a sequence of characters 535N/A * representing the special character. 535N/A * @param c the character to append 535N/A * @param out the object to append the character to 535N/A * @exception IOException if an I/O error occurs * Same as {@code breadcrumbPath(urlPrefix, l, '/')}. * @see #breadcrumbPath(String, String, char) * Same as {@code breadcrumbPath(urlPrefix, l, sep, "", false)}. * @see #breadcrumbPath(String, String, char, String, boolean) * Create a breadcrumb path to allow navigation to each element of a path. * @param urlPrefix what comes before the path in the URL * @param l the full path from which the breadcrumb path is built * @param sep the character that separates the path elements in {@code l} * @param urlPostfix what comes after the path in the URL * @param compact if {@code true}, remove {@code ..} and empty path * elements from the path in the links * @return HTML markup for the breadcrumb path * Leave a breadcrumb to allow navigation to one of the parent directories. * Write a hyperlink to the specified {@code StringBuilder}. * @param urlPrefix what comes before the path in the URL * @param sep the character that separates path elements * @param urlPostfix what comes after the path in the URL * @param compact if {@code true}, remove {@code ..} and empty path * elements from the path in the link * @param hyperl a string builder to which the hyperlink is written * @param path all the elements of the full path * @param index which path element to create a link to // Only generate the link if the path element is non-empty. Empty // path elements could occur if the path contains two consecutive // separator characters, or if the path begins or ends with a path // Add a separator between each path element, but not after the last // one. If the original path ended with a separator, the last element // of the path array is an empty string, which means that the final // separator will be printed. * Append parts of a file path to a {@code StringBuilder}. Separate each * element in the path with "/". The path elements from index 0 up to * index {@code lastIndex} (inclusive) are used. * @param path array of path elements * @param lastIndex the index of the last path element to use * @param out the {@code StringBuilder} to which the path is appended * @param compact if {@code true}, remove {@code ..} and empty path * elements from the path in the link // Copy the relevant part of the path. If compact is false, just // copy the lastIndex first elements. If compact is true, remove empty // path elements, and follow .. up to the parent directory. Occurrences // of .. at the beginning of the path will be removed. // Print the path with / between each element. No separator before // the first element or after the last element. * Generate a regex that matches the specified character. Escape it in * case it is a character that has a special meaning in a regex. * @param c the character that the regex should match * @return a six-character string on the form <tt>\u</tt><i>hhhh</i> }
else if (l <
1048576) {
out.
write(
"<span class=\"blame\"><span class=\"l\"> ");
* Append path and date into a string in such a way that lexicographic * sorting gives the same results as a walk of the file hierarchy. Thus * null (\u0000) is used both to separate directory components and to * separate the path from the date. // We should probably use an encoding which supports a larger // character set, but use ISO-8859-1 for now, since that's what // we use other places in the code. // Should not happen. ISO-8859-1 must be supported by all JVMs. for (
int i =
0; i < q.
length(); i++) {
* Build a string that may be converted to a Query and passed to Lucene. * All parameters may be passed as null or an empty string to indicate that * @param freetext The string from the "Full Search" text-field. This field * will be applied as it is specified. * @param defs The string from the "Definition" text-field. This field * will be searched for in the <b>defs</b> field in the lucene * index. All occurences of ":" will be replaced with "\:" * @param refs The string from the "Symbol" text-field. This field * will be searched for in the <b>refs</b> field in the lucene * index. All occurences of ":" will be replaced with "\:" * @param path The string from the "File Path" text-field. This field * will be searched for in the <b>path</b> field in the lucene * index. All occurences of ":" will be replaced with "\:" * @param hist The string from the "History" text-field. This field * will be searched for in the <b>hist</b> field in the lucene * index. All occurences of ":" will be replaced with "\:" * @return A string to be parsed by the Lucene parser.