List of usage examples for java.lang Short Short
@Deprecated(since = "9") public Short(String s) throws NumberFormatException
From source file:Main.java
public static ContentValues listToContentValues(List<String> values, String type) { ContentValues contentvalues = new ContentValues(); //Place values into contentvalue structure for (int i = 0; i < values.size(); i++) { String current = values.get(i); try {//from w w w.j a va2 s. com //Separate the value by = in order to get key:value Integer indexOfEquals = current.indexOf("="); String key = current.substring(0, indexOfEquals); String value = current.substring(indexOfEquals + 1); if (type.toUpperCase().equals("STRING")) contentvalues.put(key, value); if (type.toUpperCase().equals("BOOLEAN")) contentvalues.put(key, Boolean.valueOf(value)); if (type.toUpperCase().equals("INTEGER")) contentvalues.put(key, new Integer(value)); if (type.toUpperCase().equals("DOUBLE")) contentvalues.put(key, new Double(value)); if (type.toUpperCase().equals("FLOAT")) contentvalues.put(key, new Float(value)); if (type.toUpperCase().equals("LONG")) contentvalues.put(key, new Long(value)); if (type.toUpperCase().equals("SHORT")) contentvalues.put(key, new Short(value)); } catch (Exception e) { Log.e("mercury", "Error with argument " + current); } } return contentvalues; }
From source file:TreeCellRendererImplementation.java
public TreeCellRendererImplementation() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DefaultMutableTreeNode root = new DefaultMutableTreeNode("+"); root.add(new DefaultMutableTreeNode(new Integer(3))); DefaultMutableTreeNode node = new DefaultMutableTreeNode("*"); node.add(new DefaultMutableTreeNode("string")); node.add(new DefaultMutableTreeNode(new Short((short) 5))); root.add(node);/*from w ww . ja v a 2 s . com*/ TreeModel tm = new DefaultTreeModel(root); JTree tree = new JTree(tm); tree.setShowsRootHandles(true); tree.setCellRenderer(new MyRenderer()); getContentPane().add(tree, BorderLayout.CENTER); setSize(400, 300); setVisible(true); }
From source file:de.odysseus.calyxo.base.util.ParseUtils.java
private static Object nullValue(Class type) { if (type.isPrimitive()) { if (type == boolean.class) return Boolean.FALSE; if (type == byte.class) return new Byte((byte) 0); if (type == char.class) return new Character((char) 0); if (type == short.class) return new Short((short) 0); if (type == int.class) return new Integer(0); if (type == long.class) return new Long(0); if (type == float.class) return new Float(0); if (type == double.class) return new Double(0); }/*from w w w .j a v a 2 s .co m*/ return null; }
From source file:com.jaspersoft.studio.editor.preview.input.array.number.ShortElement.java
@Override protected Object convertString(String str) { return new Short(str); }
From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.ShortCalculator.java
public Object add(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.redhat.lightblue.crud.validator.MinMaxCheckerTest.java
/** * Col1: For debugging purposes to know which test case had issues * Col2: A instantiation to test with. Should always represent 2. *///from w ww.j a v a 2 s . c om @Parameters(name = "{index}: {0}") public static Collection<Object[]> data() { return Arrays.asList(new Object[][] { { Integer.class, new Integer(2) }, { Byte.class, new Byte(new Integer(2).byteValue()) }, { Short.class, new Short(new Integer(2).shortValue()) }, { Long.class, new Long(2L) }, { Float.class, new Float(2F) }, { Double.class, new Double(2D) }, { BigInteger.class, new BigInteger("2") }, { BigDecimal.class, new BigDecimal(2) } }); }
From source file:com.myJava.util.Util.java
public static Short buildOptimizedShort(short s) { if (s < -10 || s > 10) { return new Short(s); } else {//from w ww. j a v a2s . c o m return POOLED_SHORTS[s + 10]; } }
From source file:org.workin.http.httpclient.v4.handler.response.ShortResponseHandler.java
@Override public Short handleResponse(HttpResponse response) throws ClientProtocolException, IOException { String result = super.doResponse(response); if (result != null) return new Short(result); String defaultValue = super.getDefaultValue(); return StringUtils.isNotBlank(defaultValue) ? new Short(defaultValue) : null; }
From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.ShortCalculator.java
public Object div(Object obj1, Object obj2) { Short shortData1 = (Short) obj1; Short shortData2 = (Short) obj2; return (Object) (new Short((short) (shortData1.shortValue() / shortData2.shortValue()))); }
From source file:NumberUtils.java
/** * Convert the given number into an instance of the given target class. * @param number the number to convert//www . j av a 2 s.co m * @param targetClass the target class to convert to * @return the converted number * @throws IllegalArgumentException if the target class is not supported * (i.e. not a standard Number subclass as included in the JDK) * @see java.lang.Byte * @see java.lang.Short * @see java.lang.Integer * @see java.lang.Long * @see java.math.BigInteger * @see java.lang.Float * @see java.lang.Double * @see java.math.BigDecimal */ public static Number convertNumberToTargetClass(Number number, Class targetClass) throws IllegalArgumentException { if (targetClass.isInstance(number)) { return number; } else if (targetClass.equals(Byte.class)) { long value = number.longValue(); if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) { raiseOverflowException(number, targetClass); } return 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 new Short(number.shortValue()); } else if (targetClass.equals(Integer.class)) { long value = number.longValue(); if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) { raiseOverflowException(number, targetClass); } return new Integer(number.intValue()); } else if (targetClass.equals(Long.class)) { return new Long(number.longValue()); } else if (targetClass.equals(Float.class)) { return new Float(number.floatValue()); } else if (targetClass.equals(Double.class)) { return new Double(number.doubleValue()); } else if (targetClass.equals(BigInteger.class)) { return BigInteger.valueOf(number.longValue()); } else if (targetClass.equals(BigDecimal.class)) { // using BigDecimal(String) here, to avoid unpredictability of BigDecimal(double) // (see BigDecimal javadoc for details) return new BigDecimal(number.toString()); } else { throw new IllegalArgumentException("Could not convert number [" + number + "] of type [" + number.getClass().getName() + "] to unknown target class [" + targetClass.getName() + "]"); } }