List of usage examples for java.lang Number toString
public String toString()
From source file:de.crowdcode.bitemporal.example.AddressServiceImpl.java
@Override @Transactional(propagation = Propagation.SUPPORTS) public String findRevisionNumberByAddressIdAndRevisionNumber(Long addressId, Integer revisionNumber) { Number number = addressRepository.findRevisionNumberByAddressIdAndRevisionNumber(addressId, revisionNumber); return number.toString(); }
From source file:org.openbravo.dal.xml.XMLTypeConverter.java
/** * @return numbers are converted using the Number.toString method *//*from ww w.j a v a 2s .co m*/ public String toXML(Number number) { return number.toString(); }
From source file:org.openhab.binding.ehealth.internal.EHealthBinding.java
private void postUpdate(EHealthDatagram datagram) { for (EHealthBindingProvider provider : providers) { for (String itemName : provider.getItemNames()) { EHealthSensorPropertyName propertyName = provider.getSensorPropertyName(itemName); // do only publish a new state if it has changed ... if (datagram.hasChanged(previousDatagram, propertyName)) { Number sensorValue = datagram.getRawData().get(propertyName); State newState = new DecimalType(sensorValue.toString()); eventPublisher.postUpdate(itemName, newState); }// w ww .j a v a 2 s . co m } } this.previousDatagram = datagram; }
From source file:foam.lib.csv.Outputter.java
protected void outputNumber(Number value) { writer_.append(value.toString()); }
From source file:org.tsm.concharto.audit.EventFieldChangeFormatter.java
/** * null safe to string or number//from www. jav a 2 s. c o m * @param value an Number * @return "" or string representation of the Number */ private String nullSafeToString(Number value) { if (value == null) { return ""; } return value.toString(); }
From source file:com.github.jillesvangurp.urlbuilder.UrlBuilder.java
/** * Create a query parameter with a number value. * @param name parameter name// w ww . j a va 2 s . c o m * @param value * @return the builder */ public UrlBuilder queryParam(String name, Number value) { if (value != null) { return queryParam(name, value.toString()); } else { return null; } }
From source file:com.mycompany.hibernatecrud.dao.impl.KartaDaoImpl.java
@Transactional @Override/* w ww. j a v a 2 s .c om*/ public int getCountUtakmiceInKlub(int klubId) { String hql = "select count(*) from utakmica where id_klub = :id"; Number result = (Number) getSession().createSQLQuery(hql).setInteger("id", klubId).uniqueResult(); return Integer.parseInt(result.toString()); }
From source file:com.mycompany.hibernatecrud.dao.impl.KartaDaoImpl.java
@Transactional @Override//from ww w . j ava 2s .c o m public int getCountUtakmice() { Number result = (Number) getSession().createSQLQuery("select count(*) from utakmica").uniqueResult(); return Integer.parseInt(result.toString()); }
From source file:dk.nodes.webservice.parser.NJSONObject.java
/** * Encodes the number as a JSON string./*from www . j a va2 s.co m*/ * * @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.kuali.ext.mm.web.format.MMDecimalFormatter.java
/** * begin Kuali Foundation modification Unformats its argument and returns a MMDecimal instance initialized with the resulting * string value// w w w .ja v a2s . c o m * * @see org.kuali.rice.kns.web.format.Formatter#convertToObject(java.lang.String) end Kuali Foundation modification */ @Override protected Object convertToObject(String target) { // begin Kuali Foundation modification MMDecimal value = null; LOG.debug("convertToObject '" + target + "'"); if (target != null) { target = target.trim(); String rawString = target; // parseable values are $1.23 and ($1.23), not (1.23) if (target.startsWith("(")) { if (!target.startsWith("($")) { target = "($" + StringUtils.substringAfter(target, "("); } } // Insert currency symbol if absent if (!(target.startsWith("(") || target.startsWith(getSymbol()))) { target = interpolateSymbol(target); } // preemptively detect non-numeric-related symbols, since NumberFormat.parse seems to be silently deleting them // (i.e. 9aaaaaaaaaaaaaaa is silently converted into 9) if (!CURRENCY_PATTERN.matcher(target).matches()) { throw new FormatException("parsing", RiceKeyConstants.ERROR_CURRENCY, rawString); } // preemptively detect String with excessive digits after the decimal, to prevent them from being silently rounded if (rawString.contains(".") && !TRAILING_DECIMAL_PATTERN.matcher(rawString).matches()) { throw new FormatException("parsing", RiceKeyConstants.ERROR_CURRENCY_DECIMAL, rawString); } // actually reformat the numeric value NumberFormat formatter = getCurrencyInstanceUsingParseBigDecimal(); try { Number parsedNumber = formatter.parse(target); value = new MMDecimal(parsedNumber.toString()); } catch (NumberFormatException e) { throw new FormatException("parsing", RiceKeyConstants.ERROR_CURRENCY, rawString, e); } catch (ParseException e) { throw new FormatException("parsing", RiceKeyConstants.ERROR_CURRENCY, rawString, e); } } return value; // end Kuali Foundation modification }