org.opensolaris.opengrok.web
Class Util

java.lang.Object
  extended by org.opensolaris.opengrok.web.Util

public final class Util
extends java.lang.Object

File for useful functions


Method Summary
static java.lang.String breadcrumbPath(java.lang.String urlPrefix, java.lang.String l)
          Same as breadcrumbPath(urlPrefix, l, '/').
static java.lang.String breadcrumbPath(java.lang.String urlPrefix, java.lang.String l, char sep)
          Same as breadcrumbPath(urlPrefix, l, sep, "", false).
static java.lang.String breadcrumbPath(java.lang.String urlPrefix, java.lang.String l, char sep, java.lang.String urlPostfix, boolean compact)
          Create a breadcrumb path to allow navigation to each element of a path.
static java.lang.String buildQueryString(java.lang.String freetext, java.lang.String defs, java.lang.String refs, java.lang.String path, java.lang.String hist)
          Build a string that may be converted to a Query and passed to Lucene.
static java.lang.String encode(java.lang.String s)
          Converts different html special characters into their encodings used in html currently used only for tooltips of annotation revision number view
static java.lang.String formQuoteEscape(java.lang.String q)
           
static void htmlize(char[] cs, int length, java.lang.Appendable out)
           
static java.lang.String htmlize(java.lang.CharSequence q)
           
static void htmlize(java.lang.CharSequence q, java.lang.Appendable out)
          Append a character sequence to an Appendable object.
static void htmlize(java.lang.CharSequence q, java.lang.StringBuilder out)
          Append a character sequence to a StringBuilder object.
static void readableLine(int num, java.io.Writer out, Annotation annotation)
           
static java.lang.String redableSize(long num)
           
static java.lang.String uid(java.lang.String path, java.lang.String date)
          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.
static java.lang.String uid2url(java.lang.String uid)
           
static java.lang.String URIEncode(java.lang.String q)
          wrapper arround UTF-8 URL encoding of a string
static java.lang.String URIEncodePath(java.lang.String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

htmlize

public static java.lang.String htmlize(java.lang.CharSequence q)

htmlize

public static void htmlize(java.lang.CharSequence q,
                           java.lang.Appendable out)
                    throws java.io.IOException
Append a character sequence to an Appendable object. Escape special characters for HTML.

Parameters:
q - a character sequence
out - the object to append the character sequence to
Throws:
java.io.IOException - if an I/O error occurs

htmlize

public static void htmlize(java.lang.CharSequence q,
                           java.lang.StringBuilder out)
Append a character sequence to a StringBuilder object. Escape special characters for HTML. This method is identical to htmlize(CharSequence,Appendable), except that it is guaranteed not to throw IOException because it uses a StringBuilder.

Parameters:
q - a character sequence
out - the object to append the character sequence to
See Also:
htmlize(CharSequence, Appendable)

htmlize

public static void htmlize(char[] cs,
                           int length,
                           java.lang.Appendable out)
                    throws java.io.IOException
Throws:
java.io.IOException

breadcrumbPath

public static java.lang.String breadcrumbPath(java.lang.String urlPrefix,
                                              java.lang.String l)
Same as breadcrumbPath(urlPrefix, l, '/').

See Also:
breadcrumbPath(String, String, char)

breadcrumbPath

public static java.lang.String breadcrumbPath(java.lang.String urlPrefix,
                                              java.lang.String l,
                                              char sep)
Same as breadcrumbPath(urlPrefix, l, sep, "", false).

See Also:
breadcrumbPath(String, String, char, String, boolean)

breadcrumbPath

public static java.lang.String breadcrumbPath(java.lang.String urlPrefix,
                                              java.lang.String l,
                                              char sep,
                                              java.lang.String urlPostfix,
                                              boolean compact)
Create a breadcrumb path to allow navigation to each element of a path.

Parameters:
urlPrefix - what comes before the path in the URL
l - the full path from which the breadcrumb path is built
sep - the character that separates the path elements in l
urlPostfix - what comes after the path in the URL
compact - if true, remove .. and empty path elements from the path in the links
Returns:
HTML markup for the breadcrumb path

redableSize

public static java.lang.String redableSize(long num)

encode

public static java.lang.String encode(java.lang.String s)
Converts different html special characters into their encodings used in html currently used only for tooltips of annotation revision number view

Parameters:
s - input text
Returns:
encoded text for use in tag

readableLine

public static void readableLine(int num,
                                java.io.Writer out,
                                Annotation annotation)
                         throws java.io.IOException
Throws:
java.io.IOException

uid

public static java.lang.String uid(java.lang.String path,
                                   java.lang.String date)
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 () is used both to separate directory components and to separate the path from the date.


uid2url

public static java.lang.String uid2url(java.lang.String uid)

URIEncode

public static java.lang.String URIEncode(java.lang.String q)
wrapper arround UTF-8 URL encoding of a string

Parameters:
q - query to be encoded
Returns:
null if fail, otherwise the encoded string

URIEncodePath

public static java.lang.String URIEncodePath(java.lang.String path)

formQuoteEscape

public static java.lang.String formQuoteEscape(java.lang.String q)

buildQueryString

public static java.lang.String buildQueryString(java.lang.String freetext,
                                                java.lang.String defs,
                                                java.lang.String refs,
                                                java.lang.String path,
                                                java.lang.String hist)
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.

Parameters:
freetext - The string from the "Full Search" text-field. This field will be applied as it is specified.
defs - The string from the "Definition" text-field. This field will be searched for in the defs field in the lucene index. All occurences of ":" will be replaced with "\:"
refs - The string from the "Symbol" text-field. This field will be searched for in the refs field in the lucene index. All occurences of ":" will be replaced with "\:"
path - The string from the "File Path" text-field. This field will be searched for in the path field in the lucene index. All occurences of ":" will be replaced with "\:"
hist - The string from the "History" text-field. This field will be searched for in the hist field in the lucene index. All occurences of ":" will be replaced with "\:"
Returns:
A string to be parsed by the Lucene parser.