Util.java revision 604
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/**
* File for useful functions
*/
public final class Util {
/**
* Return a string which represents a <code>CharSequence</code> in HTML.
*
* @param q a character sequence
* @return a string representing the character sequence in HTML
*/
private Util() {
// Util class, should not be constructed
}
}
/**
* Append a character sequence to an <code>Appendable</code> object. Escape
* special characters for HTML.
*
* @param q a character sequence
* @param out the object to append the character sequence to
* @exception IOException if an I/O error occurs
*/
throws IOException {
for (int i = 0; i < q.length(); i++) {
}
}
/**
* Append a character sequence to a <code>StringBuilder</code>
* object. Escape special characters for HTML. This method is identical to
* <code>htmlize(CharSequence,Appendable)</code>, except that it is
* guaranteed not to throw <code>IOException</code> because it uses a
* <code>StringBuilder</code>.
*
* @param q a character sequence
* @param out the object to append the character sequence to
* @see #htmlize(CharSequence, Appendable)
*/
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
try {
} catch (IOException ioe) {
// StringBuilder's append methods are not declared to throw
// IOException, so this should never happen.
}
}
throws IOException {
}
}
/**
* Append a character to a an <code>Appendable</code> object. If the
* character has special meaning in HTML, append a sequence of characters
* representing the special character.
*
* @param c the character to append
* @param out the object to append the character to
* @exception IOException if an I/O error occurs
*/
switch (c) {
case '&':
break;
case '>':
break;
case '<':
break;
case '\n':
break;
default:
}
}
/**
* Same as {@code breadcrumbPath(urlPrefix, l, '/')}.
* @see #breadcrumbPath(String, String, char)
*/
}
/**
* Same as {@code breadcrumbPath(urlPrefix, l, sep, "")}.
* @see #breadcrumbPath(String, String, char, String)
*/
}
/**
* 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
* @return HTML markup for the breadcrumb path
*/
public static String breadcrumbPath(
return l;
}
}
}
/**
* 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 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
*/
private static void leaveBreadcrumb(
// 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
// separator.
}
// 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
*/
private static void appendPath(
for (int i = 0; i <= lastIndex; i++) {
if (i < lastIndex) {
}
}
}
/**
* 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>
*/
private static String escapeForRegex(char c) {
}
}
float l = (float) num;
if (l < 1024) {
} else if (l < 1048576) {
} else {
}
}
throws IOException {
if (num > 1) {
}
if (annotation != null) {
}
if (enabled) {
}
if (enabled) {
}
}
} else {
}
}
}
/**
* 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.
*/
}
}
try {
// 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.
} catch (UnsupportedEncodingException e) {
// Should not happen. ISO-8859-1 must be supported by all JVMs.
return null;
}
}
try {
return uri.getRawPath();
} catch (URISyntaxException ex) {
return "";
}
}
if (q == null) {
return "";
}
char c;
for (int i = 0; i < q.length(); i++) {
c = q.charAt(i);
if (c == '"') {
} else {
}
}
}
/**
* 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
* they are unused.
*
* @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.
*/
public static String buildQueryString(String freetext, String defs, String refs, String path, String hist) {
}
}
}
}
}
}
}
}