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] 1297N/A * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 1185N/A * Portions Copyright 2011 Jens Elkner. 1185N/A * Class for useful functions. 92N/A * Return a string which represents a <code>CharSequence</code> in HTML. 92N/A * @return a string representing the character sequence in HTML 1185N/A * Append a character sequence to the given destination whereby 1185N/A * special characters for HTML are escaped accordingly. 1185N/A * @param q a character sequence to esacpe 1185N/A * @param dest where to append the character sequence to 1185N/A * Append a character array to the given destination whereby 1185N/A * special characters for HTML are escaped accordingly. 1185N/A * @param cs characters to esacpe 1185N/A * @param length max. number of characters to append, starting from index 0. 1185N/A * @param dest where to append the character sequence to 1190N/A * Append a character to the given destination whereby special characters 1185N/A * special for HTML are escaped accordingly. 1185N/A * @param c the character to append 1185N/A * @param dest where to append the character to 1185N/A * used by BUI - CSS needs this parameter for proper cache refresh (per 1185N/A * changeset) in client browser jel: but useless, since the page cached 990N/A * @return html escaped version (hg changeset) 1185N/A * Convinience method for {@code breadcrumbPath(urlPrefix, path, '/')}. 1185N/A * @param urlPrefix prefix to add to each url 1185N/A * @param path path to crack 1185N/A * @return HTML markup fro the breadcrumb or the path itself. 604N/A * @see #breadcrumbPath(String, String, char) 1185N/A * {@code breadcrumbPath(urlPrefix, path, sep, "", false)}. 1185N/A * @param urlPrefix prefix to add to each url 1185N/A * @param path path to crack 1185N/A * @param sep separator to use to crack the given path 1185N/A * @return HTML markup fro the breadcrumb or the path itself. 1185N/A * @see #breadcrumbPath(String, String, char, String, boolean, boolean) 1185N/A * {@code breadcrumbPath(urlPrefix, path, sep, "", false, path.endsWith(sep)}. 1185N/A * @param urlPrefix prefix to add to each url 1185N/A * @param path path to crack 1185N/A * @param sep separator to use to crack the given path 1185N/A * @param urlPostfix suffix to add to each url 1185N/A * @param compact if {@code true} the given path gets transformed into 1190N/A * its canonical form (.i.e. all '.' and '..' and double separators 1190N/A * removed, but not always resolves to an absolute path) before processing 1185N/A * @return HTML markup fro the breadcrumb or the path itself. 1185N/A * @see #breadcrumbPath(String, String, char, String, boolean, boolean) 1185N/A * @see #getCanonicalPath(String, char) 604N/A * Create a breadcrumb path to allow navigation to each element of a path. 1185N/A * Consecutive separators (<var>sep</var>) in the given <var>path</var> are 1185N/A * always collapsed into a single separator automatically. If 1185N/A * <var>compact</var> is {@code true} path gets translated into a canonical 1185N/A * path similar to {@link File#getCanonicalPath()}, however the current 1185N/A * working directory is assumed to be "/" and no checks are done (e.g. 1185N/A * neither whether the path [component] exists nor which type it is). 1185N/A * what should be prepend to the constructed URL 1185N/A * the full path from which the breadcrumb path is built. 1185N/A * the character that separates the path components in 1185N/A * what should be append to the constructed URL 1185N/A * if {@code true}, a canonical path gets constructed before 1185N/A * if {@code true} a "/" gets append to the last path component's 1185N/A * link and <var>sep</var> to its name 1190N/A * @return <var>path</var> if it resolves to an empty or "/" or 1185N/A * {@code null} path, the HTML markup for the breadcrumb path otherwise. 1190N/A * Normalize the given <var>path</var> to its canonical form. I.e. all 1190N/A * separators (<var>sep</var>) are replaced with a slash ('/'), all 1185N/A * double slashes are replaced by a single slash, all single dot path 1190N/A * components (".") of the formed path are removed and all double dot path 1190N/A * components (".." ) of the formed path are replaced with its parent or 1185N/A * '/' if there is no parent. 1185N/A * So the difference to {@link File#getCanonicalPath()} is, that this method 1185N/A * does not hit the disk (just string manipulation), resolves <var>path</var> 1190N/A * always against '/' and thus always returns an absolute path, which may 1190N/A * actually not exist, and which has a single trailing '/' if the given 1190N/A * <var>path</var> ends with the given <var>sep</var>. 1190N/A * @param path path to mangle. If not absolute or {@code null}, the 1185N/A * current working directory is assumed to be '/'. 1185N/A * @param sep file separator to use to crack <var>path</var> into path 1185N/A * @return always a canonical path which starts with a '/'. 1190N/A // since is not a general purpose method. So we waive to handle 1185N/A // || path.endsWith("/..") || path.endsWith("/.") 1297N/A * Get email address of the author. 1297N/A * string containing author and possibly email address. 1297N/A * @return email address of the author or 1297N/A * full author string if the author string does not contain an email 1185N/A * Remove all empty and {@code null} string elements from the given 1185N/A * <var>names</var> and optionally all redundant information like "." and 1185N/A * if {@code true}, remove redundant elements as well. 1185N/A * @return a possible empty array of names all with a length > 0. 1185N/A * Generate a regex that matches the specified character. Escape it in case 1185N/A * it is a character that has a special meaning in a regex. 1185N/A * the character that the regex should match 604N/A * @return a six-character string on the form <tt>\u</tt><i>hhhh</i> 1185N/A * Convert the given size into a human readable string. 1185N/A * @param num size to convert. 1185N/A * @return a readable string 154N/A }
else if (l <
1048576) {
1185N/A * Converts different html special characters into their encodings used in 1185N/A * html. Currently used only for tooltips of annotation revision number view 878N/A * @return encoded text for use in <a title=""> tag 1190N/A * Write out line information wrt. to the given annotation in the format: 1185N/A * {@code Linenumber Blame Author} incl. appropriate links. 1185N/A * @param num linenumber to print 1185N/A * @param out print destination 1190N/A * @param annotation annotation to use. If {@code null} only the 1185N/A * @param userPageLink see {@link RuntimeEnvironment#getUserPage()} 1185N/A * @param userPageSuffix see {@link RuntimeEnvironment#getUserPageSuffix()} 1185N/A * @throws IOException depends on the destination (<var>out</var>). 1185N/A // this method should go to JFlexXref 1185N/A * Generate a string from the given path and date in a way that allows 1190N/A * stable lexicographic sorting (i.e. gives always the same results) as a 1190N/A * walk of the file hierarchy. Thus null character (\u0000) is used both 1185N/A * to separate directory components and to separate the path from the date. 1185N/A * @param path path to mangle. 1185N/A * @param date date string to use. 1185N/A * @return the mangled path. 1190N/A * The reverse operation for {@link #path2uid(String, String)} - re-creates 1185N/A * the unmangled path from the given uid. 1185N/A * @param uid uid to unmangle. 1185N/A * @return the original path. 849N/A * wrapper arround UTF-8 URL encoding of a string 1185N/A * @param q query to be encoded. If {@code null}, an empty string will 849N/A * @return null if fail, otherwise the encoded string 1185N/A * @see URLEncoder#encode(String, String) 830N/A // Should not happen. UTF-8 must be supported by JVMs. 1185N/A * Append '&name=value" to the given buffer. If the given <var>value</var> 1185N/A * is {@code null}, this method does nothing. 1185N/A * @param buf where to append the query string 1185N/A * @param key the name of the parameter to add. Append as is! 1185N/A * @param value the value for the given parameter. Gets automatically UTF-8 1185N/A * @throws NullPointerException if the given buffer is {@code null}. 1185N/A * URI encode the given path. 1185N/A * @param path path to encode. 1185N/A * @return the encoded path. 1185N/A * @throws NullPointerException if a parameter is {@code null} 1340N/A // Bug #19188: Ideally, we'd like to use the standard class library to 1340N/A // encode the paths. We're aware of the following two methods: 1340N/A // 1) URLEncoder.encode() - this method however transforms space to + 1340N/A // instead of %20 (which is right for HTML form data, but not for 1340N/A // paths), and it also does not preserve the separator chars (/). 1340N/A // 2) URI.getRawPath() - transforms space and / as expected, but gets 1340N/A // confused when the path name contains a colon character (it thinks 1340N/A // parts of the path is schema in that case) 1340N/A // For now, encode manually the way we want it. 1340N/A // URLEncoder's javadoc says a-z, A-Z, ., -, _ and * are safe 1340N/A // characters, so we preserve those to make the encoded string 1340N/A // shorter and easier to read. We also preserve the separator 1340N/A // chars (/). All other characters are encoded (as UTF-8 byte 1340N/A if ((b ==
'/') || (b >=
'a' && b <=
'z') ||
1340N/A (b >=
'A' && b <=
'Z') || (b >=
'0' && b <=
'9') ||
1340N/A (b ==
'.') || (b ==
'-') || (b ==
'_') || (b ==
'*')) {
1340N/A int u = b &
0xFF;
// Make the byte value unsigned. 1340N/A // Add leading zero if required. 1185N/A * Replace all quote characters (ASCI 0x22) with the corresponding html 1185N/A * @param q string to escape. 1190N/A * @return an empty string if a parameter is {@code null}, the mangled 1185N/A * Tag changes in the given <var>line1</var> and <var>line2</var> 1185N/A * for highlighting. Removed parts are tagged with CSS class {@code d}, 1185N/A * new parts are tagged with CSS class {@code a} using a {@code span} 1185N/A * @param line1 line of the original file 1185N/A * @return the tagged lines (field[0] ~= line1, field[1] ~= line2). 1190N/A * @throws NullPointerException if one of the given parameters is {@code null}. 1124N/A * Dump the configuration as an HTML table. 1185N/A * destination for the HTML output 1185N/A * if an error happens while writing to {@code out} 1185N/A * if the history guru cannot be accesses 1185N/A * Just read the given source and dump as is to the given destionation. 1190N/A * Does nothing, if one or more of the parameters is {@code null}. 1185N/A * @param out write destination 1185N/A * @throws NullPointerException if a parameter is {@code null}. 1190N/A * Silently dump a file to the given destionation. All {@link IOException}s 1185N/A * gets caught and logged, but not re-thrown. 1185N/A * @param out dump destination 1185N/A * @param dir directory, which should contains the file. 1185N/A * @param filename the basename of the file to dump. 1185N/A * @param compressed if {@code true} the denoted file is assumed to be 1185N/A * @return {@code true} on success (everything read and written). 1185N/A * @throws NullPointerException if a parameter is {@code null}. 1190N/A * Silently dump a file to the given destionation. All {@link IOException}s 1185N/A * gets caught and logged, but not re-thrown. 1185N/A * @param out dump destination 1185N/A * @param file file to dump. 1185N/A * @param compressed if {@code true} the denoted file is assumed to be 1185N/A * @return {@code true} on success (everything read and written). 1185N/A * @throws NullPointerException if a parameter is {@code null}. 1185N/A "An error occured while piping file " +
file +
": ", e);
1124N/A * Print a row in an HTML table. 1185N/A * destination for the HTML output 1185N/A * the values to print in the cells of the row 1185N/A * if an error happens while writing to {@code out} 1124N/A * Print an unordered list (HTML). 1185N/A * destination for the HTML output 1185N/A * if an error happens while writing to {@code out} 1145N/A * Create a string literal for use in JavaScript functions. 1185N/A * the string to be represented by the literal 1145N/A * @return a JavaScript string literal