List of usage examples for java.lang Byte Byte
@Deprecated(since = "9") public Byte(String s) throws NumberFormatException
From source file:com.ning.metrics.serialization.hadoop.pig.SmileStorage.java
private Object getJsonValue(final SchemaFieldType type, final JsonNode node) { switch (type) { case BOOLEAN: return node.intValue(); case BYTE:/* w w w . j a v a 2 s . c om*/ return new Byte(node.textValue()); case SHORT: case INTEGER: return node.intValue(); case LONG: case DATE: return node.longValue(); case DOUBLE: return node.doubleValue(); case IP: case STRING: default: return node.textValue(); } }
From source file:org.wisdom.template.thymeleaf.OgnlOpsByReflectionTest.java
@Test public void testNewInteger() throws Exception { Class[] classes = new Class[] { Integer.TYPE, Long.TYPE }; assertThat(invoke("newInteger", classes, NumericTypes.INT, 42l)).isEqualTo(42); assertThat(invoke("newInteger", classes, NumericTypes.LONG, 42l)).isEqualTo(42l); assertThat(invoke("newInteger", classes, NumericTypes.BYTE, 8)).isEqualTo(new Byte("8")); assertThat(invoke("newInteger", classes, NumericTypes.SHORT, 42)).isEqualTo(new Short("42")); // Also works with float and double, but only if there are no decimal part assertThat(invoke("newInteger", classes, NumericTypes.FLOAT, 42)).isEqualTo(42f); assertThat(invoke("newInteger", classes, NumericTypes.DOUBLE, 42)).isEqualTo(42d); }
From source file:com.jaspersoft.jasperserver.api.engine.common.service.impl.HibernateLoggingService.java
@Transactional(propagation = Propagation.REQUIRED) public int getUserEventsCount(ExecutionContext context) { //TODO: FIXME - at the moment method returns all the events. String username = securityContextProvider.getContextUsername(); List result = getHibernateTemplate().find("select count(*) from RepoLogEvent where state=?", new Byte(LogEvent.STATE_UNREAD)); if (result != null) { return (Integer) result.get(0); }/*from w w w. j a va 2 s.c o m*/ return 0; }
From source file:com.eryansky.common.utils.SysUtils.java
/** * /*from www .ja va 2 s . c o m*/ * * @param in * ? * @return */ public static String unZip_Str(byte[] in) { Inflater decompresser = new Inflater(); decompresser.setInput(in); ArrayList<Byte> al = new ArrayList<Byte>(); byte[] result; int count = 0; for (; !decompresser.finished();) { result = new byte[100]; try { count += decompresser.inflate(result); } catch (DataFormatException e) { e.printStackTrace(); } for (int i = 0; i < result.length; i++) { al.add(new Byte(result[i])); } } result = new byte[al.size()]; for (int i = 0; i < al.size(); i++) { result[i] = (al.get(i)).byteValue(); } decompresser.end(); try { return new String(result, 0, count, "UTF-8"); } catch (UnsupportedEncodingException e) { return ""; } }
From source file:org.ff4j.commonsconf.FF4JConfigurationTest.java
@Test public void testgetByteDefault() { // Given//from ww w. j a v a 2 s . co m Assert.assertTrue(ff4jConf.containsKey("propByte")); // When Assert.assertEquals("123", ff4jConf.getString("propByte")); Assert.assertEquals(new Byte("120"), (Byte) ff4jConf.getByte("invalid", new Byte("120"))); Assert.assertEquals(new Byte("120").byteValue(), ff4jConf.getByte("invalid", new Byte("120").byteValue())); Assert.assertEquals(new Byte("123"), (Byte) ff4jConf.getByte("propByte", new Byte("120"))); Assert.assertEquals(new Byte("123").byteValue(), ff4jConf.getByte("propByte", new Byte("120").byteValue())); }
From source file:com.jaspersoft.jasperserver.ws.axis2.scheduling.ReportJobBeanTraslator.java
protected SortedSet toByteSet(int[] values) { SortedSet set;//from w ww .ja va 2s.c om if (values == null || values.length == 0) { set = null; } else { set = new TreeSet(); for (int i = 0; i < values.length; i++) { set.add(new Byte((byte) values[i])); } } return set; }
From source file:com.tesora.dve.db.mysql.DBTypeBasedUtilsTest.java
@Test public void mysqlConvertTest() throws Exception { ByteBuf cb;//w w w . j a v a2s.com ListOfPairs<MyFieldType, Object> expValuesConvMysql = new ListOfPairs<MyFieldType, Object>(); expValuesConvMysql.add(new Pair<MyFieldType, Object>(MyFieldType.FIELD_TYPE_LONG, new Integer(8765432))); expValuesConvMysql.add(new Pair<MyFieldType, Object>(MyFieldType.FIELD_TYPE_LONGLONG, new Long(8765432))); expValuesConvMysql .add(new Pair<MyFieldType, Object>(MyFieldType.FIELD_TYPE_SHORT, new Short((short) 5678))); expValuesConvMysql.add(new Pair<MyFieldType, Object>(MyFieldType.FIELD_TYPE_TINY, new Integer(100))); expValuesConvMysql.add(new Pair<MyFieldType, Object>(MyFieldType.FIELD_TYPE_TINY, new Byte((byte) 1))); // expValuesConvMysql.add(new Pair<MyFieldType, Object>(MyFieldType.FIELD_TYPE_BIT, new Boolean(true))); int len; for (Pair<MyFieldType, Object> expValue : expValuesConvMysql) { len = 0; if (expValue.getSecond() instanceof Byte) len = 1; cb = Unpooled.buffer(100).order(ByteOrder.LITTLE_ENDIAN); DataTypeValueFunc dtvf = DBTypeBasedUtils.getMysqlTypeFunc(expValue.getFirst(), len, 0); dtvf.writeObject(cb, expValue.getSecond()); assertEquals(expValue.getSecond(), dtvf.readObject(cb)); } }
From source file:com.edmunds.autotest.AutoTestGetterSetter.java
private static Map<Class<?>, Object> createDefaultValueMap() { Map<Class<?>, Object> valueMap = new HashMap<Class<?>, Object>(); valueMap.put(byte.class, new Byte((byte) 0)); valueMap.put(short.class, new Short((short) 0)); valueMap.put(int.class, new Integer(0)); valueMap.put(long.class, new Long(0)); valueMap.put(float.class, new Float(0)); valueMap.put(double.class, new Double(0)); valueMap.put(boolean.class, Boolean.FALSE); valueMap.put(char.class, new Character((char) 0)); valueMap.put(Byte.class, new Byte((byte) 0)); valueMap.put(Short.class, new Short((short) 0)); valueMap.put(Integer.class, new Integer(0)); valueMap.put(Long.class, new Long(0)); valueMap.put(Float.class, new Float(0)); valueMap.put(Double.class, new Double(0)); valueMap.put(Boolean.class, Boolean.FALSE); valueMap.put(Character.class, new Character((char) 0)); return valueMap; }
From source file:com.dreamlinx.automation.DINRelay.java
/** * This method returns a message digest of the given string using the * MD5 message digest algorithm. If the MD5 algorithm is not available in * the caller's environment, then the original message is returned. * * @param value Arbitrary length message to digest. * @return 32 character MD5 message digest of given message. *//*from ww w.j a v a2 s .c o m*/ public String toMD5(String value) { byte axMsg[] = value.getBytes(); try { MessageDigest md5 = MessageDigest.getInstance("MD5"); byte axMD5[] = md5.digest(axMsg); StringBuffer sbMD5 = new StringBuffer(axMD5.length * 2); for (int iByteIdx = 0; iByteIdx < axMD5.length; iByteIdx++) { String hexByte = "0" + Integer.toHexString(new Byte(axMD5[iByteIdx]).intValue()); sbMD5.append(hexByte.substring(hexByte.length() - 2)); } return sbMD5.toString().toLowerCase(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return value; } }
From source file:com.projity.util.ClassUtils.java
/** * Convert a Double to an Object of a given class * @param value Double value to convert//from w ww. ja v a 2 s . c o m * @param clazz Class the class to convert to * @return new object of the given class * @throws IllegalArgumentException if the value is not convertible to the class */ public static Object doubleToObject(Double value, Class clazz) { if (clazz == Boolean.class) return new Boolean(value.doubleValue() != 0.0); else if (clazz == Byte.class) return new Byte(value.byteValue()); else if (clazz == Short.class) return new Short(value.shortValue()); else if (clazz == Integer.class) return new Integer(value.intValue()); else if (clazz == Long.class) return new Long(value.longValue()); else if (clazz == Float.class) return new Float(value.floatValue()); else if (clazz == Double.class) return value; else if (clazz == Money.class) return Money.getInstance(value.doubleValue()); else if (clazz == Duration.class) return Duration.getInstanceFromDouble(value); else if (clazz == Work.class) return Work.getWorkInstanceFromDouble(value); throw new IllegalArgumentException("Class " + clazz + " cannot be converted from a Double"); }