Example usage for java.lang Short Short

List of usage examples for java.lang Short Short

Introduction

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

Prototype

@Deprecated(since = "9")
public Short(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Short object that represents the short value indicated by the String parameter.

Usage

From source file:fm.last.hadoop.tools.ReplicationPolicyFixer.java

public static int verifyBlockPlacement(LocatedBlock lBlk, short replication, NetworkTopology cluster) {
    try {// w  w w .jav a2 s  . c o  m
        Class<?> replicationTargetChooserClass = Class
                .forName("org.apache.hadoop.hdfs.server.namenode.ReplicationTargetChooser");
        Method verifyBlockPlacementMethod = replicationTargetChooserClass.getDeclaredMethod(
                "verifyBlockPlacement", LocatedBlock.class, Short.TYPE, NetworkTopology.class);
        verifyBlockPlacementMethod.setAccessible(true);

        return (Integer) verifyBlockPlacementMethod.invoke(null, lBlk, new Short(replication), cluster);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    } catch (SecurityException e) {
        throw new RuntimeException(e);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    } catch (IllegalArgumentException e) {
        throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (InvocationTargetException e) {
        Throwable cause = e.getCause();
        if (cause instanceof RuntimeException) {
            cause.printStackTrace();
            throw (RuntimeException) cause;
        } else {
            throw new RuntimeException(e);
        }
    }
}

From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.ShortCalculator.java

public Object mul(Object obj1, Object obj2) {
    Short shortData1 = (Short) obj1;
    Short shortData2 = (Short) obj2;

    return (Object) (new Short((short) (shortData1.shortValue() * shortData2.shortValue())));
}

From source file:com.igorbaiborodine.example.mybatis.customer.TestCustomerMapper.java

@Test
public void testSelectByPrimaryKey() {
    Short customerId = new Short("1");
    Customer customer = _customerMapper.selectByPrimaryKey(customerId);

    assertNotNull("test select by primary key failed - customer must not be null", customer);
    _logger.debug(String.format("retrieved ", customer.toString()));
    assertTrue("test select by primary key failed - customer id must not be different",
            customerId.equals(customer.getCustomerId()));
}

From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.ShortCalculator.java

public Object sub(Object obj1, Object obj2) {
    Short shortData1 = (Short) obj1;
    Short shortData2 = (Short) obj2;

    return (Object) (new Short((short) (shortData1.shortValue() - shortData2.shortValue())));
}

From source file:Main.java

/**
 * <p>Inserts the specified element at the specified position in the array. 
 * Shifts the element currently at that position (if any) and any subsequent
 * elements to the right (adds one to their indices).</p>
 *
 * <p>This method returns a new array with the same elements of the input
 * array plus the given element on the specified position. The component 
 * type of the returned array is always the same as that of the input 
 * array.</p>/* w  w  w . jav a  2 s .  co m*/
 *
 * <p>If the input array is <code>null</code>, a new one element array is returned
 *  whose component type is the same as the element.</p>
 * 
 * <pre>
 * ArrayUtils.add([1], 0, 2)         = [2, 1]
 * ArrayUtils.add([2, 6], 2, 10)     = [2, 6, 10]
 * ArrayUtils.add([2, 6], 0, -4)     = [-4, 2, 6]
 * ArrayUtils.add([2, 6, 3], 2, 1)   = [2, 6, 1, 3]
 * </pre>
 * 
 * @param array  the array to add the element to, may be <code>null</code>
 * @param index  the position of the new object
 * @param element  the object to add
 * @return A new array containing the existing elements and the new element
 * @throws IndexOutOfBoundsException if the index is out of range 
 * (index < 0 || index > array.length).
 */
public static short[] add(short[] array, int index, short element) {
    return (short[]) add(array, index, new Short(element), Short.TYPE);
}

From source file:com.impetus.kundera.utils.NumericUtils.java

/**
 *  Check if zero//from   ww  w .  ja va  2s .  c  o m
 * @param value        value string
 * @param valueClazz   value class 
 * @return             
 */
public static final boolean checkIfZero(String value, Class valueClazz) {
    boolean returnValue = false;
    if (value != null && NumberUtils.isNumber(value) && numberTypes.get(valueClazz) != null) {
        switch (numberTypes.get(valueClazz)) {

        case INTEGER:
            returnValue = Integer.parseInt(value) == (NumberUtils.INTEGER_ZERO);
            break;

        case FLOAT:
            returnValue = Float.parseFloat(value) == (NumberUtils.FLOAT_ZERO);
            break;

        case LONG:
            returnValue = Long.parseLong(value) == (NumberUtils.LONG_ZERO);
            break;

        case BIGDECIMAL:
            returnValue = new BigDecimal(value) == (BigDecimal.ZERO);
            break;

        case BIGINTEGER:
            returnValue = new BigInteger(value) == (BigInteger.ZERO);
            break;

        case SHORT:
            returnValue = new Short(value) == (NumberUtils.SHORT_ZERO);
            break;
        }
    }

    return returnValue;
}

From source file:com.bitranger.parknshop.admin.CtrlIndex.java

@RequestMapping(value = "/admin", method = RequestMethod.GET)
public ModelAndView adminIndex(ModelAndView mv) {

    inject(mv);//  ww  w  . j  a va 2s .co m

    mv.setViewName("admin");

    List ls = psAdministratorDAO.findAll();
    if (ls != null && ls.size() > 0)
        mv.addObject("cur_admin", ls.get(0));
    else {
        System.out.println("CtrlIndex.adminIndex()");
        System.err.println("No admin");
    }

    mv.addObject("shopapply_list", psShopApplyDAO.findAll());
    mv.addObject("notice_list", psNoticeAdminDAO.findByIsValid(new Short((short) 1)));
    mv.addObject("seller_list", psSellerDAO.findAll(new FetchOption().descending().limit(20)));
    mv.addObject("buyer_list", psCustomerDAO.findAll(new FetchOption().descending().limit(50)));
    mv.addObject("ad_list", psPromotItemDAO.findAllValid());

    mv.addObject("order_list", psOrderDAO.findAll(OrderStatus.FINISHED));
    mv.addObject("count_orders", psOrderDAO.findAll(OrderStatus.FINISHED).size());

    double tnxV = psOrderDAO.countTnxVolumn();
    mv.addObject("tnx_volumn", tnxV);
    double ro = tnxV * 0.01;
    double ra = psPromotItemDAO.calAdRevenue();
    double sum = ro + ra;
    mv.addObject("revenue_orders", ro);
    mv.addObject("revenue_ads", ra);
    mv.addObject("ratio_order", ro / sum);
    mv.addObject("ratio_ad", ra / sum);

    return mv;
}

From source file:org.openmrs.module.sync.SyncUtilTest.java

@Test
public void getSetterMethod_shouldReturnMethodForPrimitiveShort() {
    Method m = SyncUtil.getSetterMethod(new Xform().getClass(), "shortField", new Short((short) 1).getClass());
    Assert.notNull(m);//from   w  w  w .j  a v  a  2 s .  co  m
}

From source file:org.lightadmin.core.util.NumberUtils.java

@SuppressWarnings("unchecked")
public static <T extends Number> T convertNumberToTargetClass(Number number, Class<T> targetClass)
        throws IllegalArgumentException {
    Assert.notNull(number, "Number must not be null");
    Assert.notNull(targetClass, "Target class must not be null");

    if (targetClass.isInstance(number)) {
        return (T) number;
    } else if (targetClass.equals(byte.class)) {
        long value = number.longValue();
        if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }/*from  w  w w . j a  va  2s .  c  o  m*/
        return (T) new Byte(number.byteValue());
    } else if (targetClass.equals(short.class)) {
        long value = number.longValue();
        if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Short(number.shortValue());
    } else if (targetClass.equals(int.class)) {
        long value = number.longValue();
        if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Integer(number.intValue());
    } else if (targetClass.equals(long.class)) {
        return (T) new Long(number.longValue());
    } else if (targetClass.equals(float.class)) {
        return (T) Float.valueOf(number.toString());
    } else if (targetClass.equals(double.class)) {
        return (T) Double.valueOf(number.toString());
    } else {
        return org.springframework.util.NumberUtils.convertNumberToTargetClass(number, targetClass);
    }
}

From source file:agilejson.JSON.java

/**
 * This method takes in a primitive that has been converted to an object
 * and creates a copy of it so that .equals results in different objects.
 * @param v/*from  w w  w  .  j  a v a2 s. c  o  m*/
 * @throws java.lang.Exception
 */
private static Object getObjectForPrimitive(Object v) throws Exception {
    Class c = v.getClass();
    if (c == Byte.class) {
        return new String(new byte[] { ((Byte) v).byteValue() });
    } else if (c == Boolean.class) {
        return new Boolean((Boolean) v);
    } else if (c == Character.class) {
        return new Character((Character) v);
    } else if (c == Short.class) {
        return new Short((Short) v);
    } else if (c == Integer.class) {
        return new Integer((Integer) v);
    } else if (c == Long.class) {
        return new Long((Long) v);
    } else if (c == Float.class) {
        return new Float((Float) v);
    } else if (c == Double.class) {
        return new Double((Double) v);
    } else {
        throw new Exception("Unknown Primitive");
    }
}