/** * Get Datatype instance by the corresponding Java class. This method tries to find matching supertype too. * @return Datatype instance * @throws IllegalArgumentException if no datatype suitable for the given type found */ @Nonnull public static <T> Datatype<T> getNN(Class<T> clazz) { return getDatatypeRegistry().getNN(clazz); }
/** * Format Date (date without time) using {@code dateFormat} string specified in the main message pack. * @return string representation or empty string if the value is null */ public String formatDate(@Nullable Date value) { return datatypeRegistry.getNN(java.sql.Date.class).format(value, uss.getLocale()); }
/** * Parse Long using {@code integerFormat} string specified in the main message pack. * @return Long value or null if a blank string is provided */ @Nullable public Long parseLong(String str) throws ParseException { return datatypeRegistry.getNN(Long.class).parse(str, uss.getLocale()); } }
/** * Format BigDecimal using {@code decimalFormat} string specified in the main message pack. * @return string representation or empty string if the value is null */ public String formatBigDecimal(@Nullable BigDecimal value) { return datatypeRegistry.getNN(BigDecimal.class).format(value, uss.getLocale()); }
/** * Format Boolean using {@code trueString} and {@code falseString} strings specified in the main message pack. * @return string representation or empty string if the value is null */ public String formatBoolean(@Nullable Boolean value) { return datatypeRegistry.getNN(Boolean.class).format(value, uss.getLocale()); }
/** * Format Long using {@code integerFormat} string specified in the main message pack. * @return string representation or empty string if the value is null */ public String formatLong(@Nullable Long value) { return datatypeRegistry.getNN(Long.class).format(value, uss.getLocale()); }
/** * Parse Double using {@code doubleFormat} string specified in the main message pack. * @return Double value or null if a blank string is provided */ @Nullable public Double parseDouble(String str) throws ParseException { return datatypeRegistry.getNN(Double.class).parse(str, uss.getLocale()); }
/** * Parse Date (time without date) using {@code timeFormat} string specified in the main message pack. * @return Date value or null if a blank string is provided */ @Nullable public Date parseTime(String str) throws ParseException { return datatypeRegistry.getNN(Time.class).parse(str, uss.getLocale()); }
/** * Parse BigDecimal using {@code decimalFormat} string specified in the main message pack. * @return BigDecimal value or null if a blank string is provided */ @Nullable public BigDecimal parseBigDecimal(String str) throws ParseException { return datatypeRegistry.getNN(BigDecimal.class).parse(str, uss.getLocale()); }
/** * Parse Integer using {@code integerFormat} string specified in the main message pack. * @return Integer value or null if a blank string is provided */ @Nullable public Integer parseInteger(String str) throws ParseException { return datatypeRegistry.getNN(Integer.class).parse(str, uss.getLocale()); }
/** * Format Date (time without date) using {@code timeFormat} string specified in the main message pack. * @return string representation or empty string if the value is null */ public String formatTime(@Nullable Date value) { return datatypeRegistry.getNN(Time.class).format(value, uss.getLocale()); }
/** * Parse Boolean using {@code trueString} and {@code falseString} strings specified in the main message pack. * @return Boolean value or null if a blank string is provided */ @Nullable public Boolean parseBoolean(String str) throws ParseException { return datatypeRegistry.getNN(Boolean.class).parse(str, uss.getLocale()); }
/** * Format Double using {@code doubleFormat} string specified in the main message pack. * @return string representation or empty string if the value is null */ public String formatDouble(@Nullable Double value) { return datatypeRegistry.getNN(Double.class).format(value, uss.getLocale()); }
/** * Format Integer using {@code integerFormat} string specified in the main message pack. * @return string representation or empty string if the value is null */ public String formatInteger(@Nullable Integer value) { return datatypeRegistry.getNN(Integer.class).format(value, uss.getLocale()); }
/** * Parse Date (date without time) using {@code dateFormat} string specified in the main message pack. * @return Date value or null if a blank string is provided */ @Nullable public Date parseDate(String str) throws ParseException { return datatypeRegistry.getNN(java.sql.Date.class).parse(str, uss.getLocale()); }
/** * Format Date (date and time) using {@code dateTimeFormat} string specified in the main message pack. * <p>Takes into account time zone if it is set for the current user session.</p> * @return string representation or empty string if the value is null */ public String formatDateTime(@Nullable Date value) { TimeZone timeZone = uss.getUserSession().getTimeZone(); Datatype<Date> datatype = datatypeRegistry.getNN(Date.class); if (datatype instanceof DateTimeDatatype) { return ((DateTimeDatatype) datatype).format(value, uss.getLocale(), timeZone); } return datatype.format(value, uss.getLocale()); }
/** * Parse Date (date and time) using {@code dateTimeFormat} string specified in the main message pack. * <p>Takes into account time zone if it is set for the current user session.</p> * @return Date value or null if a blank string is provided */ @Nullable public Date parseDateTime(String str) throws ParseException { TimeZone timeZone = uss.getUserSession().getTimeZone(); Datatype<Date> datatype = datatypeRegistry.getNN(Date.class); if (datatype instanceof DateTimeDatatype) { return ((DateTimeDatatype) datatype).parse(str, uss.getLocale(), timeZone); } return datatype.parse(str, uss.getLocale()); }
protected String getFileSizeLimitString() { String fileSizeLimitString; if (fileSizeLimit > 0) { if (fileSizeLimit % BYTES_IN_MEGABYTE == 0) { fileSizeLimitString = String.valueOf(fileSizeLimit / BYTES_IN_MEGABYTE); } else { DatatypeRegistry datatypeRegistry = beanLocator.get(DatatypeRegistry.NAME); Datatype<Double> doubleDatatype = datatypeRegistry.getNN(Double.class); double fileSizeInMb = fileSizeLimit / ((double) BYTES_IN_MEGABYTE); UserSessionSource userSessionSource = beanLocator.get(UserSessionSource.NAME); fileSizeLimitString = doubleDatatype.format(fileSizeInMb, userSessionSource.getLocale()); } } else { Configuration configuration = beanLocator.get(Configuration.NAME); fileSizeLimitString = String.valueOf(configuration.getConfig(ClientConfig.class).getMaxUploadSizeMb()); } return fileSizeLimitString; }
protected String getFileSizeLimitString() { String fileSizeLimitString; if (fileSizeLimit > 0) { if (fileSizeLimit % BYTES_IN_MEGABYTE == 0) { fileSizeLimitString = String.valueOf(fileSizeLimit / BYTES_IN_MEGABYTE); } else { DatatypeRegistry datatypeRegistry = beanLocator.get(DatatypeRegistry.NAME); Datatype<Double> doubleDatatype = datatypeRegistry.getNN(Double.class); double fileSizeInMb = fileSizeLimit / ((double) BYTES_IN_MEGABYTE); UserSessionSource userSessionSource = beanLocator.get(UserSessionSource.NAME); fileSizeLimitString = doubleDatatype.format(fileSizeInMb, userSessionSource.getLocale()); } } else { Configuration configuration = beanLocator.get(Configuration.NAME); fileSizeLimitString = String.valueOf(configuration.getConfig(ClientConfig.class).getMaxUploadSizeMb()); } return fileSizeLimitString; }
datatypeRegistry.getNN(String.class) : datatypeRegistry.get(item.getDataTypeName());