Package org.compiere.util
Class Util
java.lang.Object
org.compiere.util.Util
General Utility methods
- 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic StringRemove all Ampersand character (used to indicate shortcut in Swing client)static StringClean - Remove all white spacesstatic StringdeleteAccents(String text) Remove accents from stringstatic voidDump a Map (key=value) to standard outstatic intfindIndexOf(String str, char search) Find index of search character in str.
This ignores content in () and quoted text ('texts').static intfindIndexOf(String str, char search1, char search2) Find index of search characters in str.
This ignores content in () and quoted text ('texts').static intfindIndexOf(String str, String search) Find index of search string in str.
This ignores content in () and quoted text ('texts')static UUIDGenerate a UUIDv7 based on current timestampstatic UUIDgenerateUUIDv7(Timestamp timestamp) Generate a UUIDv7 based on given timestampstatic intGet the number of occurrences of countChar in string.static AttributedCharacterIteratorgetIterator(AttributedString aString, AttributedCharacterIterator.Attribute[] relevantAttributes) Return a Iterator with only the relevant attributes.
Fixes implementation in AttributedString, which returns everything.static StringCapitalize first character of a wordstatic booleanIs str a 8 Bit stringstatic booleanIs running from Eclipsestatic booleanIs String Empty or nullstatic booleanIs String Empty or nullstatic booleanIs value a valid UUID stringstatic StringMask HTML content.
i.e. replace characters with &values;
CR is not masked.static StringMask HTML content.
i.e. replace characters with &values;static voidMerge pdf filesstatic StringprettifyJSONString(String value) Returns a string with a formatted JSON objectstatic voidDeprecated.Swing client have been deprecatedstatic StringremoveCRLF(String in) Remove CR / LF from Stringstatic TimestampremoveTime(Timestamp ts) Set time portion to zero.static StringReplace String values.static StringsetFilenameCorrect(String input) Make filename safe (replace all unauthorized characters with safe ones)static intSize of String in bytesstatic StringDeprecated, for removal: This API element is subject to removal in a future version.dummy method, not doing anythingstatic StringtoHex(byte b) Return Hex String representation of byte bstatic StringtoHex(char c) Return Hex String representation of char cstatic StringtrimLength(String str, int length) Trim to max character lengthstatic StringTrim to max byte size
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
replace
Replace String values.- Parameters:
value- string to be processedoldPart- old partnewPart- replacement - can be null or ""- Returns:
- String with replaced values
-
removeCRLF
Remove CR / LF from String- Parameters:
in- input- Returns:
- cleaned string
-
cleanWhitespace
Clean - Remove all white spaces- Parameters:
in-- Returns:
- cleaned string
-
maskHTML
Mask HTML content.
i.e. replace characters with &values;
CR is not masked.- Parameters:
content- content- Returns:
- masked content
- See Also:
-
maskHTML
Mask HTML content.
i.e. replace characters with &values;- Parameters:
content- contentmaskCR- convert CR into- Returns:
- masked content or null if the
contentis null
-
getCount
Get the number of occurrences of countChar in string.- Parameters:
string- String to be searchedcountChar- to be counted character- Returns:
- number of occurrences
-
isEmpty
Is String Empty or null- Parameters:
str- string- Returns:
- true if str is empty or null
-
isEmpty
Is String Empty or null- Parameters:
str- stringtrimWhitespaces- trim whitespaces- Returns:
- true if str is empty or null
-
deleteAccents
Remove accents from string- Parameters:
text- string- Returns:
- Unaccented String
-
findIndexOf
Find index of search character in str.
This ignores content in () and quoted text ('texts').- Parameters:
str- stringsearch- search character- Returns:
- index or -1 if not found
-
findIndexOf
Find index of search characters in str.
This ignores content in () and quoted text ('texts').- Parameters:
str- stringsearch1- first search charactersearch2- second search character (or)- Returns:
- index or -1 if not found
-
findIndexOf
Find index of search string in str.
This ignores content in () and quoted text ('texts')- Parameters:
str- stringsearch- search string- Returns:
- index or -1 if not found
-
toHex
Return Hex String representation of byte b- Parameters:
b- byte- Returns:
- Hex
-
toHex
Return Hex String representation of char c- Parameters:
c- character- Returns:
- Hex
-
initCap
Capitalize first character of a word- Parameters:
in- string- Returns:
- Capitalize string
-
getIterator
@Generated 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
Dump a Map (key=value) to standard out- Parameters:
map- Map
-
printActionInputMap
Deprecated.Swing client have been deprecatedPrint Action and Input Map for component- Parameters:
comp- Component with ActionMap
-
is8Bit
Is str a 8 Bit string- Parameters:
str- string- Returns:
- true if str doesn't contains chars > 255
-
cleanAmp
Remove all Ampersand character (used to indicate shortcut in Swing client)- Parameters:
in- input- Returns:
- cleaned string
-
trimLength
Trim to max character length- Parameters:
str- stringlength- max (inclusive) character length- Returns:
- trim string
-
size
Size of String in bytes- Parameters:
str- string- Returns:
- size in bytes
-
trimSize
Trim to max byte size- Parameters:
str- stringsize- max size in bytes- Returns:
- string
-
stripDiacritics
Deprecated, for removal: This API element is subject to removal in a future version.dummy method, not doing anythingStrip diacritics from given string- Parameters:
s- original string- Returns:
- string without diacritics
-
removeTime
Set time portion to zero.- Parameters:
ts-- Returns:
- truncated timestamp
-
mergePdf
public static void mergePdf(List<File> pdfList, File outFile) throws IOException, com.lowagie.text.DocumentException, FileNotFoundException Merge pdf files- Parameters:
pdfList- list of pdf file to mergeoutFile- merged output file- Throws:
IOExceptioncom.lowagie.text.DocumentExceptionFileNotFoundException
-
setFilenameCorrect
Make filename safe (replace all unauthorized characters with safe ones)- Parameters:
input- the filename to check
-
isUUID
Is value a valid UUID string- Parameters:
value-- Returns:
- true if value is a UUID identifier
-
isDeveloperMode
Is running from Eclipse- Returns:
- true if there is a directory org.adempiere.base within AdempiereHome or if there is a System property org.idempiere.developermode set to Y
-
prettifyJSONString
Returns a string with a formatted JSON object- Returns:
- string with a pretty JSON format
-
generateUUIDv7
Generate a UUIDv7 based on current timestamp- Returns:
-
generateUUIDv7
Generate a UUIDv7 based on given timestamp- Parameters:
timestamp-- Returns:
-