Open SiteSearch 4.1.1
Final

ORG.oclc.ecat.util
Class Util

java.lang.Object
  |
  +--ORG.oclc.ecat.util.Util

public class Util
extends Object


Field Summary
static char[] badchars
           
static String badExtensions
           
static Hashtable stopwords
           
static int TRACE_ALL
           
static int TRACE_CALLS
           
static int TRACE_MSGS
           
static int TRACE_NONE
           
static int TRACE_PARMS
           
static int TRACE_READ_MSGS
           
static int TRACE_WRITE_MSGS
           
 
Constructor Summary
Util()
           
 
Method Summary
static String breakdownUrlForBCP(String s)
           
static String breakdownUrlForInsert(String s)
           
static String breakdownUrlForSelect(String s)
           
static Vector breakdownUrlIntoVector(String s)
           
static Vector breakdownUrlIntoVectorAndEscape(String s)
           
static char chop(StringBuffer val)
           
static String collapseBlankLines(String s)
          Remove leading and trailing space from each line, new lines, and blank lines.
static String collapseLines(String s)
          Remove leading and trailing space as well as new lines from each line.
static boolean compareCharArray(char[] s1, int s1start, char[] s2)
           
static int convertClientDateToSeconds(String cdate)
           
static String convertSecondsToYYYYMMDD(int seconds)
           
static String current_hhmmss()
           
static String current_HHmmss()
           
static String current_yyyymmdd()
           
static StringBuffer escapeStringForDbInsertion(String s)
           
static StringBuffer escapeStringForDbInsertionOld(String s)
           
static String findNameValue(String name, String data)
           
static String findNameValue(String name, String data, boolean replace_newlines_with_spaces)
           
static String getCharsUpTo(String s, int max)
          Returns a String terminating at the last space in s before max or <max if s does not contain a space.
static Hashtable getMetadataFrom(String content)
          Generate a Hashtable of metadata in the document.
static Hashtable getMetadataFrom(String content, String lower)
          Generate a Hashtable of metadata in the document.
static int getStemLevel(String db)
           
static String getTitle(String content)
          Get the title from the <TITLE> tag.
static String getTitle(String content, String lower)
          Get the title from the <TITLE> tag.
static int hashCode(String s)
          Returns a hashcode for a string.
static boolean isalpha(char c)
           
static void logMsg(String msg)
           
static void logMsg(String msg, boolean debug)
           
static String makeUniqueIndexableUrl(String s)
           
static String ms2hhmmss_smart(long curTimeMs)
           
static String ms2hhmmss_smart(long curTimeMs, boolean diffOnly)
           
static String ms2hhmmss(long curTimeMs)
           
static int parseTraceLevel(String traceString)
           
static Vector parseUrlString(String s)
           
static void printSQLError(SQLException ex)
           
static void QuickSortStringArray(String[] a, int lo0, int hi0)
          This is a generic version of C.A.R Hoare's Quick Sort algorithm.
static void QuickSortStringVector(Vector a, int lo0, int hi0)
          This is a generic version of C.A.R Hoare's Quick Sort algorithm.
static String removeAllTagsFrom(String content)
           
static String removeBlanksFrom(String content)
          Collapse blanks.
static String removeCharactersAndCharactersInRangeFrom(String content, char[] bad, int start, int stop)
          Replace characters with space.
static String removeCharactersFrom(String content, char[] bad)
          Replace characters with space.
static String removeCharactersInRangeFrom(String content, int start, int stop)
          Replace characters whose ordinal value is between start and stop with space.
static String removeDoctypeFrom(String buf)
          Remove any <DOCTYPE> tags.
static String removeDoctypeFrom(String buf, String lower)
          Remove any <DOCTYPE> tags.
static String removeDot(String s)
          Remove lines that contain the character '.'.
static String removeEntitiesFrom(String content)
           
static String removeLines(String s)
          Remove new lines from the string.
static String removeNumbersFrom(String content)
          Remove any numbers from the string.
static String removeSGMLCommentsFrom(String buf)
           
static String removeStopWordsAndNumbersAndWordsLessThanNCharsFrom(String content, Hashtable stopwords, int n)
          Remove stopwords, numbers and words less than n characters from the string.
static String removeStopWordsAndWordsLessThanNCharsFrom(String content, Hashtable stopwords, int n)
          Remove stopwords and words less than n characters from the string.
static String removeStopWordsFrom(String content, Hashtable stopwords)
          Remove any stopwords form the string.
static String removeWordsLessThanNChars(String content, int n)
          Remove any words with length less than n.
static void sortStringArray(String[] in, int order)
           
static void sortStringVector(Vector in, int order)
           
static String stripAllTagsAndAnchors(String content)
           
static int theNextTagIn(int start_here, int[] res, char[] char_array)
           
static int theNextTagIn(int start_here, int[] res, String mybuf)
           
static String truncateEscapedString(StringBuffer s, int len)
           
static String truncateEscapedUrl(StringBuffer s, int len)
           
static String wrapLines(String s, int w)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE_NONE

public static final int TRACE_NONE

TRACE_CALLS

public static final int TRACE_CALLS

TRACE_PARMS

public static final int TRACE_PARMS

TRACE_MSGS

public static final int TRACE_MSGS

TRACE_READ_MSGS

public static final int TRACE_READ_MSGS

TRACE_WRITE_MSGS

public static final int TRACE_WRITE_MSGS

TRACE_ALL

public static final int TRACE_ALL

badExtensions

public static final String badExtensions

badchars

public static final char[] badchars

stopwords

public static final Hashtable stopwords
Constructor Detail

Util

public Util()
Method Detail

printSQLError

public static final void printSQLError(SQLException ex)

getCharsUpTo

public static final String getCharsUpTo(String s,
                                        int max)
Returns a String terminating at the last space in s before max or <max if s does not contain a space.
Parameters:
s - input string
max - max characters
Returns:
a string terminating at the last space in s before max or <max if s does not contain a space.

collapseLines

public static final String collapseLines(String s)
Remove leading and trailing space as well as new lines from each line.
Parameters:
s - input string
Returns:
the string without newlines and with leading and trailing space removed from each line.

removeLines

public static final String removeLines(String s)
Remove new lines from the string.
Parameters:
s - input string
Returns:
the string without newlines.

collapseBlankLines

public static final String collapseBlankLines(String s)
Remove leading and trailing space from each line, new lines, and blank lines.
Parameters:
s - input string
Returns:
the string without newlines, blank lines and with leading and trailing space removed from each line.

removeDot

public static final String removeDot(String s)
Remove lines that contain the character '.'.
Parameters:
s - input string
Returns:
the string without lines containing '.'.

getTitle

public static final String getTitle(String content)
Get the title from the <TITLE> tag.
Parameters:
content - the document content
Returns:
the document title.

getTitle

public static final String getTitle(String content,
                                    String lower)
Get the title from the <TITLE> tag.
Parameters:
content - the document content
lower - lower case version of the document content (so we don't have to lower case it)
Returns:
the document title.

isalpha

public static final boolean isalpha(char c)

removeSGMLCommentsFrom

public static final String removeSGMLCommentsFrom(String buf)

removeDoctypeFrom

public static final String removeDoctypeFrom(String buf)
Remove any <DOCTYPE> tags.
Parameters:
content - the document content
Returns:
the document with <DOCTYPE> tags removed.

removeDoctypeFrom

public static final String removeDoctypeFrom(String buf,
                                             String lower)
Remove any <DOCTYPE> tags.
Parameters:
content - the document content
lower - lower case version of the document content (so we don't have to lower case it)
Returns:
the document with <DOCTYPE> tags removed.

theNextTagIn

public static final int theNextTagIn(int start_here,
                                     int[] res,
                                     String mybuf)

theNextTagIn

public static final int theNextTagIn(int start_here,
                                     int[] res,
                                     char[] char_array)

stripAllTagsAndAnchors

public static final String stripAllTagsAndAnchors(String content)

getMetadataFrom

public static final Hashtable getMetadataFrom(String content)
Generate a Hashtable of metadata in the document.
Parameters:
content - the document content
Returns:
a hashtable of metadata in the document.

getMetadataFrom

public static final Hashtable getMetadataFrom(String content,
                                              String lower)
Generate a Hashtable of metadata in the document.
Parameters:
content - the document content
lower - lower case version of the document content (so we don't have to lower case it)
Returns:
a hashtable of metadata in the document.

removeAllTagsFrom

public static final String removeAllTagsFrom(String content)

removeBlanksFrom

public static final String removeBlanksFrom(String content)
Collapse blanks.
Parameters:
content - the document content
Returns:
this string with blanks collapsed to a single blank.

removeStopWordsFrom

public static final String removeStopWordsFrom(String content,
                                               Hashtable stopwords)
Remove any stopwords form the string.
Parameters:
content - the document content
stopwords - stopwords to be removed
Returns:
this string with stopwords removed

removeWordsLessThanNChars

public static final String removeWordsLessThanNChars(String content,
                                                     int n)
Remove any words with length less than n.
Parameters:
content - the document content
n - maximum length of words to be removed
Returns:
this string with words with length less than n removed.

removeNumbersFrom

public static final String removeNumbersFrom(String content)
Remove any numbers from the string.
Parameters:
content - the document content
Returns:
this string with numbers removed.

removeStopWordsAndNumbersAndWordsLessThanNCharsFrom

public static final String removeStopWordsAndNumbersAndWordsLessThanNCharsFrom(String content,
                                                                               Hashtable stopwords,
                                                                               int n)
Remove stopwords, numbers and words less than n characters from the string.
Parameters:
content - the document content
n - the maximum length of words to be removed
Returns:
the processed string

removeStopWordsAndWordsLessThanNCharsFrom

public static final String removeStopWordsAndWordsLessThanNCharsFrom(String content,
                                                                     Hashtable stopwords,
                                                                     int n)
Remove stopwords and words less than n characters from the string.
Parameters:
content - the document content
n - the maximum length of words to be removed
Returns:
the processed string

removeCharactersFrom

public static final String removeCharactersFrom(String content,
                                                char[] bad)
Replace characters with space.
Parameters:
content - the document content
bad - characters to be removed
Returns:
this string with characters in bad_chars replaced by space.

removeCharactersInRangeFrom

public static final String removeCharactersInRangeFrom(String content,
                                                       int start,
                                                       int stop)
Replace characters whose ordinal value is between start and stop with space.
Parameters:
content - the document content
start - the ordinal value to start at
stop - the ordinal value to stop at
Returns:
this string with characters in replaced by space.

removeCharactersAndCharactersInRangeFrom

public static final String removeCharactersAndCharactersInRangeFrom(String content,
                                                                    char[] bad,
                                                                    int start,
                                                                    int stop)
Replace characters with space. Does not work on letters and numbers
Parameters:
content - the document content
bad - characters to be removed
start - the ordinal value to start at
stop - the ordinal value to stop at
Returns:
this string with characters in bad_chars replaced by space.

removeEntitiesFrom

public static final String removeEntitiesFrom(String content)

parseUrlString

public static final Vector parseUrlString(String s)

convertClientDateToSeconds

public static final int convertClientDateToSeconds(String cdate)

convertSecondsToYYYYMMDD

public static final String convertSecondsToYYYYMMDD(int seconds)

hashCode

public static final int hashCode(String s)
Returns a hashcode for a string. Borrowed algorithm from java.lang.String in JDK 1.2b2 to protect against possible future changes like the change from an earlier release of Java.
Returns:
a hash code value for this object.

makeUniqueIndexableUrl

public static final String makeUniqueIndexableUrl(String s)

breakdownUrlForSelect

public static final String breakdownUrlForSelect(String s)

breakdownUrlIntoVectorAndEscape

public static final Vector breakdownUrlIntoVectorAndEscape(String s)

breakdownUrlIntoVector

public static final Vector breakdownUrlIntoVector(String s)

breakdownUrlForInsert

public static final String breakdownUrlForInsert(String s)

breakdownUrlForBCP

public static final String breakdownUrlForBCP(String s)

escapeStringForDbInsertionOld

public static final StringBuffer escapeStringForDbInsertionOld(String s)

escapeStringForDbInsertion

public static final StringBuffer escapeStringForDbInsertion(String s)

truncateEscapedUrl

public static final String truncateEscapedUrl(StringBuffer s,
                                              int len)

truncateEscapedString

public static final String truncateEscapedString(StringBuffer s,
                                                 int len)

logMsg

public static final void logMsg(String msg,
                                boolean debug)

logMsg

public static final void logMsg(String msg)

findNameValue

public static final String findNameValue(String name,
                                         String data)

findNameValue

public static final String findNameValue(String name,
                                         String data,
                                         boolean replace_newlines_with_spaces)

sortStringVector

public static final void sortStringVector(Vector in,
                                          int order)

sortStringArray

public static final void sortStringArray(String[] in,
                                         int order)

wrapLines

public static final String wrapLines(String s,
                                     int w)

parseTraceLevel

public static final int parseTraceLevel(String traceString)

QuickSortStringArray

public static final void QuickSortStringArray(String[] a,
                                              int lo0,
                                              int hi0)
This is a generic version of C.A.R Hoare's Quick Sort algorithm. This will handle arrays that are already sorted, and arrays with duplicate keys.
If you think of a one dimensional array as going from the lowest index on the left to the highest index on the right then the parameters to this function are lowest index or left and highest index or right. The first time you call this function it will be with the parameters 0, a.length - 1.
Parameters:
a - a String array
lo0 - left boundary of array partition
hi0 - right boundary of array partition

QuickSortStringVector

public static final void QuickSortStringVector(Vector a,
                                               int lo0,
                                               int hi0)
This is a generic version of C.A.R Hoare's Quick Sort algorithm. This will handle arrays that are already sorted, and arrays with duplicate keys.
If you think of a one dimensional array as going from the lowest index on the left to the highest index on the right then the parameters to this function are lowest index or left and highest index or right. The first time you call this function it will be with the parameters 0, a.length - 1.
Parameters:
a - a String array
lo0 - left boundary of array partition
hi0 - right boundary of array partition

getStemLevel

public static final int getStemLevel(String db)

compareCharArray

public static final boolean compareCharArray(char[] s1,
                                             int s1start,
                                             char[] s2)

chop

public static final char chop(StringBuffer val)

current_yyyymmdd

public static String current_yyyymmdd()

current_hhmmss

public static String current_hhmmss()

current_HHmmss

public static String current_HHmmss()

ms2hhmmss

public static String ms2hhmmss(long curTimeMs)

ms2hhmmss_smart

public static String ms2hhmmss_smart(long curTimeMs)

ms2hhmmss_smart

public static String ms2hhmmss_smart(long curTimeMs,
                                     boolean diffOnly)

Open SiteSearch 4.1.1
Final