Package org.biojava.nbio.core.util
Class StringManipulationHelper
java.lang.Object
org.biojava.nbio.core.util.StringManipulationHelper
A utility class for common
String
manipulation tasks.
All functions are static methods.- Author:
- Amr ALHOSSARY, Richard Adams
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
convertStreamToString
(InputStream stream) Converts an InputStream of text to a String, closing the stream before returning.static boolean
equalsToIgnoreEndline
(String expected, String actual) Compares two strings in a case-sensitive manner for equality, line by line, ignoring any difference of end line delimiters contained within the 2 Strings.static boolean
equalsToXml
(String expected, String actual) This method is not implemented or used, never returns true and should probably be removed.static String
join
(Collection<String> s, String delimiter) Joins Strings together with a delimiter to a singlestatic String
Adds padding to left of supplied stringstatic String
Adds padding to right of supplied string
-
Method Details
-
convertStreamToString
Converts an InputStream of text to a String, closing the stream before returning.- Newlines are converted to Unix newlines (\n)
- Default charset encoding is used to read the stream.
- Any IOException reading the stream is 'squashed' and not made available to caller
- An additional newline is appended at the end of the string.
- Parameters:
stream
-- Returns:
- a possibly empty but non-null String
-
equalsToIgnoreEndline
Compares two strings in a case-sensitive manner for equality, line by line, ignoring any difference of end line delimiters contained within the 2 Strings.
This method should be used if and only if two Strings are considered identical when all nodes are identical including their relative order. Generally useful when asserting identity of automatically regenerated XML or PDB.- Parameters:
expected
-actual
-
-
equalsToXml
This method is not implemented or used, never returns true and should probably be removed.- Parameters:
expected
-actual
-- Returns:
- Throws:
UnsupportedOperationException
- in most cases
-
padLeft
Adds padding to left of supplied string- Parameters:
s
- The String to padn
- an integer >= 1- Returns:
- The left-padded string.
- Throws:
IllegalArgumentException
- if n <= 0
-
padRight
Adds padding to right of supplied string- Parameters:
s
- The String to padn
- an integer >= 1- Returns:
- The right-padded string.
- Throws:
IllegalArgumentException
- if n <= 0
-
join
Joins Strings together with a delimiter to a single- Parameters:
s
- AnIterable
of Stringsdelimiter
-- Returns:
-