Package nl.nn.adapterframework.util
Class Misc
- java.lang.Object
-
- nl.nn.adapterframework.util.Misc
-
public class Misc extends Object
Miscellaneous conversion functions.
-
-
Field Summary
Fields Modifier and Type Field Description static String
LINE_SEPARATOR
static String
MESSAGE_SIZE_WARN_BY_DEFAULT_KEY
-
Constructor Summary
Constructors Constructor Description Misc()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.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
getBuildOutputDirectory()
static String
getDurationInMs(long value)
static String
getFileSystemFreeSpace()
static String
getFileSystemTotalSpace()
static String
getHostname()
static long
getMessageSizeWarnByDefault()
static String
getProjectBaseDir()
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
parseAge(String value, long defaultValue)
static String
toFileSize(long value)
static String
toFileSize(long value, boolean format)
static String
toFileSize(long value, boolean format, boolean floor)
Converts the input value in bytes to the highest degree of file size, and formats and floors the value, if set to true.static long
toFileSize(String value, long defaultValue)
Converts the file size to bytes.
-
-
-
Field Detail
-
MESSAGE_SIZE_WARN_BY_DEFAULT_KEY
public static final String MESSAGE_SIZE_WARN_BY_DEFAULT_KEY
- See Also:
- Constant Field Values
-
LINE_SEPARATOR
public static final String LINE_SEPARATOR
-
-
Method Detail
-
insertAuthorityInUrlString
public static String insertAuthorityInUrlString(String url, String authAlias, String username, String password)
-
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:
StreamUtil.streamToString(InputStream, String, boolean)
-
getHostname
public static String getHostname()
-
toFileSize
public static long toFileSize(String value, long defaultValue)
Converts the file size to bytes.Misc.toFileSize("14GB", 20); // gives out 15032385536
-
toFileSize
public static String toFileSize(long value)
- See Also:
toFileSize(long, boolean)
-
toFileSize
public static String toFileSize(long value, boolean format)
- See Also:
toFileSize(long, boolean, boolean)
-
toFileSize
public static String toFileSize(long value, boolean format, boolean floor)
Converts the input value in bytes to the highest degree of file size, and formats and floors the value, if set to true.String mb = Misc.toFileSize(15000000, true); // gives out "14 MB" String kb = Misc.toFileSize(150000, false, true); // gives out "146KB"
-
getMessageSizeWarnByDefault
public static long getMessageSizeWarnByDefault()
-
listToString
public static String listToString(List<String> list)
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
-
getFileSystemTotalSpace
public static String getFileSystemTotalSpace()
-
getFileSystemFreeSpace
public static String getFileSystemFreeSpace()
-
getAge
public static String getAge(long value)
-
getDurationInMs
public static String getDurationInMs(long value)
-
parseAge
public static long parseAge(String value, long defaultValue)
-
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
public static String getBuildOutputDirectory()
-
getProjectBaseDir
public static String getProjectBaseDir()
-
addToSortedListUnique
public static <T> void addToSortedListUnique(List<T> list, T item)
-
addToSortedListNonUnique
public static <T> void addToSortedListNonUnique(List<T> list, T item)
-
asInputSource
public static InputSource asInputSource(URL url) throws IOException
- Throws:
IOException
-
-