|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jmythapi.utils.EncodingUtils
public class EncodingUtils
Nested Class Summary | |
---|---|
static class |
EncodingUtils.DateTimePattern
Date pattern used to parse dates. |
Field Summary | |
---|---|
static String |
DATE_PATTERN
|
static String |
NULL_DATE_TIME
|
static String |
NULL_DAY
|
static String |
NULL_TIME
|
static String |
TIME_PATTERN
|
static String |
TIMEZONE_UTC
|
static Class<?>[][] |
VALUE_OF_ARGS
valueOf methods that are supported by decodeString(java.lang.Class |
Method Summary | ||
---|---|---|
static Date |
aggregateDateTime(Date day,
Time time,
boolean isUTC)
|
|
static Boolean |
decodeBoolean(String value)
|
|
static Boolean |
decodeBoolean(String value,
Boolean onEmptyValue)
|
|
static long |
decodeLong(int[] values)
Deprecated. 66 |
|
static long |
decodeLong(String value1,
String value2)
Deprecated. 66 |
|
static
|
decodeString(Class<E> clazz,
ProtocolVersion protoVersion,
int dbVersion,
boolean isUTC,
String value)
|
|
static
|
decodeString(Class<E> clazz,
ProtocolVersion protoVersion,
int dbVersion,
boolean isUTC,
String value,
E onEmptyValue)
Converts the given value-string into the specified class. |
|
static
|
decodeString(Class<E> clazz,
ProtocolVersion protoVersion,
String value)
Converts the given value-string into the specified class. |
|
static String[] |
encodeLong(long value)
Deprecated. 66 |
|
static
|
encodeObject(Class<S> sourceType,
ProtocolVersion versionNr,
int dbVersion,
boolean isUTC,
S value,
Class<T> targetType,
String onNullValue)
|
|
static
|
encodeObject(Class<S> sourceType,
ProtocolVersion versionNr,
S value,
Class<T> targetType,
String onNullValue)
|
|
static String |
formatDateTime(Date date,
boolean isUTC)
Formats the given date as string. |
|
static String |
formatDateTimeToUnixTimestamp(Date date)
|
|
static String |
formatDay(Date day,
boolean isUTC)
|
|
static String |
formatTime(Date time,
boolean isUTC)
|
|
static String |
generateId(Integer id,
Date date)
|
|
static int |
getDaysDiff(Date start,
Date end)
|
|
static String |
getFormattedFileSize(Locale locale,
long bytes)
|
|
static String |
getFormattedFileSize(long bytes)
|
|
static String |
getFormattedTitle(String title,
String subTitle)
|
|
static int[] |
getHourMinutesLength(int duration)
|
|
static int |
getHoursDiff(Date start,
Date end)
|
|
static int |
getMinutesAfterMidnight(Date start)
|
|
static int |
getMinutesDiff(Date start,
Date end)
|
|
static int |
getMinutesDiff(long start,
long end)
|
|
static int |
getSecondsDiff(Date start,
Date end)
|
|
static int |
getSecondsDiff(long start,
long end)
|
|
static Date |
parseDate(String value,
boolean isUTC)
Parses the given string into a date object. |
|
static Date |
parseDay(String dayString,
boolean isUTC)
|
|
static Time |
parseTime(String timeString,
boolean isUTC)
|
|
static Object[] |
splitId(String idString,
boolean isUTC)
Splits a id-string into the channel-id and start-date part. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String TIMEZONE_UTC
public static final String DATE_PATTERN
public static final String TIME_PATTERN
public static final String NULL_DAY
public static final String NULL_TIME
public static final String NULL_DATE_TIME
public static final Class<?>[][] VALUE_OF_ARGS
valueOf
methods that are supported by decodeString(java.lang.Class, org.jmythapi.protocol.ProtocolVersion, java.lang.String)
Method Detail |
---|
public static String formatDay(Date day, boolean isUTC)
parseDay(java.lang.String, boolean)
public static Date parseDay(String dayString, boolean isUTC)
parseDay(java.lang.String, boolean)
public static String formatTime(Date time, boolean isUTC)
parseTime(java.lang.String, boolean)
public static Time parseTime(String timeString, boolean isUTC)
formatTime(java.util.Date, boolean)
public static Date aggregateDateTime(Date day, Time time, boolean isUTC)
public static String formatDateTime(Date date, boolean isUTC)
The returned string is in the format EncodingUtils.DateTimePattern.PROTOCOL_DATE_FORMAT
date
- the date to formatisUTC
- if the date is in UTC format
public static String formatDateTimeToUnixTimestamp(Date date)
public static Date parseDate(String value, boolean isUTC)
The date string can be in one of the following formats
0000-00-00
: will be converted to null
\\d+
: will be interpreted as unix timestamp (seconds since January 1, 1970)EncodingUtils.DateTimePattern.PROTOCOL_DATE_FORMAT
value
- the date string.isUTC
- if the date is in UTC format
null
if the date is invalid or can not be parsedpublic static String[] encodeLong(long value)
public static long decodeLong(String value1, String value2)
public static long decodeLong(int[] values)
public static <E> E decodeString(Class<E> clazz, ProtocolVersion protoVersion, String value)
The conversion is done by calling one of the following static functions (see: VALUE_OF_ARGS
):
Class.valueOf(int protoVersion, String value)
Class.valueOf(String value)
Class.valueOf(Object value)
Usage example:
ProgramInfo programInfo = ....; ProgramFlags programFlags = EncodingUtils.decodeString( // the target class to convert the string to ProgramFlags.class, // the protocol version this.protoVersion, // the string value of the given argument programInfo.getResponseArgument(ProgramInfo.Props.PROGRAM_FLAGS) );
E
- the target typeclazz
- the target classprotoVersion
- the protocol- or database-versionvalue
- the value as string
null
then null
is returnedpublic static <E> E decodeString(Class<E> clazz, ProtocolVersion protoVersion, int dbVersion, boolean isUTC, String value)
public static <E> E decodeString(Class<E> clazz, ProtocolVersion protoVersion, int dbVersion, boolean isUTC, String value, E onEmptyValue)
The conversion is done by calling one of the following static functions (see: VALUE_OF_ARGS
):
Class.valueOf(int protoVersion, String value)
Class.valueOf(String value)
Class.valueOf(Object value)
String
Boolean
Date
Time
Enum
Usage example:
ProgramInfo programInfo = ....; ProgramFlags programFlags = EncodingUtils.decodeString( // the target class to convert the string to ProgramFlags.class, // the protocol version this.protoVersion, // the string value of the given argument programInfo.getResponseArgument(ProgramInfo.Props.PROGRAM_FLAGS) );
E
- the target typeclazz
- the target classprotoVersion
- the protocol- or database-versionvalue
- the value as string.
null
then the value of onEmptyValue
is returnedpublic static Boolean decodeBoolean(String value)
public static Boolean decodeBoolean(String value, Boolean onEmptyValue)
public static <S,T> String encodeObject(Class<S> sourceType, ProtocolVersion versionNr, S value, Class<T> targetType, String onNullValue)
public static <S,T> String encodeObject(Class<S> sourceType, ProtocolVersion versionNr, int dbVersion, boolean isUTC, S value, Class<T> targetType, String onNullValue)
public static int getMinutesAfterMidnight(Date start)
public static int getSecondsDiff(long start, long end)
public static int getSecondsDiff(Date start, Date end)
public static int getMinutesDiff(long start, long end)
public static int getMinutesDiff(Date start, Date end)
public static int getHoursDiff(Date start, Date end)
public static int getDaysDiff(Date start, Date end)
public static int[] getHourMinutesLength(int duration)
public static String getFormattedFileSize(long bytes)
public static String getFormattedFileSize(Locale locale, long bytes)
public static String getFormattedTitle(String title, String subTitle)
public static String generateId(Integer id, Date date)
public static Object[] splitId(String idString, boolean isUTC)
idString
- the unique- program- or -recording-id
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |