Package org.compiere.util
Class Util
- java.lang.Object
-
- org.compiere.util.Util
-
public class Util extends Object
General Utilities- Version:
- $Id: Util.java,v 1.3 2006/07/30 00:52:23 jjanke Exp $
- Author:
- Jorg Janke, Teo Sarca, SC ARHIPAC SERVICE SRL - BF [ 1748346 ]
-
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
cleanAmp(String in)
Clean Ampersand (used to indicate shortcut)static String
cleanWhitespace(String in)
Clean - Remove all white spacesstatic String
deleteAccents(String text)
Remove accents from stringstatic void
dump(Map<Object,Object> map)
Dump a Map (key=value) to outstatic int
findIndexOf(String str, char search)
Find index of search character in str.static int
findIndexOf(String str, char search1, char search2)
Find index of search characters in str.static int
findIndexOf(String str, String search)
Find index of search character in str.static int
getCount(String string, char countChar)
Get the number of occurances of countChar in string.static AttributedCharacterIterator
getIterator(AttributedString aString, AttributedCharacterIterator.Attribute[] relevantAttributes)
Return a Iterator with only the relevant attributes.static String
initCap(String in)
Init Cap Words With Spacesstatic boolean
is8Bit(String str)
Is 8 Bitstatic boolean
isEmpty(String str)
Is String Emptystatic boolean
isEmpty(String str, boolean trimWhitespaces)
Is String Emptystatic String
maskHTML(String content)
Mask HTML content.static String
maskHTML(String content, boolean maskCR)
Mask HTML content.static void
mergePdf(List<File> pdfList, File outFile)
static void
printActionInputMap(JComponent comp)
Print Action and Input Map for componentstatic String
removeCRLF(String in)
Remove CR / LF from Stringstatic Timestamp
removeTime(Timestamp ts)
static String
replace(String value, String oldPart, String newPart)
Replace String values.static int
size(String str)
Size of String in bytesstatic String
stripDiacritics(String s)
String diacritics from given stringstatic String
toHex(byte b)
Return Hex String representation of byte bstatic String
toHex(char c)
Return Hex String representation of char cstatic String
trimLength(String str, int length)
Trim to max character lengthstatic String
trimSize(String str, int size)
Trim to max byte size
-
-
-
Method Detail
-
replace
public static String replace(String value, String oldPart, String newPart)
Replace String values.- Parameters:
value
- string to be processedoldPart
- old partnewPart
- replacement - can be null or ""- Returns:
- String with replaced values
-
removeCRLF
public static String removeCRLF(String in)
Remove CR / LF from String- Parameters:
in
- input- Returns:
- cleaned string
-
cleanWhitespace
public static String cleanWhitespace(String in)
Clean - Remove all white spaces- Parameters:
in
- in- Returns:
- cleaned string
-
maskHTML
public static String maskHTML(String content)
Mask HTML content. i.e. replace characters with &values; CR is not masked- Parameters:
content
- content- Returns:
- masked content
- See Also:
maskHTML(String, boolean)
-
maskHTML
public static String maskHTML(String content, boolean maskCR)
Mask HTML content. i.e. replace characters with &values;- Parameters:
content
- contentmaskCR
- convert CR into- Returns:
- masked content or null if the
content
is null
-
getCount
public static int getCount(String string, char countChar)
Get the number of occurances of countChar in string.- Parameters:
string
- String to be searchedcountChar
- to be counted character- Returns:
- number of occurances
-
isEmpty
public static boolean isEmpty(String str)
Is String Empty- Parameters:
str
- string- Returns:
- true if >= 1 char
-
isEmpty
public static boolean isEmpty(String str, boolean trimWhitespaces)
Is String Empty- Parameters:
str
- stringtrimWhitespaces
- trim whitespaces- Returns:
- true if >= 1 char
-
deleteAccents
public static String deleteAccents(String text)
Remove accents from string- Parameters:
text
- string- Returns:
- Unaccented String
-
findIndexOf
public static int findIndexOf(String str, char search)
Find index of search character in str. This ignores content in () and 'texts'- Parameters:
str
- stringsearch
- search character- Returns:
- index or -1 if not found
-
findIndexOf
public static int findIndexOf(String str, char search1, char search2)
Find index of search characters in str. This ignores content in () and 'texts'- Parameters:
str
- stringsearch1
- first search charactersearch2
- second search character (or)- Returns:
- index or -1 if not found
-
findIndexOf
public static int findIndexOf(String str, String search)
Find index of search character in str. This ignores content in () and 'texts'- Parameters:
str
- stringsearch
- search character- Returns:
- index or -1 if not found
-
toHex
public static String toHex(byte b)
Return Hex String representation of byte b- Parameters:
b
- byte- Returns:
- Hex
-
toHex
public static String toHex(char c)
Return Hex String representation of char c- Parameters:
c
- character- Returns:
- Hex
-
initCap
public static String initCap(String in)
Init Cap Words With Spaces- Parameters:
in
- string- Returns:
- init cap
-
getIterator
public static AttributedCharacterIterator getIterator(AttributedString aString, AttributedCharacterIterator.Attribute[] relevantAttributes)
Return a Iterator with only the relevant attributes. Fixes implementation in AttributedString, which returns everything- Parameters:
aString
- attributed stringrelevantAttributes
- relevant attributes- Returns:
- iterator
-
dump
public static void dump(Map<Object,Object> map)
Dump a Map (key=value) to out- Parameters:
map
- Map
-
printActionInputMap
public static void printActionInputMap(JComponent comp)
Print Action and Input Map for component- Parameters:
comp
- Component with ActionMap
-
is8Bit
public static boolean is8Bit(String str)
Is 8 Bit- Parameters:
str
- string- Returns:
- true if string contains chars > 255
-
cleanAmp
public static String cleanAmp(String in)
Clean Ampersand (used to indicate shortcut)- Parameters:
in
- input- Returns:
- cleaned string
-
trimLength
public static String trimLength(String str, int length)
Trim to max character length- Parameters:
str
- stringlength
- max (incl) character length- Returns:
- string
-
size
public static int size(String str)
Size of String in bytes- Parameters:
str
- string- Returns:
- size in bytes
-
trimSize
public static String trimSize(String str, int size)
Trim to max byte size- Parameters:
str
- stringsize
- max size in bytes- Returns:
- string
-
stripDiacritics
public static String stripDiacritics(String s)
String diacritics from given string- Parameters:
s
- original string- Returns:
- string without diacritics
-
mergePdf
public static void mergePdf(List<File> pdfList, File outFile) throws IOException, com.lowagie.text.DocumentException, FileNotFoundException
- Parameters:
pdfList
-outFile
-- Throws:
IOException
com.lowagie.text.DocumentException
FileNotFoundException
-
-