public class StringHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ALPHABET |
static String |
ALPHABET_UPPER_CASE |
static String |
ALPHANUM |
static String |
BASIC_CHAR |
static String |
DEFAULT_LIST_SEPARATOR |
static String |
DEFAULT_SEPARATOR |
static String[] |
EMPTY_STRING_ARRAY |
protected static Logger |
logger
create a static logger.
|
static String |
NUMERIC |
static Pattern |
RANGE_MATCHER_BETWEEN |
static Pattern |
RANGE_MATCHER_GREATER |
static Pattern |
RANGE_MATCHER_LOWER |
static String |
REQUEST_KEY_FORM_VALID |
static SimpleDateFormat |
RFC822DATEFORMAT |
static String |
SOMETHING |
static String |
specialChar |
static long |
TIMED_TOKEN_DIVIDER |
static String[][] |
TXT2HTML |
Constructor and Description |
---|
StringHelper() |
Modifier and Type | Method and Description |
---|---|
static String |
addSufixToFileName(String fileName,
String sufix) |
static String |
arrayToString(Object[] array) |
static String |
arrayToString(Object[] array,
String inSep) |
static String |
asBase32(byte value)
generate a base 32 string with a int
|
static String |
asBase32(byte[] bytes)
generate a base 32 string.
|
static String |
asBase32(int value)
generate a base 32 string with a int
|
static String |
asBase64(byte[] bytes)
generate a base 64 string.
|
static String |
asBase64(int value)
generate a base 64 string with a int
|
static String |
asBase64(long value)
generate a base 64 string with a long
|
static String |
changeFileExtension(String inFileName,
String newExt)
change the file extension of the path
|
static String |
cleanPath(String path)
clean path, remove double "/" and replace "\" by "/"
|
String |
cleanString(String text) |
static <T extends IStringSeralizable> |
collectionStringSeralizableToString(Collection<T> col,
String sep) |
static String |
collectionToString(Collection<?> col) |
static String |
collectionToString(Collection<?> col,
String inSep) |
static String |
collectionToString(String... values) |
static String |
collectionToText(Collection<?> col)
convert a collection to text.
|
static String |
colorToHexString(Color color) |
static String |
colorToHexStringNotNull(Color color) |
static boolean |
compare(String str1,
String str2) |
static boolean |
containsUppercase(String text)
check if a text contains uppercase char. test > false, Test > true, TEST
> true
|
static String |
convertString(String pattern1,
String pattern2,
String text)
convert a string to another string if math pattern1 and convert to
pattern2. pattern is a String with one '*' for any characters. sample :
/*, /test/*, /view/fr --> /test/view/fr
|
static int |
countChar(String str,
char c) |
static String |
CR2BR(String text)
replace CR with
|
static String |
createASCIIString(String text) |
static String |
createFileName(String fileName)
convert a file name with space, accent and other bad character to a
acceptable name. sample: "l'éléphant rose.odt" ->
"l_elephant_rose.odt"
|
static String |
createI18NURL(String value) |
static String |
createKey(int length,
Set<String> keys)
create a new unic key.
|
static String |
CRtoSpace(String text)
replace CR with a space
|
static String |
cutEndXHTML(String str,
int cut)
cut the end of a xhtml code. sample: "aaa´coucou", 5 =
"aaa´c"
|
static byte[] |
decodeBase64(String data)
generate a base 64 string.
|
static String |
decodeNoChar(String data,
String noChars)
insert char from a Sting (encoded with encodeNoChar)
|
static String |
encodeAsStructuredCommunicationMod97(String code)
transform a string of number (length 10) to a structured communication,
last number is the mod 97 of the first number
|
static String |
encodeCDATA(String value)
encode a string to a CDATA sequence.
|
static String |
encodeNoChar(String data,
String noChars)
remove char from a Sting
|
static String |
encryptPassword(String plaintext) |
static String |
encryptPasswordSHA256(String plaintext) |
static String |
escapeHTML(String html) |
static String |
escapeProperty(String theString,
boolean escapeSpace,
boolean escapeUnicode)
Method copied from the private method
java.util.Properties#saveConvert(...)
|
static String |
escapeWordChar(String text) |
static String |
expandSystemProperties(String str) |
static String |
extractHost(String inUrl) |
static List<String> |
extractItem(String text,
String prefix,
String suffix)
extract a subtext from a text. sample : Hi patrick how are you ?
|
static String |
firstLetterLower(String string) |
static String |
firstLetterUpper(String string) |
static String |
frameTokenCaseUnsensitive(String str,
String token,
String prefix,
String sufix)
split a String, if there are no character between two token this method
place a empty String ( !
|
static String |
getColName(int colIndex) |
static int |
getColNum(String colName) |
static long |
getCRC32(String text) |
static String |
getDateRandomId()
return a ID contruct on with the current date : sample : 20101223-4687
|
static String |
getDateRandomIdWithCheck()
return a ID contruct on with the current date : sample : 20101223-4687
|
static int |
getDigitMod9(String value) |
static String |
getDirNameFromPath(String path) |
static String |
getFileExtension(String inFileName)
retreive the file extension.
|
static String |
getFileNameFromPath(String path)
retreive the file extension.
|
static String |
getFileNameWithoutExtension(String inFileName)
retreive the file extension.
|
static String |
getFileSize(String filePath)
return a formated size in a String.
|
static String |
getFirstNotNull(String value1,
String value2) |
static String |
getItem(String text,
String sep,
int i,
String defaultValue)
get the item from a string with separator. sample : text1,text2,text3
getItem(sample,",",1) = text1
|
static String |
getLanguageFromFileName(String filename) |
static String |
getLargeRandomIdBase64()
generate a id in a String.
|
static String |
getNewToken() |
static String |
getNumberAsAlphabetic(int number) |
static String |
getPathType(String path,
String prefix)
return the type of a path (video, image...)
|
static Integer |
getPixelValue(String pxSize)
transform a string with size in pixel in integer.
|
static String |
getPropertieskey(String key) |
static String |
getRandomId() |
static String |
getRandomIdBase10()
generate a id in a String.
|
static String |
getRandomIdBase64()
generate a id in a String.
|
static String |
getRandomString(int lenght) |
static String |
getRandomString(int lenght,
String acceptedChars) |
static String |
getShortRandomId()
return a short id (length 10 chars).
|
static String |
hex(byte[] array) |
static String |
html2txt(String html) |
static int |
htmlSize(String str)
retreive the size of a String with html code. sample: "aaa´" = 4.
|
static boolean |
isAllEmpty(Object... values) |
static boolean |
isAlpha(String str)
check if stirng contains only digital number
|
static boolean |
isCharset(byte[] b,
String inCharset) |
static boolean |
isDigit(char c) |
static boolean |
isDigit(String str)
check if stirng contains only digital number
|
static boolean |
isDoc(String fileName)
return true if the filename in a document (sp. : word, libreoffice...).
|
static boolean |
isEditable(String fileName)
return true if the filename in a image for wcms (sp. : tif or psd in not
a image).
|
static boolean |
isEditableExtension(String fileExtension) |
static boolean |
isEmpty(Object value) |
static boolean |
isExcelFile(String fileName)
return true if the filename in a image for wcms (sp. : tif or psd in not
a image).
|
static boolean |
isFloat(String str) |
static boolean |
isHTML(String fileName)
return true if the filename in a html image).
|
static boolean |
isHTMLStatic(String fileName) |
static boolean |
isImage(String fileName)
return true if the filename in a image for wcms (sp. : tif or psd in not
a image).
|
static boolean |
isImageExtension(String fileExtension)
return true if the file extension is an image for wcms (sp. : tif or psd
is not an image).
|
static boolean |
isJpeg(String fileName)
return true if the filename in a image for wcms (sp. : tif or psd in not
a image).
|
static boolean |
isJpgExtension(String fileExtension)
return true if the file extension is an image for wcms (sp. : tif or psd
is not an image).
|
static boolean |
isLetter(char c) |
static boolean |
isLikeNumber(String str)
check if string contains somthing similar to digital number
|
static boolean |
isMail(String email) |
static boolean |
isMailURL(String url) |
static boolean |
isOneEmpty(Object... values) |
static boolean |
isPasswordMath(String pwdData,
String userInput,
boolean crypted) |
static boolean |
isPDF(String fileName)
return true if the filename in a PDF file.
|
static boolean |
isPhoneNumber(String phone) |
static boolean |
isProperties(String fileName) |
static boolean |
isSound(String fileName)
return true if the filename in a sound file image.
|
static boolean |
isTrue(Object inBool) |
static boolean |
isTrue(Object inBool,
boolean defaultValue) |
static boolean |
isTrue(String bool,
boolean defaultValue) |
static boolean |
isURL(String url) |
static boolean |
isURLFile(String fileName)
return true if the filename in a url file).
|
static boolean |
isVAT(String vat) |
static boolean |
isVideo(String fileName)
return true if the filename in a video file image).
|
static boolean |
listContainsItem(String list,
String sep,
String item) |
static void |
main(String[] args) |
static String |
mapToString(Map<String,String> maps) |
static boolean |
matchQuestionPattern(String str,
String pattern)
Test if a string match with a pattern using '?'.
|
static boolean |
matchSimplePattern(String str,
String pattern,
boolean ignoreCase)
Test if a string match with a pattern using '?'
|
static boolean |
matchStarPattern(String str,
String pattern)
Test if a string match with a pattern using stars (*).
|
static String |
md5(String message) |
static String |
md5Hex(String message) |
static String |
neverEmpty(String inStr,
String replaceWith)
transform a string empty to a other string
|
static String |
neverNull(Object inStr)
transform a string null in a empty String.
|
static String |
neverNull(Object inStr,
String replaceWith)
transform a string null in a empty String.
|
String |
noRepeatChar(String text,
char chr) |
static String |
normalizePhoneNumber(String phone,
String countryPrefix)
format number to number like : +32486123456
|
static String |
onlyAlphaNumeric(String data,
boolean stopOnBadChar) |
static Color |
parseColor(String color)
parse error without fault, return null if color is unidentified.
|
static Date |
parseDate(String inDate) |
static Date |
parseDate(String inDate,
char sep) |
static Date |
parseDate(String inDate,
String pattern) |
static Date |
parseDateOrTime(String inDate) |
static Date |
parseDateTime(String inDate,
char sep) |
static Date |
parseFileTime(String fileTime) |
static int |
parseInt(String value,
int defaultValue)
null save parse int.
|
static Date |
parseIso8601(String input) |
static Date[] |
parseRangeDate(String date) |
static Date |
parseSecondFileTime(String fileTime) |
static Date |
parseSortableDate(String date) |
static Date |
parseSortableTime(String date) |
static Date |
parseTime(String inDate) |
static Date |
parseTimeOnly(String inDate) |
static String |
propertiesToString(Properties p) |
static String |
quote(String string) |
static boolean |
rangeMatches(String range,
Integer value)
Test if the value is included in the range.
|
static String[] |
readLines(String text) |
static String |
removeAccents(String textWithAccent) |
static String |
removeCR(String text)
remove CR from a String
|
static String |
removeFirstChar(String txt,
char c) |
static String |
removeNumber(String text) |
static String |
removeQuote(String text)
remote " on the start and the end of text, if quote was found.
|
static String |
removeRepeatedChar(String str) |
static String |
removeRepeatedChar(String str,
char c)
remove repeated char inside string. sample : "javlo--love" "-" =
"javlo-love".
|
static String |
removeSequence(String text,
String prefix,
String sufix)
remove sequence from a string. sample : removeSequence ("slkqfj #dlskj#
sdljf", "#", "#") -> slkqfj sdljf.
|
static String |
removeSpecialChars(char c) |
static String |
removeSpecialChars(String text) |
static String |
removeTag(String text)
remove tag. sample: link -> link
|
static String |
renderDate(Date date) |
static String |
renderDate(Date date,
String pattern) |
static String |
renderDate(Locale locale,
Date date,
String pattern) |
static String |
renderDateAsRFC822String(Date date) |
static String |
renderDateWithDefaultValue(Date date,
String defaultValue) |
static String |
renderDouble(double value,
int precision) |
static String |
renderDouble(double value,
int precision,
char sep) |
static String |
renderDouble(double value,
Locale locale) |
static String |
renderDoubleAsPercentage(double value) |
static String |
renderFileTime(Date date) |
static String |
renderFullDate(ContentContext ctx,
Date date) |
static String |
renderLightDate(Date date) |
static String |
renderMediumDate(ContentContext ctx,
Date date) |
static String |
renderMonthDate(ContentContext ctx,
Date date) |
static String |
renderNumber(int n,
int size) |
static String |
renderOnlyTime(Date date) |
static String |
renderPrice(double price,
String currency) |
static String |
renderSecondFileTime(Date date) |
static String |
renderShortDate(ContentContext ctx,
Date date)
render a date, search the format in I18n files.
|
static String |
renderShortDateWidthDay(ContentContext ctx,
Date date) |
static String |
renderShortTime(ContentContext ctx,
Date date) |
static String |
renderSize(long size)
return a formated size in a String.
|
static String |
renderSortableDate(Date date) |
static String |
renderSortableTime(Date date) |
static String |
renderTime(ContentContext ctx,
Date date) |
static String |
renderTime(Date date) |
static String |
renderTimeInSecond(long time) |
static String |
renderTimeOnly(Date date) |
static String |
renderUserFriendlyDate(ContentContext ctx,
Date date)
render a date, search the format in I18n files.
|
static String |
renderUserFriendlyDate(Date date) |
static String |
renderUserFriendlyDate(Locale locale,
Date date) |
static String |
renderUserFriendlyTime(Date date) |
static String |
replaceCR(String text,
String separator) |
static Double |
safeParseDouble(String string,
Double defaultValue) |
static Integer |
safeParseInt(String string,
Integer defaultValue) |
static Long |
safeParseLong(String string,
Long defaultValue) |
static Collection<String> |
searchEmail(String text)
extract email from a free text
|
static List<URL> |
searchLinks(String text)
extract external link from a free text
|
static Collection<javax.mail.internet.InternetAddress> |
searchStructuredEmail(String text)
extract email from a free text
|
static Date |
smartParseDate(String inDate) |
static Date |
smartParseDateTime(String inDate) |
static String |
sortText(String text)
sort line of a text
|
static String[] |
split(String str,
String token)
split a String, if there are no character between two token this method
place a empty String ( !
|
static String[] |
splitStaySeparator(String str,
char token)
split a String, if there are no character between two token this method
place a empty String ( !
|
static String[] |
splitStaySeparator(String str,
String token)
split a String, if there are no character between two token this method
place a empty String ( !
|
static int |
stringInArray(String[] array,
String token) |
static String[] |
stringToArray(String str) |
static String[] |
stringToArray(String str,
String token) |
static String[] |
stringToArrayRemoveEmpty(String str) |
static List<String> |
stringToCollection(String str) |
static List<String> |
stringToCollection(String str,
String token) |
static List<String> |
stringToCollection(String str,
String token,
boolean trim) |
static Collection<? extends String> |
stringToCollectionRemoveEmpty(String addRolesAsRaw) |
static List<String> |
stringToCollectionTrim(String str) |
static List<String> |
stringToCollectionTrim(String str,
String token) |
static String |
stringToFileName(String inStr) |
static Map<String,String> |
stringToMap(String encodedMap) |
static Set<String> |
stringToSet(String str) |
static Set<String> |
stringToSet(String str,
String sep) |
static <T extends IStringSeralizable> |
stringToStringSeralizableCollection(String data,
String sep,
Class c) |
static String |
stringWithoutSpecialChar(String inStr) |
static String |
textToList(GlobalContext globalContext,
String text,
String sep,
String layout,
boolean autoLink) |
static String |
textToList(GlobalContext globalContext,
String text,
String sep,
String layout,
boolean autoLink,
String ulClass) |
static List<String> |
textToList(String text) |
static String |
timedTokenGenerate(String data,
long timeInMillis) |
static boolean |
timedTokenValidate(String tokenData,
String orignalData,
int validityRangeInMinutes,
long timeInMillis) |
static String |
toHTMLAttribute(String value)
transform a free value to a attribute xml value
|
static String |
toJSString(String inStr)
transform a String to insert in a JavaScript.
|
static String |
toLatin(String text)
convert to latin alphabet
|
static String |
toMaxSize(String str,
int size,
String sufix)
transform a String to a max size. sample: "Welcome in the new wave party"
--> "Welcome in the..."
|
static String |
toXMLAttribute(String value)
transform a free value to a attribute xml value
|
static String |
trim(String text,
char trimChar)
replace trimChar at the start and the end of text string. sample :
--test-, - >>> test
|
static String |
trimAndNullify(String str) |
static String |
trimLineReturn(String string) |
static List<String> |
trimList(Collection<String> list)
trim all items of the list.
|
static String |
trimOn(String inText,
String token) |
static String |
trimSpaceAndUnderscore(String inText) |
static String |
txt2html(String text) |
static String |
txt2htmlCR(String text)
replace CR with
and replace special char to html code |
static Map<String,String> |
uriParamToMap(String uri) |
static boolean |
validUTF8(byte[] input) |
static String |
writeLines(String... text) |
protected static Logger logger
public static final String SOMETHING
public static final String REQUEST_KEY_FORM_VALID
public static final String ALPHABET
public static final String ALPHABET_UPPER_CASE
public static final String NUMERIC
public static final String BASIC_CHAR
public static final String ALPHANUM
public static String specialChar
public static String DEFAULT_SEPARATOR
public static final String[][] TXT2HTML
public static SimpleDateFormat RFC822DATEFORMAT
public static final String DEFAULT_LIST_SEPARATOR
public static final String[] EMPTY_STRING_ARRAY
public static final Pattern RANGE_MATCHER_LOWER
public static final Pattern RANGE_MATCHER_BETWEEN
public static final Pattern RANGE_MATCHER_GREATER
public static final long TIMED_TOKEN_DIVIDER
public static String asBase64(byte[] bytes)
public static String asBase32(int value)
public static String asBase32(byte value)
public static String asBase32(byte[] bytes)
public static String asBase64(int value)
public static String asBase64(long value)
public static String changeFileExtension(String inFileName, String newExt)
inFileName
- a path or a url to a file.newExt
- the new extension of the file.public static String collectionToString(Collection<?> col)
public static <T extends IStringSeralizable> String collectionStringSeralizableToString(Collection<T> col, String sep)
public static <T extends IStringSeralizable> List<T> stringToStringSeralizableCollection(String data, String sep, Class c) throws InstantiationException, IllegalAccessException
public static String collectionToText(Collection<?> col)
col
- public static String collectionToString(Collection<?> col, String inSep)
public static String convertString(String pattern1, String pattern2, String text)
pattern1
- a pattern with one '*'pattern2
- a pattern with one '*'text
- public static int countChar(String str, char c)
public static String CR2BR(String text)
text
- a simple textpublic static String removeSpecialChars(char c)
public static String createFileName(String fileName)
fileName
- a bad file namepublic static String trim(String text, char trimChar)
text
- trimChar
- public static String CRtoSpace(String text)
text
- a simple textpublic static String cutEndXHTML(String str, int cut)
str
- the stringcut
- the end charaster must be removed.public static byte[] decodeBase64(String data) throws IOException
IOException
public static String decodeNoChar(String data, String noChars)
data
- string to be encodednoChars
- list of vorbiden charpublic static String encodeCDATA(String value)
value
- public static String encodeNoChar(String data, String noChars)
data
- string to be encodednoChars
- list of vorbiden charpublic static String frameTokenCaseUnsensitive(String str, String token, String prefix, String sufix)
str
- a standard strtoken
- a token ( not pattern !!! )public static String getDateRandomId()
public static String getDateRandomIdWithCheck()
public static int getDigitMod9(String value)
public static String getFileExtension(String inFileName)
inFileName
- a file namepublic static String getFileNameFromPath(String path)
inFileName
- a file namepublic static String getFileNameWithoutExtension(String inFileName)
inFileName
- a file namepublic static final String getFileSize(String filePath)
filePath
- a path to a filepublic static String getRandomId()
public static String getShortRandomId()
public static String encodeAsStructuredCommunicationMod97(String code)
code
- a string of length 10 with only numberpublic static String getRandomIdBase10()
public static String getLargeRandomIdBase64()
public static String getRandomIdBase64()
public static String getRandomString(int lenght)
public static int htmlSize(String str)
str
- the stringpublic static boolean isCharset(byte[] b, String inCharset)
public static boolean isDigit(char c)
public static boolean isLetter(char c)
public static boolean isLikeNumber(String str)
str
- public static boolean isDigit(String str)
str
- public static boolean isAlpha(String str)
str
- public static boolean isFloat(String str)
public static final boolean isHTML(String fileName)
fileName
- file name with extensionpublic static final boolean isHTMLStatic(String fileName)
public static final boolean isProperties(String fileName)
public static final boolean isImage(String fileName)
fileName
- file name with extensionpublic static final boolean isEditable(String fileName)
fileName
- file name with extensionpublic static final boolean isJpeg(String fileName)
fileName
- file name with extensionpublic static final boolean isExcelFile(String fileName)
fileName
- file name with extensionpublic static final boolean isImageExtension(String fileExtension)
fileExtension
- file extensiongetFileExtension(String)
public static final boolean isEditableExtension(String fileExtension)
public static final boolean isJpgExtension(String fileExtension)
fileExtension
- file extensiongetFileExtension(String)
public static final boolean isDoc(String fileName)
fileName
- file name with extensionpublic static final boolean isPDF(String fileName)
fileName
- file name with extensionpublic static boolean isMail(String email)
public static boolean isMailURL(String url)
public static final boolean isPasswordMath(String pwdData, String userInput, boolean crypted)
public static boolean isPhoneNumber(String phone)
public static final boolean isSound(String fileName)
fileName
- file name with extensionpublic static boolean isTrue(Object inBool)
public static boolean isTrue(Object inBool, boolean defaultValue)
public static boolean isTrue(String bool, boolean defaultValue)
public static boolean isURL(String url)
public static final boolean isURLFile(String fileName)
fileName
- file name with extensionpublic static final boolean isVideo(String fileName)
fileName
- file name with extensionpublic static boolean matchStarPattern(String str, String pattern)
str
- pattern
- public static boolean matchQuestionPattern(String str, String pattern)
str
- pattern
- public static boolean matchSimplePattern(String str, String pattern, boolean ignoreCase)
str
- pattern
- public static String neverEmpty(String inStr, String replaceWith)
inStr
- a string can be nullreplaceWith
- replace with this if null.public static String neverNull(Object inStr)
inStr
- a string can be nullpublic static String neverNull(Object inStr, String replaceWith)
inStr
- a string can be nullreplaceWith
- replace with this if null.public static Date parseDate(String inDate) throws ParseException
ParseException
public static int parseInt(String value, int defaultValue)
value
- a string with a int insidedefaultValue
- the value if string value is nullpublic static Date[] parseRangeDate(String date) throws ParseException
ParseException
public static Date parseDate(String inDate, char sep) throws ParseException
ParseException
public static Date parseDateTime(String inDate, char sep) throws ParseException
ParseException
public static Date parseDate(String inDate, String pattern) throws ParseException
ParseException
public static Date parseDateOrTime(String inDate) throws ParseException
ParseException
public static Date parseFileTime(String fileTime) throws ParseException
ParseException
public static Date parseSecondFileTime(String fileTime) throws ParseException
ParseException
public static Date parseSortableTime(String date) throws ParseException
ParseException
public static Date parseSortableDate(String date) throws ParseException
ParseException
public static Date parseTime(String inDate) throws ParseException
ParseException
public static Date parseTimeOnly(String inDate) throws ParseException
ParseException
public static String removeCR(String text)
text
- a simple Stringpublic static String removeRepeatedChar(String str, char c)
str
- c
- public static final String removeSequence(String text, String prefix, String sufix)
text
- a simple textprefix
- the prefix for identify the sequencesufix
- the sufix for identify the sequencepublic static String removeTag(String text)
text
- XHTML Codepublic static String renderShortTime(ContentContext ctx, Date date) throws FileNotFoundException, IOException
FileNotFoundException
IOException
public static String renderShortDate(ContentContext ctx, Date date) throws FileNotFoundException, IOException
session
- locale
- date
- IOException
FileNotFoundException
public static Date parseIso8601(String input) throws ParseException
ParseException
public static String renderDateWithDefaultValue(Date date, String defaultValue)
public static final String renderTimeInSecond(long time)
public static String renderDouble(double value, int precision)
public static String renderDouble(double value, int precision, char sep)
public static String renderDoubleAsPercentage(double value)
public static String renderMediumDate(ContentContext ctx, Date date)
public static String renderFullDate(ContentContext ctx, Date date)
public static String renderMonthDate(ContentContext ctx, Date date)
public static String renderNumber(int n, int size)
public static String renderShortDateWidthDay(ContentContext ctx, Date date)
public static final String renderSize(long size)
filePath
- a path to a filepublic static String renderTime(ContentContext ctx, Date date) throws FileNotFoundException, IOException
FileNotFoundException
IOException
public static String renderUserFriendlyDate(ContentContext ctx, Date date) throws FileNotFoundException, IOException
session
- locale
- date
- IOException
FileNotFoundException
public static Collection<javax.mail.internet.InternetAddress> searchStructuredEmail(String text)
text
- a free textpublic static Collection<String> searchEmail(String text)
text
- a free textpublic static List<URL> searchLinks(String text)
text
- a free text, can be htmlpublic static String[] split(String str, String token)
str
- a standard strtoken
- a token ( not pattern !!! )public static String[] splitStaySeparator(String str, char token)
str
- a standard strtoken
- a token ( not pattern !!! )public static String[] splitStaySeparator(String str, String token)
str
- a standard strtoken
- a token ( not pattern !!! )public static List<String> stringToCollection(String str, String token, boolean trim)
public static String textToList(GlobalContext globalContext, String text, String sep, String layout, boolean autoLink)
public static String textToList(GlobalContext globalContext, String text, String sep, String layout, boolean autoLink, String ulClass)
sep
- separation between title and text. sample "1.2 great section"
sep=" " -> "1.2" is title and "great section" is text.layout
- the layout of the list : ("ul-ul", "ol-ol", "ul-ol", "ol-ul")
the first element is the first level and the next is all the
next level.public static String toJSString(String inStr)
inStr
- a Simple Stringpublic static String toMaxSize(String str, int size, String sufix)
str
- the string must be cut.size
- the max size of the final string.sufix
- the sufix of new String if cutted (sp. ... ).public static String toXMLAttribute(String value)
value
- public static String toHTMLAttribute(String value)
value
- public static String txt2htmlCR(String text)
text
- a simple textpublic static String getPathType(String path, String prefix)
path
- prefix
- public static boolean isEmpty(Object value)
public static boolean isAllEmpty(Object... values)
public static boolean isOneEmpty(Object... values)
public static List<String> extractItem(String text, String prefix, String suffix)
text
- prefix
- suffix
- public static Collection<? extends String> stringToCollectionRemoveEmpty(String addRolesAsRaw)
public static String createKey(int length, Set<String> keys)
length
- the length of the key.keys
- set of keys allready existpublic static String cleanPath(String path)
path
- public static boolean containsUppercase(String text)
text
- public static String escapeProperty(String theString, boolean escapeSpace, boolean escapeUnicode)
theString
- escapeSpace
- escapeUnicode
- public static boolean validUTF8(byte[] input)
public static String getNewToken()
public static String getNumberAsAlphabetic(int number)
public static Color parseColor(String color)
color
- public static List<String> trimList(Collection<String> list)
list
- public static String getItem(String text, String sep, int i, String defaultValue)
text
- sep
- i
- defaultValue
- default value if item not foundpublic static Integer getPixelValue(String pxSize)
pxSize
- a size in px (sp. '12px').public static String hex(byte[] array)
public static long getCRC32(String text)
public static boolean rangeMatches(String range, Integer value)
range
- Range values are like -25,25-30,31-35,35+value
- the integer to testtrue
is the value is in the range false
otherwisepublic static int getColNum(String colName)
public static String getColName(int colIndex)
public static boolean timedTokenValidate(String tokenData, String orignalData, int validityRangeInMinutes, long timeInMillis)
public static String toLatin(String text)
text
- public static String removeQuote(String text)
text
- public static String normalizePhoneNumber(String phone, String countryPrefix)
phone
- countryPrefix
- public static boolean isVAT(String vat) throws MalformedURLException, Exception
MalformedURLException
Exception
public static String propertiesToString(Properties p)
public static void main(String[] args)
Copyright © 2012-2018. All Rights Reserved.