Package org.frankframework.util
Class Misc
java.lang.Object
org.frankframework.util.Misc
Miscellaneous conversion functions.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addItemsToList
(Collection<String> collection, String list, String collectionDescription, boolean lowercase) Adds items on a string, added by comma separator (ex: "1,2,3"), into a list.static <T> void
addToSortedListNonUnique
(List<T> list, T item) static <T> void
addToSortedListUnique
(List<T> list, T item) static InputSource
asInputSource
(URL url) static String
byteArrayToString
(byte[] input, String endOfLineString, boolean xmlEncode) Converts a byte array into a string, and adds a specified string to the end of the converted string.static String
cleanseMessage
(String inputString, String regexForHiding, IMessageBrowser.HideMethod hideMethod) Edits the input string according to the regex and the hide method specified.static String
getAge
(long value) static String
static String
getDurationInMs
(long value) static String
static long
static String
insertAuthorityInUrlString
(String url, String authAlias, String username, String password) static String
jsonPretty
(String json) static String
listToString
(List<String> list) Converts the list to a string.static long
static String
toFileSize
(long bytes) static String
toFileSize
(long bytes, boolean format) static String
toFileSize
(long bytes, boolean format, boolean useSiUnits) Format bytes as human-readable text.static long
toFileSize
(String value, long defaultValue) Converts the file size to bytes.
-
Field Details
-
MESSAGE_SIZE_WARN_BY_DEFAULT_KEY
- See Also:
-
LINE_SEPARATOR
-
-
Constructor Details
-
Misc
public Misc()
-
-
Method Details
-
insertAuthorityInUrlString
-
byteArrayToString
public static String byteArrayToString(byte[] input, String endOfLineString, boolean xmlEncode) throws IOException Converts a byte array into a string, and adds a specified string to the end of the converted string.- Throws:
IOException
- See Also:
-
getHostname
-
toFileSize
Converts the file size to bytes.Misc.toFileSize("14GB", 20); // gives out 15032385536
-
toFileSize
- See Also:
-
toFileSize
- See Also:
-
toFileSize
Format bytes as human-readable text.String kbIecUnits = Misc.toFileSize(150000, false, false); // gives out "146KiB" String mbIecUnits = Misc.toFileSize(15000000, true); // gives out "14 MiB" String gbIecUnits = Misc.toFileSize(Long.parseLong("3221225472")); // gives out "3GiB" String kbSiUnits = Misc.toFileSize(150000, true, false); // gives out "150kB" String mbSiUnits = Misc.toFileSize(15000000, true, true); // gives out "15 MB" String gbSiUnits = Misc.toFileSize(Long.parseLong("3221225472"), true, false); // gives out "3GB"
- Parameters:
bytes
- Number of bytes. Should be positive, value is returned as string if negative.format
- True to insert space between value and unit.useSiUnits
- True to use metric (SI) units, aka powers of 1000. False to use binary (IEC), aka powers of 1024.- Returns:
- Formatted string.
-
getMessageSizeWarnByDefault
public static long getMessageSizeWarnByDefault() -
listToString
Converts the list to a string.<pre> List<String> list = new ArrayList<>(); list.add("We Are"); list.add(" Frank"); String res = Misc.listToString(list); // res = "We Are Frank" </pre>
-
addItemsToList
public static void addItemsToList(Collection<String> collection, String list, String collectionDescription, boolean lowercase) Adds items on a string, added by comma separator (ex: "1,2,3"), into a list.- Parameters:
collectionDescription
- description of the list
-
getAge
-
getDurationInMs
-
parseAge
- Returns:
- 'age' in milliseconds.
-
cleanseMessage
public static String cleanseMessage(String inputString, String regexForHiding, IMessageBrowser.HideMethod hideMethod) Edits the input string according to the regex and the hide method specified. -
getBuildOutputDirectory
-
addToSortedListUnique
-
addToSortedListNonUnique
-
jsonPretty
-
asInputSource
- Throws:
IOException
-