Example usage for java.lang Short valueOf

List of usage examples for java.lang Short valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Short valueOf(short s) 

Source Link

Document

Returns a Short instance representing the specified short value.

Usage

From source file:Main.java

public static void main(String[] args) {
    System.out.println(Short.valueOf("10"));

}

From source file:Main.java

public static void main(String[] args) {

    short shortNum = 100;

    Short ShortValue = Short.valueOf(shortNum);

    System.out.println("Short object representing " + "the specified short value = " + ShortValue);
}

From source file:Main.java

public static void main(String[] args) {
    Short sObj1 = new Short("100");
    System.out.println(sObj1);/*from  w  w  w  .  j a va  2  s .c  om*/
    String str = "100";
    Short sObj2 = Short.valueOf(str);
    System.out.println(sObj2);
}

From source file:MainClass.java

public static void main(String args[]) {

    Boolean bool = Boolean.valueOf("true");
    Character c = new Character('c');
    Byte b = Byte.valueOf("12");
    Short s = Short.valueOf("2");
    Integer i = Integer.valueOf("13245");
    Long l = Long.valueOf("12341234");
    Float f = Float.valueOf("11234.1234");
    Double d = Double.valueOf("43213241234.123412341234");

    System.out.println(bool);//from w w w .  j  a v  a 2  s  .c o  m
    System.out.println(c);
    System.out.println(b);
    System.out.println(s);
    System.out.println(i);
    System.out.println(l);
    System.out.println(f);
    System.out.println(d);
}

From source file:com.sm.test.TestFile.java

public static void main(String[] args) throws Exception {
    String[] opts = new String[] { "-filename", "-mapSize", "-range", "-listSize", "-times", "-url",
            "-store", };
    String[] defaults = new String[] { "/Users/mhsieh/test/data/userCrm", "5", "4", "2", "100",
            "las1-crmp001:6172", "userCrm" };
    String[] paras = getOpts(args, opts, defaults);

    String filename = paras[0];/*www.  ja v  a 2  s .  co  m*/
    short mapSize = Short.valueOf(paras[1]);
    int range = Integer.valueOf(paras[2]);
    int listSize = Integer.valueOf(paras[3]);
    int times = Integer.valueOf(paras[4]);
    String url = paras[5];
    String store = paras[6];
    TestFile testFile = new TestFile(mapSize, range, listSize);
    ClusterClientFactory ccf = ClusterClientFactory.connect(url, store);
    ClusterClient client = ccf.getDefaultStore();

    StoreIterator storeIterator = new StoreIterator(filename);
    int i = 0;
    while (storeIterator.hasNext()) {
        //            Pair<Key, byte[]> pair = storeIterator.next();
        //            short c1 = testFile.getPartitionIndex( pair.getFirst()).getFirst();
        //            short c2 = testFile.finePartition( pair.getFirst());
        //            if ( c1 != c2) {
        //                logger.info( "mismatch i "+i + " c1 "+c1 + " c2 "+c2+ " "+ toStr( (byte[]) pair.getFirst().getKey() )+ " "+pair.getFirst().hashCode() );
        //            }
        List<Key> list = getKeyList(storeIterator, 1000);
        List<KeyValue> keyValues = client.multiGets(list);
        int ma = match(keyValues);
        if (ma != list.size()) {
            logger.info("expect " + list.size() + " get " + ma);
        }
        i++;
        if (i > times)
            break;

    }
    logger.info("close file " + filename);
    storeIterator.close();
}

From source file:Main.java

public static void keep_setShort(Field field, Object obj, Cursor cursor, int i) {
    try {/*from ww  w . j  a v  a  2 s .  c om*/
        if (field.getType().equals(Short.TYPE))
            field.setShort(obj, cursor.getShort(i));
        else
            field.set(obj, Short.valueOf(cursor.getShort(i)));
    } catch (Exception exception) {
        exception.printStackTrace();
    }
}

From source file:Main.java

public static Object getObject(String type, String value) throws Exception {

    type = type.toLowerCase();/* w w  w.  j a v a 2 s . c  o m*/
    if ("boolean".equals(type))
        return Boolean.valueOf(value);
    if ("byte".equals(type))
        return Byte.valueOf(value);
    if ("short".equals(type))
        return Short.valueOf(value);
    if ("char".equals(type))
        if (value.length() != 1)
            throw new NumberFormatException("Argument is not a character!");
        else
            return Character.valueOf(value.toCharArray()[0]);
    if ("int".equals(type))
        return Integer.valueOf(value);
    if ("long".equals(type))
        return Long.valueOf(value);
    if ("float".equals(type))
        return Float.valueOf(value);
    if ("double".equals(type))
        return Double.valueOf(value);
    if ("string".equals(type))
        return value;
    else {
        Object objs[] = new String[] { value };
        return Class.forName(type).getConstructor(new Class[] { java.lang.String.class }).newInstance(objs);
    }
}

From source file:Main.java

/**
 * box the short to Short
 */
public static Short boxed(short v) {
    return Short.valueOf(v);
}

From source file:Main.java

/**
 * <p>Extract short values from an array of strings into an array of short.</p>
 *
 * <p>Exceptions in the format of the string are trapped and 0 value(s) returned.</p>
 *
 * @param   src   an array of strings, each of which should be a short numeric value
 * @return      an array of short/*from  w  w  w  . j  a v  a  2 s  . c om*/
 */
static public short[] copyStringToShortArray(String[] src) {
    if (src == null)
        return null;
    int n = src.length;
    short[] dst = new short[n];
    for (int j = 0; j < n; ++j) {
        short value = 0;
        try {
            value = Short.valueOf(src[j]).shortValue();
        } catch (NumberFormatException e) {
        } catch (NullPointerException e) {
        }
        dst[j] = value;
    }
    return dst;
}

From source file:Main.java

/**
 * Helper method used to get default value for wrappers used for primitive types
 * (0 for Integer etc)/*from w  w  w.  ja v  a2s . co m*/
 */
public static Object defaultValue(Class<?> cls) {
    if (cls == Integer.TYPE) {
        return Integer.valueOf(0);
    }
    if (cls == Long.TYPE) {
        return Long.valueOf(0L);
    }
    if (cls == Boolean.TYPE) {
        return Boolean.FALSE;
    }
    if (cls == Double.TYPE) {
        return Double.valueOf(0.0);
    }
    if (cls == Float.TYPE) {
        return Float.valueOf(0.0f);
    }
    if (cls == Byte.TYPE) {
        return Byte.valueOf((byte) 0);
    }
    if (cls == Short.TYPE) {
        return Short.valueOf((short) 0);
    }
    if (cls == Character.TYPE) {
        return '\0';
    }
    throw new IllegalArgumentException("Class " + cls.getName() + " is not a primitive type");
}