List of usage examples for org.apache.commons.lang3.math NumberUtils toLong
public static long toLong(final String str)
Convert a String
to a long
, returning zero
if the conversion fails.
If the string is null
, zero
is returned.
NumberUtils.toLong(null) = 0L NumberUtils.toLong("") = 0L NumberUtils.toLong("1") = 1L
From source file:org.obp.nmea.NmeaLineScanner.java
public long nextLong() { return NumberUtils.toLong(next()); }
From source file:org.ocsoft.rosetto.parsers.rosetto.RosettoElementParser.java
/** * ??Rosetto??????.<br>//w w w.j a va 2 s . com * ??????????ActionCall??????????. */ @Override public RosettoValue parseElement(String element) { //null?Values.NULL if (element == null) return Values.NULL; //?????? element = ParseUtils.removeDoubleQuate(element); //?????????????? if (element.startsWith("[") && element.endsWith("]")) { //???????? return parseActionCall(element); } else if (element.startsWith("(") && element.endsWith(")")) { //?????? return parseList(element); } else if (element.startsWith("{") && element.endsWith("}")) { //?????? return parseMacro(element); } //???????????? if (element.startsWith("@")) { //@????? return new ActionCall("getlocal", element.substring(1)); } else if (element.startsWith("$")) { //$?????? return new ActionCall("getglobal", element.substring(1)); } //??????????? if (NumberUtils.isNumber(element)) { if (element.contains(".")) { return new DoubleValue(NumberUtils.toDouble(element)); } else { return new IntValue(NumberUtils.toLong(element)); } } //bool??????????? if (element.equals("true")) { return BoolValue.TRUE; } else if (element.equals("false")) { return BoolValue.FALSE; } //????????? return new StringValue(element); }
From source file:org.yamj.core.api.json.VideoController.java
/** * Get information on a movie/* w w w. j a va2 s . co m*/ * * TODO: Allow genres to be added to the returned data * * @param id * @param options * @return */ @RequestMapping(value = "/movie/{id}", method = RequestMethod.GET) @ResponseBody public ApiWrapperSingle<ApiVideoDTO> getVideoById(@PathVariable String id, @ModelAttribute("options") OptionsIndexVideo options) { ApiWrapperSingle<ApiVideoDTO> wrapper = new ApiWrapperSingle<ApiVideoDTO>(); // Add the ID to the options options.setId(NumberUtils.toLong(id)); // Set the type to movie options.setType("MOVIE"); wrapper.setOptions(options); if (options.getId() > 0L) { LOG.info("Getting video with ID '{}'", options.getId()); jsonApiStorageService.getSingleVideo(wrapper); } wrapper.setStatusCheck(); return wrapper; }
From source file:org.yamj.core.api.json.VideoController.java
/** * Get information on a series// ww w . j av a 2 s . c o m * * TODO: Get associate seasons for the series * * @param id * @param options * @return */ @RequestMapping(value = "/series/{id}", method = RequestMethod.GET) @ResponseBody public ApiWrapperSingle<ApiVideoDTO> getSeriesById(@PathVariable String id, @ModelAttribute("options") OptionsIndexVideo options) { ApiWrapperSingle<ApiVideoDTO> wrapper = new ApiWrapperSingle<ApiVideoDTO>(); // Add the ID to the options options.setId(NumberUtils.toLong(id)); // Set the type to movie options.setType("SERIES"); wrapper.setOptions(options); if (options.getId() > 0L) { LOG.info("Getting series with ID '{}'", options.getId()); jsonApiStorageService.getSingleVideo(wrapper); } wrapper.setStatusCheck(); return wrapper; }
From source file:org.yamj.core.api.json.VideoController.java
/** * Get information on a series/*from w w w . j a v a 2 s .c o m*/ * * TODO: Add episodes to the season * * @param id * @param options * @return */ @RequestMapping(value = "/season/{id}", method = RequestMethod.GET) @ResponseBody public ApiWrapperSingle<ApiVideoDTO> getSeasonById(@PathVariable String id, @ModelAttribute("options") OptionsIndexVideo options) { ApiWrapperSingle<ApiVideoDTO> wrapper = new ApiWrapperSingle<ApiVideoDTO>(); // Add the ID to the options options.setId(NumberUtils.toLong(id)); // Set the type to movie options.setType("SEASON"); wrapper.setOptions(options); if (options.getId() > 0L) { LOG.info("Getting season with ID '{}'", options.getId()); jsonApiStorageService.getSingleVideo(wrapper); } wrapper.setStatusCheck(); return wrapper; }