Util.java revision 604
98N/A * CDDL HEADER START 98N/A * The contents of this file are subject to the terms of the 98N/A * Common Development and Distribution License (the "License"). 98N/A * You may not use this file except in compliance with the License. 98N/A * language governing permissions and limitations under the License. 98N/A * When distributing Covered Code, include this CDDL HEADER in each 98N/A * If applicable, add the following below this CDDL HEADER, with the 98N/A * fields enclosed by brackets "[]" replaced with your own identifying 98N/A * information: Portions Copyright [yyyy] [name of copyright owner] 98N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 98N/A * Use is subject to license terms. 156N/A * File for useful functions 98N/A * Return a string which represents a <code>CharSequence</code> in HTML. 98N/A * @param q a character sequence 98N/A * @return a string representing the character sequence in HTML 98N/A // Util class, should not be constructed 122N/A * Append a character sequence to an <code>Appendable</code> object. Escape 127N/A * special characters for HTML. 145N/A * @param q a character sequence 98N/A * @param out the object to append the character sequence to 98N/A * @exception IOException if an I/O error occurs 98N/A * Append a character sequence to a <code>StringBuilder</code> 98N/A * object. Escape special characters for HTML. This method is identical to 98N/A * <code>htmlize(CharSequence,Appendable)</code>, except that it is 98N/A * guaranteed not to throw <code>IOException</code> because it uses a 98N/A * <code>StringBuilder</code>. 98N/A * @param q a character sequence 98N/A * @param out the object to append the character sequence to 98N/A * @see #htmlize(CharSequence, Appendable) 98N/A // StringBuilder's append methods are not declared to throw 98N/A // IOException, so this should never happen. 98N/A * Append a character to a an <code>Appendable</code> object. If the 98N/A * character has special meaning in HTML, append a sequence of characters 98N/A * representing the special character. 98N/A * @param c the character to append 98N/A * @param out the object to append the character to 98N/A * @exception IOException if an I/O error occurs 98N/A * Same as {@code breadcrumbPath(urlPrefix, l, '/')}. 98N/A * @see #breadcrumbPath(String, String, char) 98N/A * Same as {@code breadcrumbPath(urlPrefix, l, sep, "")}. 98N/A * @see #breadcrumbPath(String, String, char, String) 98N/A * Create a breadcrumb path to allow navigation to each element of a path. 98N/A * @param urlPrefix what comes before the path in the URL 98N/A * @param l the full path from which the breadcrumb path is built 98N/A * @param sep the character that separates the path elements in {@code l} 156N/A * @param urlPostfix what comes after the path in the URL 156N/A * @return HTML markup for the breadcrumb path 98N/A * Leave a breadcrumb to allow navigation to one of the parent directories. 106N/A * Write a hyperlink to the specified {@code StringBuilder}. 98N/A * @param urlPrefix what comes before the path in the URL 98N/A * @param sep the character that separates path elements 98N/A * @param urlPostfix what comes after the path in the URL 98N/A * @param hyperl a string builder to which the hyperlink is written 98N/A * @param path all the elements of the full path 98N/A * @param index which path element to create a link to 98N/A // Only generate the link if the path element is non-empty. Empty 98N/A // path elements could occur if the path contains two consecutive 98N/A // separator characters, or if the path begins or ends with a path 98N/A // Add a separator between each path element, but not after the last 98N/A // one. If the original path ended with a separator, the last element 156N/A // of the path array is an empty string, which means that the final 156N/A // separator will be printed. 156N/A * Append parts of a file path to a {@code StringBuilder}. Separate each 98N/A * element in the path with "/". The path elements from index 0 up to 98N/A * index {@code lastIndex} (inclusive) are used. 98N/A * @param path array of path elements 98N/A * @param lastIndex the index of the last path element to use 98N/A * @param out the {@code StringBuilder} to which the path is appended 98N/A * Generate a regex that matches the specified character. Escape it in 98N/A * case it is a character that has a special meaning in a regex. 111N/A * @param c the character that the regex should match 111N/A * @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.