org.opensolaris.opengrok.web
Class Util

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

public class Util
extends java.lang.Object

File for useful functions


Constructor Summary
Util()
           
 
Method Summary
static java.lang.String breadcrumbPath(java.lang.String urlPrefix, java.lang.String l)
           
static java.lang.String breadcrumbPath(java.lang.String urlPrefix, java.lang.String l, char sep)
           
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 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)
          Return a string which represents a CharSequence in HTML.
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)
           
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
 

Constructor Detail

Util

public Util()
Method Detail

Htmlize

public static java.lang.String Htmlize(java.lang.CharSequence q)
Return a string which represents a CharSequence in HTML.

Parameters:
q - a character sequence
Returns:
a string representing the character sequence in HTML

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)

breadcrumbPath

public static java.lang.String breadcrumbPath(java.lang.String urlPrefix,
                                              java.lang.String l,
                                              char sep)

redableSize

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

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)

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.