List of usage examples for java.lang Number longValue
public abstract long longValue();
From source file:org.osgp.adapter.protocol.dlms.domain.commands.AlarmHelperService.java
/** * Create a set of alarm types representing the active bits in the register * value.//from w w w .j ava 2 s . c o m * * @param registerValue * Value of the register. * @return List of active alarm types. */ public Set<AlarmType> toAlarmTypes(final Number registerValue) { return BYTE_REGISTER_CONVERTER.toTypes(registerValue.longValue()); }
From source file:MWC.GUI.JFreeChart.DatedToolTipGenerator.java
/** * Generates a tool tip text item for a particular item within a series. * * @param data the dataset./* w w w . j av a 2 s. com*/ * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return the tool tip text. */ public String generateToolTip(final XYDataset data, final int series, final int item) { String result = "|" + data.getSeriesKey(series) + " | "; final Number x = data.getXValue(series, item); // put into Date value final Date newD = new Date(x.longValue()); result = result + " DTG: " + newD.toString(); final Number y = data.getYValue(series, item); if (y != null) { result = result + ", value: " + this.getYFormat().format(y); } else { result = result + ", y: null"; } return result; }
From source file:com.anrisoftware.sscontrol.dns.zone.DnsZoneArgs.java
public Long serial(Map<String, Object> args, String name) { if (args.containsKey(SERIAL)) { Number serial = (Number) args.get(SERIAL); log.checkSerial(serial, name);/*from w w w . j a v a2 s .c om*/ return serial.longValue(); } else { return null; } }
From source file:org.kuali.rice.core.api.criteria.CriteriaIntegerValue.java
CriteriaIntegerValue(Number value) { validateValue(value); this.value = BigInteger.valueOf(value.longValue()); }
From source file:org.artofsolving.jodconverter.process.ProcessManagerTest.java
public void unixProcessManager() throws Exception { if (PlatformUtils.isMac() || PlatformUtils.isWindows()) { throw new SkipException("UnixProcessManager only works on Unix"); }/*from ww w .j av a 2 s. co m*/ ProcessManager processManager = new UnixProcessManager(); Process process = new ProcessBuilder("sleep", "5s").start(); ProcessQuery query = new ProcessQuery("sleep", "5s"); long pid = processManager.findPid(query); assertFalse(pid == ProcessManager.PID_NOT_FOUND); Number javaPid = (Number) FieldUtils.readDeclaredField(process, "pid", true); assertEquals(pid, javaPid.longValue()); processManager.kill(process, pid); assertEquals(processManager.findPid(query), ProcessManager.PID_NOT_FOUND); }
From source file:org.jdal.text.PeriodFormatter.java
/** * {@inheritDoc}//from w w w. java2 s.co m */ public String print(Number number, Locale locale) { long period = number.longValue(); long days = TimeUnit.MILLISECONDS.toDays(period); long left = period - TimeUnit.DAYS.toMillis(days); long hours = TimeUnit.MILLISECONDS.toHours(left); left -= TimeUnit.HOURS.toMillis(hours); long minutes = TimeUnit.MILLISECONDS.toMinutes(left); left -= TimeUnit.MINUTES.toMillis(minutes); long seconds = TimeUnit.MILLISECONDS.toSeconds(left); StringBuilder sb = new StringBuilder(); if (days != 0) append(sb, days, DAYS); if (hours != 0) append(sb, hours, HOURS); if (minutes != 0) append(sb, minutes, MINUTES); if (seconds != 0) append(sb, seconds, SECONDS); return sb.toString(); }
From source file:org.artofsolving.jodconverter.process.ProcessManagerTest.java
public void macProcessManager() throws Exception { if (!PlatformUtils.isMac()) { throw new SkipException("MacProcessManager only works on Mac"); }// w w w . j av a 2s. c om ProcessManager processManager = new MacProcessManager(); Process process = new ProcessBuilder("sleep", "5s").start(); ProcessQuery query = new ProcessQuery("sleep", "5s"); long pid = processManager.findPid(query); assertFalse(pid == ProcessManager.PID_NOT_FOUND); Number javaPid = (Number) FieldUtils.readDeclaredField(process, "pid", true); assertEquals(pid, javaPid.longValue()); processManager.kill(process, pid); assertEquals(processManager.findPid(query), ProcessManager.PID_NOT_FOUND); }
From source file:dk.nodes.webservice.parser.NJSONObject.java
/** * Encodes the number as a JSON string.//from w ww . ja v a 2 s.c om * * @param number a finite value. May not be {@link Double#isNaN() NaNs} or * {@link Double#isInfinite() infinities}. */ public static String numberToString(Number number) throws JSONException { if (number == null) { throw new JSONException("Number must be non-null"); } double doubleValue = number.doubleValue(); NJSON.checkDouble(doubleValue); // the original returns "-0" instead of "-0.0" for negative zero if (number.equals(NEGATIVE_ZERO)) { return "-0"; } long longValue = number.longValue(); if (doubleValue == (double) longValue) { return Long.toString(longValue); } return number.toString(); }
From source file:org.dbrain.data.jackson.serializers.JsonLongSerializer.java
@Override public void serialize(Number value, JsonGenerator jgen, SerializerProvider provider) throws IOException { if (value != null) { long longValue = value.longValue(); if (longValue >= MIN_VALUE && longValue <= MAX_VALUE) { jgen.writeNumber(longValue); } else {//from ww w. j a v a 2 s . c o m jgen.writeString(value.toString()); } } else { jgen.writeNull(); } }
From source file:com.neeti.neg.dao.impl.RegisterUserDaoImpl.java
@Override public long createUser(RegisterUser registerUser) { Map<String, Object> parameters = new HashMap<>(); parameters.put("groupname", registerUser.getGroupName()); parameters.put("grouppassword", registerUser.getGroupPassword()); parameters.put("teammembers", registerUser.getTeamMembers()); parameters.put("email", registerUser.getEmail()); parameters.put("enabled", registerUser.getEnabled()); Number userid = insertUser.executeAndReturnKey(parameters); return userid.longValue(); }