Example usage for java.lang Short toString

List of usage examples for java.lang Short toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this Short 's value.

Usage

From source file:Main.java

public static void main(String[] args) {
    short s = 10;
    Short sObj = new Short(s);
    String str = sObj.toString();
    System.out.println(str);//from ww  w. j  a v  a  2 s.  co  m
}

From source file:Main.java

public static void main(String[] args) {

    short sval = 50;
    Short shortValue = new Short(sval);

    System.out.println("Value is = " + shortValue.toString());
}

From source file:com.github.jessemull.microflex.util.BigIntegerUtil.java

/**
 * Safely converts a number to a BigInteger. Loss of precision may occur. Throws
 * an arithmetic exception upon overflow.
 * @param    Object    object to parse/*from   ww w  . j  a v  a  2 s  .  c o m*/
 * @return             parsed object
 * @throws   ArithmeticException    on overflow
 */
public static BigInteger toBigInteger(Object obj) {

    /* Switch on class and convert to BigInteger */

    String type = obj.getClass().getSimpleName();
    BigInteger parsed;

    switch (type) {

    case "Byte":
        Byte by = (Byte) obj;
        parsed = new BigInteger(by.toString());
        break;

    case "Short":
        Short sh = (Short) obj;
        parsed = new BigInteger(sh.toString());
        break;

    case "Integer":
        Integer in = (Integer) obj;
        parsed = new BigInteger(in.toString());
        break;

    case "Long":
        Long lo = (Long) obj;
        parsed = new BigInteger(lo.toString());
        break;

    case "Float":
        Float fl = (Float) obj;
        parsed = new BigInteger(fl.toString());
        break;

    case "BigInteger":
        parsed = (BigInteger) obj;
        break;

    case "BigDecimal":
        parsed = ((BigDecimal) obj).toBigInteger();
        break;

    case "Double":
        Double db = (Double) obj;
        parsed = new BigInteger(db.toString());
        break;

    default:
        throw new IllegalArgumentException(
                "Invalid type: " + type + "\nData values " + "must extend the abstract Number class.");

    }

    return parsed;
}

From source file:com.github.jessemull.microflex.util.BigIntegerUtil.java

/**
 * Safely converts a number to a BigInteger. Loss of precision may occur. Throws
 * an arithmetic exception upon overflow.
 * @param    Number    object to parse/*w w w .  j av  a  2 s .  c o  m*/
 * @return             parsed object
 * @throws   ArithmeticException    on overflow
 */
public static BigInteger toBigInteger(Number number) {

    /* Switch on class and convert to BigInteger */

    String type = number.getClass().getSimpleName();
    BigInteger parsed;

    switch (type) {

    case "Byte":
        Byte by = (Byte) number;
        parsed = new BigInteger(by.toString());
        break;

    case "Short":
        Short sh = (Short) number;
        parsed = new BigInteger(sh.toString());
        break;

    case "Integer":
        Integer in = (Integer) number;
        parsed = new BigInteger(in.toString());
        break;

    case "Long":
        Long lo = (Long) number;
        parsed = new BigInteger(lo.toString());
        break;

    case "Float":
        Float fl = (Float) number;
        parsed = new BigInteger(fl.toString());
        break;

    case "BigInteger":
        parsed = (BigInteger) number;
        break;

    case "BigDecimal":
        parsed = ((BigDecimal) number).toBigInteger();
        break;

    case "Double":
        Double db = (Double) number;
        parsed = new BigInteger(db.toString());
        break;

    default:
        throw new IllegalArgumentException(
                "Invalid type: " + type + "\nData values " + "must extend the abstract Number class.");

    }

    return parsed;
}

From source file:edu.ku.brc.helpers.XMLHelper.java

public static void xmlAttr(final StringBuilder sb, final String attr, final Short val) {
    if (val != null || isEmptyAttrOK) {
        xmlAttr(sb, attr, val.toString());
    }/*from   ww  w .j  a  va  2s. c  o m*/
}

From source file:airlift.util.AirliftUtil.java

/**
 * Convert./*  w w w.  j  a v  a  2 s. co m*/
 *
 * @param _number the _number
 * @return the byte[]
 */
public static byte[] convert(java.lang.Short _number) {
    return (_number == null) ? null : convert(_number.toString());
}

From source file:com.jaspersoft.jasperserver.war.cascade.handlers.converters.ShortDataConverter.java

@Override
public String valueToString(Short value) {
    return value != null ? value.toString() : "";
}

From source file:uk.ac.ebi.intact.editor.config.property.ShortPropertyConverter.java

@Override
public String convertToString(Short obj) {
    if (obj == null)
        return null;

    return obj.toString();
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmMssCF.CFCrmMssCFBindAddressCountryId.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFCrmMssCFBindAddressCountryId.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }//from w  ww.j  av  a  2s.  c  o  m

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFCrmAddressObj) {
        Short countryId = ((ICFCrmAddressObj) genDef).getOptionalCountryId();
        if (countryId == null) {
            ret = null;
        } else {
            ret = countryId.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFCrmAddressObj");
    }

    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindEnumTagEnumCode.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindEnumTagEnumCode.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }/*  ww w  .  j  a  va 2s.com*/

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamEnumTagObj) {
        Short enumCode = ((ICFBamEnumTagObj) genDef).getOptionalEnumCode();
        if (enumCode == null) {
            ret = null;
        } else {
            ret = enumCode.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamEnumTagObj");
    }

    return (ret);
}