java.lang.Short.byteValue()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中java.lang.Short.byteValue()方法的一些代码示例,展示了Short.byteValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Short.byteValue()方法的具体详情如下:
包路径:java.lang.Short
类名称:Short
方法名:byteValue

Short.byteValue介绍

[英]Returns the value of this Short as a byte.
[中]以字节形式返回此短字符的值。

代码示例

代码示例来源:origin: apache/kafka

public byte[] serialize(String topic, Short data) {
  if (data == null)
    return null;
  return new byte[] {
    (byte) (data >>> 8),
    data.byteValue()
  };
}

代码示例来源:origin: apache/pulsar

@Override
public byte[] encode(Short message) {
  if (null == message) {
    return null;
  } else {
    return new byte[] {
      (byte) (message >>> 8),
      message.byteValue()
    };
  }
}

代码示例来源:origin: jfinal/jfinal

public Byte toByte(Short self) {
    return self.byteValue();
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@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

代码示例来源:origin: prestodb/presto

return ((Short) value).byteValue();

代码示例来源:origin: CalebFenton/simplify

@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);
}

代码示例来源:origin: stackoverflow.com

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)

代码示例来源:origin: camunda/camunda-bpm-platform

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));
}

代码示例来源:origin: camunda/camunda-bpm-platform

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));
}

代码示例来源:origin: apache/tika

"0" + value.substring(i + 1, j)).byteValue());
i = j - 1;

代码示例来源:origin: com.ning/metrics.serialization-thrift

@Override
public Byte getByte()
{
  return value.byteValue();
}

代码示例来源:origin: org.mvel/mvel2

public Object convert(Object o) {
  return ((Short) o).byteValue();
 }
});

代码示例来源:origin: org.apache.pulsar/pulsar-client-schema

@Override
public byte[] encode(Short message) {
  if (null == message) {
    return null;
  } else {
    return new byte[] {
      (byte) (message >>> 8),
      message.byteValue()
    };
  }
}

代码示例来源:origin: com.jfinal/jfinal

public Byte toByte(Short self) {
    return self.byteValue();
  }
}

代码示例来源:origin: org.codehaus.castor/castor-jdo

/**
 * {@inheritDoc}
 */
public Object convert(final Object object) {
  return new Byte(((Short) object).byteValue());
}

代码示例来源:origin: org.opendaylight.openflowplugin/openflowjava-extension-nicira

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());
}

代码示例来源:origin: org.apache.plc4x/plc4j-protocol-driver-base

@Override
public Byte getByte(int index) {
  if (!isValidByte(index)) {
    throw new PlcIncompatibleDatatypeException(Byte.class, index);
  }
  return getValue(index).byteValue();
}

代码示例来源:origin: io.atlasmap/atlas-core

@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)));
}

代码示例来源:origin: org.opendaylight.openflowplugin/openflowjava-extension-nicira

@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);
}

代码示例来源:origin: org.opendaylight.openflowplugin.legacy/sal-compatibility

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;
}

相关文章