public byte[] serialize(String topic, Short data) { if (data == null) return null; return new byte[] { (byte) (data >>> 8), data.byteValue() }; }
@Override public byte[] encode(Short message) { if (null == message) { return null; } else { return new byte[] { (byte) (message >>> 8), message.byteValue() }; } }
public Byte toByte(Short self) { return self.byteValue(); } }
@SuppressWarnings({ "unchecked" }) @Override public <X> X unwrap(Short value, Class<X> type, WrapperOptions options) { if ( value == null ) { return null; } if ( Short.class.isAssignableFrom( type ) ) { return (X) value; } if ( Byte.class.isAssignableFrom( type ) ) { return (X) Byte.valueOf( value.byteValue() ); } if ( Integer.class.isAssignableFrom( type ) ) { return (X) Integer.valueOf( value.intValue() ); } if ( Long.class.isAssignableFrom( type ) ) { return (X) Long.valueOf( value.longValue() ); } if ( Double.class.isAssignableFrom( type ) ) { return (X) Double.valueOf( value.doubleValue() ); } if ( Float.class.isAssignableFrom( type ) ) { return (X) Float.valueOf( value.floatValue() ); } if ( String.class.isAssignableFrom( type ) ) { return (X) value.toString(); } throw unknownUnwrap( type ); } @Override
return ((Short) value).byteValue();
@Test public void testIntToByteWithShort() { Short value = 1000; initial.setRegisters(0, value, "S"); expected.setRegisters(0, value.byteValue(), "B"); VMTester.test(CLASS_NAME, "intToByte()V", initial, expected); }
Short.valueOf("FF",16).byteValue(); // -1 (byte) Integer.valueOf("FFFF",16).shortValue(); // -1 (short) Long.valueOf("FFFFFFFF",16).intValue(); // -1 (int) new BigInteger("FFFFFFFFFFFFFFFF",16).longValue(); // -1 (long)
protected Byte coerceToByte(Object value) { if (value == null || "".equals(value)) { return Byte.valueOf((byte)0); } if (value instanceof Byte) { return (Byte)value; } if (value instanceof Number) { return Byte.valueOf(((Number)value).byteValue()); } if (value instanceof String) { try { return Byte.valueOf((String)value); } catch (NumberFormatException e) { throw new ELException(LocalMessages.get("error.coerce.value", value, Byte.class)); } } if (value instanceof Character) { return Byte.valueOf(Short.valueOf((short)((Character)value).charValue()).byteValue()); } throw new ELException(LocalMessages.get("error.coerce.type", value.getClass(), Byte.class)); }
protected Byte coerceToByte(Object value) { if (value == null || "".equals(value)) { return Byte.valueOf((byte)0); } if (value instanceof Byte) { return (Byte)value; } if (value instanceof Number) { return Byte.valueOf(((Number)value).byteValue()); } if (value instanceof String) { try { return Byte.valueOf((String)value); } catch (NumberFormatException e) { throw new ELException(LocalMessages.get("error.coerce.value", value, Byte.class)); } } if (value instanceof Character) { return Byte.valueOf(Short.valueOf((short)((Character)value).charValue()).byteValue()); } throw new ELException(LocalMessages.get("error.coerce.type", value.getClass(), Byte.class)); }
"0" + value.substring(i + 1, j)).byteValue()); i = j - 1;
@Override public Byte getByte() { return value.byteValue(); }
public Object convert(Object o) { return ((Short) o).byteValue(); } });
@Override public byte[] encode(Short message) { if (null == message) { return null; } else { return new byte[] { (byte) (message >>> 8), message.byteValue() }; } }
public Byte toByte(Short self) { return self.byteValue(); } }
/** * {@inheritDoc} */ public Object convert(final Object object) { return new Byte(((Short) object).byteValue()); }
static void serializeLearnHeader(final ByteBuf outBuffer, ActionLearn action) { outBuffer.writeShort(action.getNxActionLearn().getIdleTimeout().shortValue()); outBuffer.writeShort(action.getNxActionLearn().getHardTimeout().shortValue()); outBuffer.writeShort(action.getNxActionLearn().getPriority().shortValue()); outBuffer.writeLong(action.getNxActionLearn().getCookie().longValue()); outBuffer.writeShort(action.getNxActionLearn().getFlags().shortValue()); outBuffer.writeByte(action.getNxActionLearn().getTableId().byteValue()); outBuffer.writeZero(1); outBuffer.writeShort(action.getNxActionLearn().getFinIdleTimeout().shortValue()); outBuffer.writeShort(action.getNxActionLearn().getFinHardTimeout().shortValue()); }
@Override public Byte getByte(int index) { if (!isValidByte(index)) { throw new PlcIncompatibleDatatypeException(Byte.class, index); } return getValue(index).byteValue(); }
@AtlasConversionInfo(sourceType = FieldType.SHORT, targetType = FieldType.BYTE, concerns = AtlasConversionConcern.RANGE) public Byte toByte(Short value) throws AtlasConversionException { if (value == null) { return null; } if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE) { return value.byteValue(); } throw new AtlasConversionException(new AtlasUnsupportedException( String.format("Short %s is greater than Byte.MAX_VALUE or less than Byte.MIN_VALUE", value))); }
@Override public void serialize(final Action input, final ByteBuf outBuffer) { ActionConntrack action = ((ActionConntrack) input.getActionChoice()); serializeHeader(LENGTH, NXAST_CONNTRACK_SUBTYPE, outBuffer); outBuffer.writeShort(action.getNxActionConntrack().getFlags().shortValue()); outBuffer.writeInt(action.getNxActionConntrack().getZoneSrc().intValue()); outBuffer.writeShort(action.getNxActionConntrack().getConntrackZone().shortValue()); outBuffer.writeByte(action.getNxActionConntrack().getRecircTable().byteValue()); outBuffer.writeZero(5); }
private static NodeTableStatistics toNodeTableStatistics(final FlowTableStatistics tableStats, final Short tableId, final Node node) throws ConstructionException { final NodeTableStatistics it = new NodeTableStatistics(); it.setActiveCount(tableStats.getActiveFlows().getValue().intValue()); it.setLookupCount(tableStats.getPacketsLookedUp().getValue().longValue()); it.setMatchedCount(tableStats.getPacketsMatched().getValue().longValue()); it.setName(tableId.toString()); it.setNodeTable(new NodeTable(NodeTableIDType.OPENFLOW, tableId.byteValue(), node)); return it; }