Example usage for java.lang Number toString

List of usage examples for java.lang Number toString

Introduction

In this page you can find the example usage for java.lang Number toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:Main.java

/**
 * Write data column.// w  w w  .jav a 2 s.  c  o  m
 * 
 * @param data the data
 * @param outputPath the output path
 */
public static void writeDataColumn(List<? extends Number> data, String outputPath) {
    File file = new File(outputPath);
    try {
        file.createNewFile();
    } catch (IOException e1) {
        e1.printStackTrace();
        System.exit(0);
    }
    try {
        BufferedWriter writer = new BufferedWriter(new FileWriter(file));
        for (Number value : data) {
            writer.write(value.toString() + "\n");
        }
        writer.close();
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(0);
    }
}

From source file:com.esofthead.mycollab.common.UrlEncodeDecoder.java

/**
 * 
 * @param str
 * @return
 */
public static String encode(Number str) {
    return encode(str.toString());
}

From source file:ec.edu.espe.distribuidas.facturacion.socket.estrucMsj.ValidadorFormato.java

public static String fomatoEntero(String numero) {
    Number number = Integer.parseInt(numero);
    return number.toString();
}

From source file:com.ebay.cloud.cms.service.resources.impl.MetadataValidator.java

public static void validateNumber(Number value, String key) {
    if (value != null) {
        CheckConditions.checkArgument(new BigDecimal(value.toString()).compareTo(BigDecimal.ZERO) > 0,
                "Configuration value must be greater than 0 for configuration item %s!", key);
    }//from   w w  w. j  a v a  2  s .  c om
}

From source file:Main.java

public static <T extends Number> List<Long> guardTypeAsLong(List<T> numbers) {
    List<Long> longs = new ArrayList<Long>();
    for (int i = 0; i < numbers.size(); i++) {
        Number n = numbers.get(i);
        if (n instanceof Long) {
            longs.add(n.longValue());//from   w w w  .  j a v  a2 s  .  c om
        } else {
            longs.add(Long.parseLong(n.toString()));
        }
    }
    return longs;
}

From source file:com.wiiyaya.framework.common.utils.StringUtils.java

/**
 * ??//from   ww w.  jav  a  2 s . c o m
 * @param num 
 * @return 
 */
public static String defaultString(final Number num) {
    return num == null ? EMPTY : num.toString();
}

From source file:com.wiiyaya.framework.common.utils.StringUtils.java

/**
 * ?//from www .  j  a  v  a2  s  .co  m
 * @param num 
 * @param defaultStr 
 * @return 
 */
public static String defaultString(final Number num, final String defaultStr) {
    return num == null ? defaultStr : num.toString();
}

From source file:airlift.util.FormatUtil.java

public static String format(java.lang.Number _number) {
    String numberString = "";

    if (_number != null) {
        numberString = _number.toString();
    }/*from   w w w  . java2  s  .  co  m*/

    return numberString;
}

From source file:io.github.seleniumquery.functions.jquery.forms.ValFunction.java

public static SeleniumQueryObject val(SeleniumQueryObject caller, List<WebElement> elements, Number value) {
    SeleniumQueryObject.LOGGER.debug("Setting value of " + caller + " to: " + value + ".");
    return val(caller, elements, value.toString());
}

From source file:com.prowidesoftware.swift.model.field.AmountResolver.java

/**
 * get the amount of the given field by reading it's components pattern.
 * The first index of 'N', number, is returned as amount.
 * <em>See the returns notes</em>
 *
 * @param f the field where to extract the amount, must not be null
 *
 * @return a BigDecimal with the number found in the first numeric component or <code>null</code> if there is 
 *    no numeric component in the field. It may also return null if Field.getComponent(index,Number.class) fails
 *    for that component//from w  w  w .j a  v  a  2  s .c o m
 * @see Field#getComponentAs(int, Class)
 * @since 7.8
 */
public static BigDecimal amount(final Field f) {
    Validate.notNull(f);
    final int i = StringUtils.indexOf(f.componentsPattern(), 'N');
    if (i >= 0) {
        final Number n = (Number) f.getComponentAs(i + 1, Number.class);
        if (n == null) {
            log.warning("getComponentAs(" + (i + 1) + ", Number.class) returned null for field " + f);
            return null;
        }
        return new BigDecimal(n.toString());
    }
    return null;
}