|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object be.destin.util.Util
public class Util
Functions for different small treatments (mainly starting from a String)
Constructor Summary | |
---|---|
Util()
|
Method Summary | |
---|---|
static java.lang.String |
escapeDot(java.lang.String buf)
Escapes characters for safe labels in DOT language (GraphWiz.org) |
static java.lang.String |
escapeHTMLEntities(java.lang.String buf)
Escapes XML entities in a HTML-compatible way (i.e. does not escape entities that are already escaped). |
static java.lang.String |
escapeJavaScript(java.lang.String buf)
Escapes characters for safe JavaScript strings |
static java.lang.String |
fileIdentificationNormalize(java.lang.String aValue)
Normalize file names so they don't differ too much from one OS to another Windows "\" become "/" TODO: Other rules? |
static java.lang.String |
firstUp(java.lang.String name)
If a letter is the very first character, puts it in Upper case. |
static java.lang.String |
fixColumns(java.lang.String aValue,
int columns)
Left align a String in a fixed number of columns for HTML output ( used as a filler) |
static java.lang.String |
formatLong(long sortKey)
Makes a long number sortable as a string of characters. |
static java.lang.String |
glue(java.lang.String[] toGlue,
java.lang.String delim)
Glue an array of strings (lines) into one string |
static java.util.LinkedHashSet<java.lang.String> |
hashStrings(java.lang.String[] anArray)
Convert an array of String in a LinkedHashSet of String |
static java.lang.String |
highlight(java.lang.String text,
java.lang.String[] QUERIES)
Highlight a text based on the words from a query. |
static int |
magnitude(long num,
int basis)
Number of digits for a number written in the given basis |
static void |
melt(java.lang.StringBuffer buf,
java.lang.String toMelt)
Ensures the last non alphanum character in buf is not repeated when adding toMelt For instance, to put a dot at the end of a sentence without possible repetition: met(title,". ") will add ". " but without repeating a dot which may already ends the current title. |
static java.lang.String |
noAccent(java.lang.String input)
Removes all accent over (under) letters |
static java.lang.String |
noDoubleSpace(java.lang.String aValue)
Removes double (and more) spaces within a String + spaces at beginning or end of the String. |
static java.lang.String |
noHTMLLink(java.lang.String input)
Removes HTML links from a String ( |
static java.lang.String |
noLuceneJoker(java.lang.String input)
Removes Lucene joker characters when doing an exact match search |
static java.lang.String |
noPlural(java.lang.String word)
Brings a word with more than 3 letters to its singular form. |
static char |
noSingleAccent(char c)
This (incorrect) version takes ONE character and removes its accents. |
static java.lang.String |
noSingleAccent(java.lang.String input)
Use noSingleAccent for each character in a String. |
static java.lang.String[] |
prepareHighlight(java.lang.String query,
boolean byPieces)
Prepares an array of queried words to help later highlight of text displayed |
static void |
printStack(java.lang.Exception e)
Prints in System.out (Tomcat stdout logs) the current stack when an exception was thrown |
static java.lang.String |
replaceAllNoRegExp(java.lang.String aInput,
java.lang.String aOldPattern,
java.lang.String aNewPattern)
Equivalent to string.replaceAll but without regular expressions |
static int |
searchBuffer(byte[] buffer,
int len,
byte[] pattern,
int base)
Search a byte array buffer for a byte array pattern, from a base position. |
static java.util.LinkedList<java.lang.String> |
sentenceSplitter(java.lang.String input)
Splits a String in a list of sentences, based on the punctuation. |
static java.util.LinkedList<java.lang.String> |
singularWordSplitter(java.lang.String input)
Creates a sequential list of words (brought to singular form) |
static boolean |
string2bool(java.lang.String aString,
boolean defBool)
Converts a String to boolean: "true" = true, "false" = false. |
static int |
string2int(java.lang.String aString,
int defInt)
Converts a String to int. |
static java.util.LinkedList<java.lang.String> |
wordSplitter(java.lang.String input)
Creates a sequential list of words |
static java.lang.String[] |
wordWrap(java.lang.String input,
int maxWidth)
Wraps a string into a string array representing lines of about maxWidth characters (words are not cut) |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Util()
Method Detail |
---|
public static boolean string2bool(java.lang.String aString, boolean defBool)
aString
- string to be encoded in booldefBool
- default value if string is null, empty or invalid
public static int string2int(java.lang.String aString, int defInt)
aString
- string to be parsed indefInt
- default value if string is null, empty or invalid
public static java.lang.String escapeHTMLEntities(java.lang.String buf)
buf
- Input string
public static java.lang.String escapeJavaScript(java.lang.String buf)
buf
- Input string
public static java.lang.String escapeDot(java.lang.String buf)
buf
- Input string
public static java.lang.String replaceAllNoRegExp(java.lang.String aInput, java.lang.String aOldPattern, java.lang.String aNewPattern)
aInput
- Input stringaOldPattern
- String to be replaced. Cannot be empty.aNewPattern
- Replacement string
public static void printStack(java.lang.Exception e)
e
- thrown exceptionpublic static java.lang.String noDoubleSpace(java.lang.String aValue)
aValue
- Input String
public static java.lang.String fileIdentificationNormalize(java.lang.String aValue)
aValue
- File name to be normalized
public static java.lang.String fixColumns(java.lang.String aValue, int columns)
aValue
- Input Stringcolumns
- Number of columns
public static java.lang.String[] prepareHighlight(java.lang.String query, boolean byPieces)
query
- String with the current Query wordsbyPieces
- true if each word is searched independently
public static java.lang.String highlight(java.lang.String text, java.lang.String[] QUERIES)
text
- Text to analyzeQUERIES
- String array prepared by method prepareHighlight
<font color="red">
added around highlighted text
TODO: parameterize the highlight markuppublic static java.lang.String noAccent(java.lang.String input)
input
- Input String
public static java.lang.String noLuceneJoker(java.lang.String input)
input
- Input String
public static java.lang.String noPlural(java.lang.String word)
word
- Input String
public static java.lang.String noSingleAccent(java.lang.String input)
input
- Input String to process one character at a time
public static char noSingleAccent(char c)
c
- character to process
public static java.util.LinkedList<java.lang.String> wordSplitter(java.lang.String input)
input
- Input String
public static java.util.LinkedList<java.lang.String> sentenceSplitter(java.lang.String input)
input
- InputString
public static java.util.LinkedList<java.lang.String> singularWordSplitter(java.lang.String input)
input
- Input String
public static java.lang.String noHTMLLink(java.lang.String input)
input
- HTML Input String
public static java.lang.String formatLong(long sortKey)
sortKey
- long number to convert
public static int magnitude(long num, int basis)
num
- Number to be sizedbasis
- (1 or less is treated as 10)
public static void melt(java.lang.StringBuffer buf, java.lang.String toMelt)
met(title,". ")
will add ". " but without repeating a dot which may already ends the current title.
buf
- StringBuffer receiving new pieces of texttoMelt
- String to addpublic static java.lang.String glue(java.lang.String[] toGlue, java.lang.String delim)
toGlue
- String Array of the lines to "glue"delim
- String inserted between each line (array element)
public static java.lang.String[] wordWrap(java.lang.String input, int maxWidth)
input
- Input StringmaxWidth
- Approximate width of a line
public static java.util.LinkedHashSet<java.lang.String> hashStrings(java.lang.String[] anArray)
anArray
- String Array to convert
public static java.lang.String firstUp(java.lang.String name)
name
- Input String
public static int searchBuffer(byte[] buffer, int len, byte[] pattern, int base)
buffer
- len
- End of the buffer part to searchpattern
- Byte array with pattern to search. (if empty, search fails)base
- Position in the buffer where the search starts (0 is the first buffer position)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |