public byte[] serialize(String topic, Integer data) { if (data == null) return null; return new byte[] { (byte) (data >>> 24), (byte) (data >>> 16), (byte) (data >>> 8), data.byteValue() }; }
public Byte toByte(Integer self) { return self.byteValue(); } }
@Override public byte[] encode(Integer message) { if (null == message) { return null; } else { return new byte[] { (byte) (message >>> 24), (byte) (message >>> 16), (byte) (message >>> 8), message.byteValue() }; } }
public byte byteValueOf(Integer integer) { return integer.byteValue(); } }
private byte getOffset(String cap) { Integer offset = offsets.get(cap); return offset == null ? 0 : offset.byteValue(); }
private static Byte intToByte(Integer input) { if (input == null) { return null; } return input.byteValue(); }
public static byte randomByte() { return Integer.valueOf(RandomUtil.random.nextInt()).byteValue(); }
public static Byte parseByte(String body, String field) { ObjectMapper mapper = new ObjectMapper(); JsonNode node = null; try { node = mapper.readTree(body); JsonNode leaf = node.get(field); if (leaf != null) { Integer value = leaf.asInt(); return value.byteValue(); } } catch (IOException e) { e.printStackTrace(); } return null; }
public static byte[] fromHex(String digest) { checkNotNull(digest, "The digest should not be null"); byte[] bytes = new byte[digest.length() / 2]; for (int i = 0; i < bytes.length; i++) { bytes[i] = Integer.valueOf(digest.substring(i * 2, (i + 1) * 2), 16).byteValue(); } return bytes; }
public static byte[] fromHex(String digest) { checkNotNull(digest, "The digest should not be null"); byte[] bytes = new byte[digest.length() / 2]; for (int i = 0; i < bytes.length; i++) { bytes[i] = Integer.valueOf(digest.substring(i * 2, (i + 1) * 2), 16).byteValue(); } return bytes; }
public void toBytes(Object object, DataOutputStream output) throws IOException { Integer newestVersion = typeDefVersions.lastKey(); JsonTypeDefinition typeDef = typeDefVersions.get(newestVersion); if(hasVersion) output.writeByte(newestVersion.byteValue()); write(output, object, typeDef.getType()); }
@Override public RevisionType nullSafeGet(ResultSet resultSet, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { final Integer representationInt = IntegerType.INSTANCE.nullSafeGet( resultSet, names[0], session ); return representationInt == null ? null : RevisionType.fromRepresentation( representationInt.byteValue() ); }
public byte getByte(int parameterIndex) throws SQLException { checkClosed(); // fake tiny int with smallint checkIndex(parameterIndex, Types.SMALLINT, "Byte"); if (callResult[parameterIndex - 1] == null) { return 0; } return ((Integer) callResult[parameterIndex - 1]).byteValue(); }
public byte getByte(int parameterIndex) throws SQLException { checkClosed(); // fake tiny int with smallint checkIndex (parameterIndex, Types.SMALLINT, "Byte"); if (callResult[parameterIndex-1] == null) return 0; return ((Integer)callResult[parameterIndex-1]).byteValue(); }
@Override protected Byte[] getSortedTestData() { Random rnd = new Random(874597969123412338L); int rndByte = rnd.nextInt(Byte.MAX_VALUE); if (rndByte < 0) { rndByte = -rndByte; } if (rndByte == Byte.MAX_VALUE) { rndByte -= 3; } if (rndByte <= 2) { rndByte += 3; } return new Byte[]{ Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Integer.valueOf(-rndByte).byteValue()), Byte.valueOf(Integer.valueOf(-1).byteValue()), Byte.valueOf(Integer.valueOf(0).byteValue()), Byte.valueOf(Integer.valueOf(1).byteValue()), Byte.valueOf(Integer.valueOf(2).byteValue()), Byte.valueOf(Integer.valueOf(rndByte).byteValue()), Byte.valueOf(Byte.MAX_VALUE)}; } }
public byte[] toBytes(StringOrder object) { return new byte[] { object.getId().byteValue() }; }
@Override protected ByteValue[] getSortedTestData() { Random rnd = new Random(874597969123412338L); int rndByte = rnd.nextInt(Byte.MAX_VALUE); if (rndByte < 0) { rndByte = -rndByte; } if (rndByte == Byte.MAX_VALUE) { rndByte -= 3; } if (rndByte <= 2) { rndByte += 3; } return new ByteValue[]{ new ByteValue(Byte.MIN_VALUE), new ByteValue(Integer.valueOf(-rndByte).byteValue()), new ByteValue(Integer.valueOf(-1).byteValue()), new ByteValue(Integer.valueOf(0).byteValue()), new ByteValue(Integer.valueOf(1).byteValue()), new ByteValue(Integer.valueOf(2).byteValue()), new ByteValue(Integer.valueOf(rndByte).byteValue()), new ByteValue(Byte.MAX_VALUE)}; } }
@Test public void canIntToByte() { Integer value = 10; when(item.getValue()).thenReturn(value); when(item.getType()).thenReturn("I"); when(instruction.getOpcode()).thenReturn(Opcode.INT_TO_BYTE); op = (UnaryMathOp) opFactory.create(location, addressToLocation, vm); op.execute(node, mState); verify(mState, times(1)).assignRegister(eq(REGISTER_A), eq(new HeapItem(value.byteValue(), "B"))); }
private byte readBinarySubtypeFromExtendedJson() { JsonToken subTypeToken = popToken(); if (subTypeToken.getType() != JsonTokenType.STRING && subTypeToken.getType() != JsonTokenType.INT32) { throw new JsonParseException("JSON reader expected a string or number but found '%s'.", subTypeToken.getValue()); } if (subTypeToken.getType() == JsonTokenType.STRING) { return (byte) Integer.parseInt(subTypeToken.getValue(String.class), 16); } else { return subTypeToken.getValue(Integer.class).byteValue(); } }
@Test public void testIntToByte() { Integer value = 128; initial.setRegisters(0, value, "I"); expected.setRegisters(0, value.byteValue(), "B"); VMTester.test(CLASS_NAME, "intToByte()V", initial, expected); }