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