Package htsjdk.samtools.util
Class FormatUtil
- java.lang.Object
-
- htsjdk.samtools.util.FormatUtil
-
public class FormatUtil extends Object
Simple class used to format object values into a standard format for printing.
-
-
Field Summary
Fields Modifier and Type Field Description static intDECIMAL_DIGITS_TO_PRINT
-
Constructor Summary
Constructors Constructor Description FormatUtil()Constructs a new FormatUtil and initializes various internal formatters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringformat(boolean value)Formats a boolean value to a String.Stringformat(char value)Formats a char as a string.Stringformat(double value)Formats a double to a floating point string.Stringformat(float value)Formats a float to a floating point string.Stringformat(int value)Formats an int to an integer string.Stringformat(long value)Formats a long to an integer string.Stringformat(short value)Formats a short to an integer string.Stringformat(Iso8601Date value)Formats date & timeStringformat(Enum value)Formats an enum to the String representation of an enum.Stringformat(Object value)Attempts to determine the type of value and format it appropriately.Stringformat(Date value)Formats a date to a date string without time.booleanparseBoolean(String value)Parses a String into a boolean, as per the above convention that true = Y and false = N.charparseChar(String value)Parses a String into a char.DateparseDate(String value)Parses a String into a date.doubleparseDouble(String value)Parses a String into a double.<E extends Enum>
EparseEnum(String value, Class<E> type)Parses a String into an Enum of the given type.floatparseFloat(String value)Parses a String into a float.intparseInt(String value)Parses a String into an int.Iso8601DateparseIso8601Date(String value)Parse a String into an Iso8601 DatelongparseLong(String value)Parses a String into a long.ObjectparseObject(String value, Class<?> returnType)Attempts to determine the correct parse method to call based on the desired return type and then parses the String and returns the value.shortparseShort(String value)Parses a String into a short.
-
-
-
Field Detail
-
DECIMAL_DIGITS_TO_PRINT
public static final int DECIMAL_DIGITS_TO_PRINT
- See Also:
- Constant Field Values
-
-
Method Detail
-
format
public String format(short value)
Formats a short to an integer string.
-
format
public String format(int value)
Formats an int to an integer string.
-
format
public String format(long value)
Formats a long to an integer string.
-
format
public String format(float value)
Formats a float to a floating point string.
-
format
public String format(double value)
Formats a double to a floating point string.
-
format
public String format(char value)
Formats a char as a string.
-
format
public String format(Iso8601Date value)
Formats date & time
-
format
public String format(boolean value)
Formats a boolean value to a String.
-
format
public String format(Object value)
Attempts to determine the type of value and format it appropriately.
-
parseShort
public short parseShort(String value)
Parses a String into a short.
-
parseInt
public int parseInt(String value)
Parses a String into an int.
-
parseLong
public long parseLong(String value)
Parses a String into a long.
-
parseFloat
public float parseFloat(String value)
Parses a String into a float.
-
parseDouble
public double parseDouble(String value)
Parses a String into a double.
-
parseEnum
public <E extends Enum> E parseEnum(String value, Class<E> type)
Parses a String into an Enum of the given type.
-
parseIso8601Date
public Iso8601Date parseIso8601Date(String value)
Parse a String into an Iso8601 Date
-
parseBoolean
public boolean parseBoolean(String value)
Parses a String into a boolean, as per the above convention that true = Y and false = N.
-
parseChar
public char parseChar(String value)
Parses a String into a char. We expect the String to have a length of exactly one, otherwise throw an exception.
-
parseObject
public Object parseObject(String value, Class<?> returnType)
Attempts to determine the correct parse method to call based on the desired return type and then parses the String and returns the value.- Parameters:
value- the String value to be parsedreturnType- the desired return type- Returns:
- an object of the returnType
-
-