List of usage examples for java.lang Byte Byte
@Deprecated(since = "9") public Byte(String s) throws NumberFormatException
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 ww w . j a v a 2 s . c o m*/ @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:org.goko.core.common.GkUtils.java
public static List<Byte> addBytesArray(List<Byte> lst, byte[] arr) { if (arr != null) { for (int i = 0; i < arr.length; i++) { lst.add(new Byte(arr[i])); }//from w ww . ja va 2 s. c o m } return lst; }
From source file:Uuid32Generator.java
public String generate() { StringBuilder strRetVal = new StringBuilder(); String strTemp;//from w w w. j a v a2 s . co m try { // IPAddress segment InetAddress addr = InetAddress.getLocalHost(); byte[] ipaddr = addr.getAddress(); for (byte anIpaddr : ipaddr) { Byte b = new Byte(anIpaddr); strTemp = Integer.toHexString(b.intValue() & 0x000000ff); strRetVal.append(ZEROS.substring(0, 2 - strTemp.length())); strRetVal.append(strTemp); } strRetVal.append(':'); // CurrentTimeMillis() segment strTemp = Long.toHexString(System.currentTimeMillis()); strRetVal.append(ZEROS.substring(0, 12 - strTemp.length())); strRetVal.append(strTemp).append(':'); // random segment SecureRandom prng = SecureRandom.getInstance("SHA1PRNG"); strTemp = Integer.toHexString(prng.nextInt()); while (strTemp.length() < 8) { strTemp = '0' + strTemp; } strRetVal.append(strTemp.substring(4)).append(':'); // IdentityHash() segment strTemp = Long.toHexString(System.identityHashCode(this)); strRetVal.append(ZEROS.substring(0, 8 - strTemp.length())); strRetVal.append(strTemp); } catch (UnknownHostException uhex) { throw new RuntimeException("Unknown host.", uhex); } catch (NoSuchAlgorithmException nsaex) { throw new RuntimeException("Algorithm 'SHA1PRNG' is unavailiable.", nsaex); } return strRetVal.toString().toUpperCase(); }
From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.ByteCalculator.java
public Object add(Object obj1, Object obj2) { Byte byteData1 = (Byte) obj1; Byte byteData2 = (Byte) obj2; return (Object) (new Byte((byte) (byteData1.byteValue() + byteData2.byteValue()))); }
From source file:org.workin.http.httpclient.v4.handler.response.ByteResponseHandler.java
@Override public Byte handleResponse(HttpResponse response) throws ClientProtocolException, IOException { String result = super.doResponse(response); if (result != null) return new Byte(result); String defaultValue = super.getDefaultValue(); return StringUtils.isNotBlank(defaultValue) ? new Byte(defaultValue) : null; }
From source file:NumberUtils.java
/** * Convert the given number into an instance of the given target class. * @param number the number to convert/*from w w w .j av a2 s. c o 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() + "]"); } }
From source file:org.jminix.console.resource.ValueParser.java
public Object parse(String value, String type) { Object result = null;/*from ww w.j a va2 s . c om*/ if (type.equals("java.lang.String")) { return value; } else if (type.equals("java.lang.Byte") || type.equals("byte")) { if (isNullOrEmpty(value)) { return "byte".equals(type) ? (byte) 0 : null; } result = new Byte(value); } else if (type.equals("java.lang.Short") || type.equals("short")) { if (isNullOrEmpty(value)) { return "short".equals(type) ? (short) 0 : null; } result = new Short(value); } else if (type.equals("java.lang.Integer") || type.equals("int")) { if (isNullOrEmpty(value)) { return "int".equals(type) ? (int) 0 : null; } result = new Integer(value); } else if (type.equals("java.lang.Long") || type.equals("long")) { if (isNullOrEmpty(value)) { return "long".equals(type) ? (long) 0 : null; } result = new Long(value); } else if (type.equals("java.lang.Double") || type.equals("double")) { if (isNullOrEmpty(value)) { return "double".equals(type) ? (double) 0 : null; } result = new Double(value); } else if (type.equals("java.lang.Float") || type.equals("float")) { if (isNullOrEmpty(value)) { return "float".equals(type) ? (float) 0 : null; } result = new Float(value); } else if (type.equals("java.lang.Boolean") || type.equals("boolean")) { if (isNullOrEmpty(value)) { return "boolean".equals(type) ? false : null; } result = new Boolean(value); } else if (type.equals("[Ljava.lang.String;")) { result = StringUtils.splitPreserveAllTokens(value, stringArraySeparator); } if (result == null) { throw new RuntimeException("Type " + type + " is not supported"); } return result; }
From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.ByteCalculator.java
public Object div(Object obj1, Object obj2) { Byte byteData1 = (Byte) obj1; Byte byteData2 = (Byte) obj2; return (Object) (new Byte((byte) (byteData1.byteValue() / byteData2.byteValue()))); }
From source file:com.jaspersoft.studio.components.chart.model.enums.JFreeChartPlotOrientationEnum.java
/** * *///from w w w .j a va 2 s . c o m public static JFreeChartPlotOrientationEnum getByValue(byte value) { return getByValue(new Byte(value)); }
From source file:org.joda.primitives.iterator.impl.TestArrayByteIterator.java
@Override public Iterator<Byte> makeFullIterator() { byte[] data = new byte[] { new Byte((byte) 2), new Byte((byte) -2), new Byte((byte) 38), new Byte((byte) 0), new Byte((byte) 126), new Byte((byte) 202), new Byte(Byte.MIN_VALUE), new Byte(Byte.MAX_VALUE) }; return new ArrayByteIterator(data); }