kernel
Class Tools

java.lang.Object
  extended by kernel.Tools

public class Tools
extends Object

This class provides some useful static methods that can be used by plugins.

Author:
Michel Deriaz

Method Summary
static String accentsToHtml(String input)
          Converts accentuated letters to their html form.
static String accentsToIso(String input)
          Converts accentuated letters to their iso form.
static void getFilesRec(ArrayList<File> allFiles, File root, boolean includesDir)
          Gets recursively all the files from a given root directory.
static PropertyResourceBundle getPrb(String baseName, String language)
          Gets the PropertyResourceBundle that corresponds to the specified language or the default one if the requested language is not available.
static String htmlToAccents(String input)
          Converts html-formed letters to accentuated letters.
static String isoToAccents(String input)
          Converts iso-formed letters to accentuated letters.
static String noAccents(String input)
          Replaces all accentuated letters (even given in their html or iso form) by their non-accentuated corresponding letters.
static String readFile(String filename)
          Reads a file and returns its content in a String.
static String removeAccents(String input)
          Removes the accents on accentuated letters.
static ArrayList<String> sort(ArrayList<String> list, boolean reverseOrder, boolean caseInsensitive)
          Sorts an ArrayList of Strings.
static String sort(String text, boolean reverseOrder, boolean caseInsensitive)
          Sorts de lines of a text.
static void writeFile(String filename, String text)
          Writes a text in a file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getPrb

public static PropertyResourceBundle getPrb(String baseName,
                                            String language)
Gets the PropertyResourceBundle that corresponds to the specified language or the default one if the requested language is not available.

Parameters:
baseName - base name of the resource bundle
language - the ISO 639-1 code of the language
Returns:
the best available PropertyResourceBundle or null if none is available

getFilesRec

public static void getFilesRec(ArrayList<File> allFiles,
                               File root,
                               boolean includesDir)
Gets recursively all the files from a given root directory.

Parameters:
allFiles - the list that will be filled with the files
root - the root directory
includesDir - if true, includes also the directories

readFile

public static String readFile(String filename)
Reads a file and returns its content in a String.

Parameters:
filename - the file to be read
Returns:
the content of the file, or null if the file does not exist

writeFile

public static void writeFile(String filename,
                             String text)
Writes a text in a file.

Parameters:
filename - the name of the file
text - the content of the file

sort

public static String sort(String text,
                          boolean reverseOrder,
                          boolean caseInsensitive)
Sorts de lines of a text.

Parameters:
text - the text to be sorted
reverseOrder - true if the sorting has to be done in reverse order, false else
caseInsensitive - true if the sorting has to be done without taking care about the case, false else
Returns:
a sorted text

sort

public static ArrayList<String> sort(ArrayList<String> list,
                                     boolean reverseOrder,
                                     boolean caseInsensitive)
Sorts an ArrayList of Strings.

Parameters:
list - the list to be sorted
reverseOrder - true if the sorting has to be done in reverse order, false else
caseInsensitive - true if the sorting has to be done without taking care about the case, false else
Returns:
a sorted list

accentsToHtml

public static String accentsToHtml(String input)
Converts accentuated letters to their html form.

Parameters:
input - the input text
Returns:
the input text with all the accentuated letters converted to their html form
See Also:
htmlToAccents(String)

htmlToAccents

public static String htmlToAccents(String input)
Converts html-formed letters to accentuated letters.

Parameters:
input - the input text
Returns:
the input text with all the html-formed letters converted to accentuated letters
See Also:
accentsToHtml(String)

accentsToIso

public static String accentsToIso(String input)
Converts accentuated letters to their iso form.

Parameters:
input - the input text
Returns:
the input text with all the accentuated letters converted to their iso form
See Also:
isoToAccents(String)

isoToAccents

public static String isoToAccents(String input)
Converts iso-formed letters to accentuated letters.

Parameters:
input - the input text
Returns:
the input text with all the iso-formed letters converted to accentuated letters
See Also:
accentsToIso(String)

removeAccents

public static String removeAccents(String input)
Removes the accents on accentuated letters.

Parameters:
input - the input text
Returns:
the input text without accents

noAccents

public static String noAccents(String input)
Replaces all accentuated letters (even given in their html or iso form) by their non-accentuated corresponding letters.

Parameters:
input - the input text
Returns:
the input text without accents, even accents given in their html or iso form