@Override public float floatValue() { return (float) intValue(); }
@Override public int encode(ByteBuffer b) { if(isElementOfArray()) { if(b.remaining()>=2) { b.putShort(_value.shortValue()); return 2; } } else { if(b.remaining()>=3) { b.put((byte)0x60); b.putShort(_value.shortValue()); return 3; } } return 0; } }
public static UnsignedShort valueOf(final String value) { int intVal = Integer.parseInt(value); if(intVal < 0 || intVal >= (1<<16)) { throw new NumberFormatException("Value \""+value+"\" lies outside the range [" + 0 + "-" + (1<<16) +")."); } return valueOf((short)intVal); } }
public static UnsignedShort valueOf(short underlying) { if((underlying & 0xFF00) == 0) { return cachedValues[underlying]; } else { return new UnsignedShort(underlying); } }
public int size() { return _open.getProperties() != null ? 10 : _open.getDesiredCapabilities() != null ? 9 : _open.getOfferedCapabilities() != null ? 8 : _open.getIncomingLocales() != null ? 7 : _open.getOutgoingLocales() != null ? 6 : _open.getIdleTimeOut() != null ? 5 : (_open.getChannelMax() != null && !_open.getChannelMax().equals(UnsignedShort.MAX_VALUE)) ? 4 : (_open.getMaxFrameSize() != null && !_open.getMaxFrameSize().equals(UnsignedInteger.MAX_VALUE)) ? 3 : _open.getHostname() != null ? 2 : 1; }
@Override public String toString() { return String.valueOf(longValue()); }
public static UnsignedShort valueOf(short underlying) { if((underlying & 0xFF00) == 0) { return cachedValues[underlying]; } else { return new UnsignedShort(underlying); } }
public int size() { return _open.getProperties() != null ? 10 : _open.getDesiredCapabilities() != null ? 9 : _open.getOfferedCapabilities() != null ? 8 : _open.getIncomingLocales() != null ? 7 : _open.getOutgoingLocales() != null ? 6 : _open.getIdleTimeOut() != null ? 5 : (_open.getChannelMax() != null && !_open.getChannelMax().equals(UnsignedShort.MAX_VALUE)) ? 4 : (_open.getMaxFrameSize() != null && !_open.getMaxFrameSize().equals(UnsignedInteger.MAX_VALUE)) ? 3 : _open.getHostname() != null ? 2 : 1; }
@Override public String toString() { return String.valueOf(longValue()); }
@Override public double doubleValue() { return (double) intValue(); }
public static UnsignedShort valueOf(final String value) { int intVal = Integer.parseInt(value); if(intVal < 0 || intVal >= (1<<16)) { throw new NumberFormatException("Value \""+value+"\" lies outside the range [" + 0 + "-" + (1<<16) +")."); } return valueOf((short)intVal); } }
@Override public int encode(ByteBuffer b) { if(isElementOfArray()) { if(b.remaining()>=2) { b.putShort(_value.shortValue()); return 2; } } else { if(b.remaining()>=3) { b.put((byte)0x60); b.putShort(_value.shortValue()); return 3; } } return 0; } }
public static UnsignedShort valueOf(short underlying) { if((underlying & 0xFF00) == 0) { return cachedValues[underlying]; } else { return new UnsignedShort(underlying); } }
public int size() { return _open.getProperties() != null ? 10 : _open.getDesiredCapabilities() != null ? 9 : _open.getOfferedCapabilities() != null ? 8 : _open.getIncomingLocales() != null ? 7 : _open.getOutgoingLocales() != null ? 6 : _open.getIdleTimeOut() != null ? 5 : (_open.getChannelMax() != null && !_open.getChannelMax().equals(UnsignedShort.MAX_VALUE)) ? 4 : (_open.getMaxFrameSize() != null && !_open.getMaxFrameSize().equals(UnsignedInteger.MAX_VALUE)) ? 3 : _open.getHostname() != null ? 2 : 1; }
@Override public String toString() { return String.valueOf(longValue()); }
@Override public double doubleValue() { return (double) intValue(); }
public static UnsignedShort valueOf(final String value) { int intVal = Integer.parseInt(value); if(intVal < 0 || intVal >= (1<<16)) { throw new NumberFormatException("Value \""+value+"\" lies outside the range [" + 0 + "-" + (1<<16) +")."); } return valueOf((short)intVal); } }
@Override public int encode(ByteBuffer b) { if(isElementOfArray()) { if(b.remaining()>=2) { b.putShort(_value.shortValue()); return 2; } } else { if(b.remaining()>=3) { b.put((byte)0x60); b.putShort(_value.shortValue()); return 3; } } return 0; } }
/** * Some clients use Unsigned types from org.apache.qpid.proton.amqp * @throws Exception */ @Test(timeout = 60000) public void testUnsignedValues() throws Exception { int sequence = 42; LinkedHashMap<String, Object> map = new LinkedHashMap<>(); map.put("sequence", new UnsignedInteger(sequence)); ServerJMSMapMessage msg = createMapMessage(1, map, null); assertEquals(msg.getInt("sequence"), sequence); map.clear(); map.put("sequence", new UnsignedLong(sequence)); msg = createMapMessage(1, map, null); assertEquals(msg.getLong("sequence"), sequence); map.clear(); map.put("sequence", new UnsignedShort((short)sequence)); msg = createMapMessage(1, map, null); assertEquals(msg.getShort("sequence"), sequence); map.clear(); map.put("sequence", new UnsignedByte((byte) sequence)); msg = createMapMessage(1, map, null); assertEquals(msg.getByte("sequence"), sequence); } }
public int size() { return _open.getProperties() != null ? 10 : _open.getDesiredCapabilities() != null ? 9 : _open.getOfferedCapabilities() != null ? 8 : _open.getIncomingLocales() != null ? 7 : _open.getOutgoingLocales() != null ? 6 : _open.getIdleTimeOut() != null ? 5 : (_open.getChannelMax() != null && !_open.getChannelMax().equals(UnsignedShort.MAX_VALUE)) ? 4 : (_open.getMaxFrameSize() != null && !_open.getMaxFrameSize().equals(UnsignedInteger.MAX_VALUE)) ? 3 : _open.getHostname() != null ? 2 : 1; }