java.lang.Byte.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(159)

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

Byte.<init>介绍

[英]Constructs a new Byte with the specified primitive byte value.
[中]用指定的基元字节值构造新字节。

代码示例

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

/**
 * Returns a Byte instance representing the specified byte.
 * Byte.valueOf was added in JDK 1.5.
 *
 * @param b a byte value.
 * @return a Byte instance representing b.
 */
protected static Byte valueOf(final byte b) {
  return new Byte(b);
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * Gets the value as a Byte instance.
 * 
 * @return the value as a Byte, never null
 */
public Object getValue() {
  return new Byte(this.value);
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Converts an array of primitive bytes to objects.</p>
 *
 * <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
 *
 * @param array  a <code>byte</code> array
 * @return a <code>Byte</code> array, <code>null</code> if null array input
 */
public static Byte[] toObject(byte[] array) {
  if (array == null) {
    return null;
  } else if (array.length == 0) {
    return EMPTY_BYTE_OBJECT_ARRAY;
  }
  final Byte[] result = new Byte[array.length];
  for (int i = 0; i < array.length; i++) {
    result[i] = new Byte(array[i]);
  }
  return result;
}

代码示例来源:origin: google/j2objc

/**
 * Asserts that two bytes are equal. If they are not
 * an AssertionFailedError is thrown with the given message.
 */
static public void assertEquals(String message, byte expected, byte actual) {
  assertEquals(message, new Byte(expected), new Byte(actual));
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * Gets this mutable as an instance of Byte.
 *
 * @return a Byte instance containing the value from this mutable
 */
public Byte toByte() {
  return new Byte(byteValue());
}

代码示例来源:origin: spring-projects/spring-loaded

public String setByte() throws Exception {
  Field f = JLRFSetTheRestVariant.class.getDeclaredField("b");
  f.set(this, new Byte("123"));
  return Byte.toString(b);
}

代码示例来源:origin: apache/incubator-dubbo

/**
 * Creates a map of the classes fields.
 */
protected static Object getParamArg(Class cl) {
  if (!cl.isPrimitive())
    return null;
  else if (boolean.class.equals(cl))
    return Boolean.FALSE;
  else if (byte.class.equals(cl))
    return new Byte((byte) 0);
  else if (short.class.equals(cl))
    return new Short((short) 0);
  else if (char.class.equals(cl))
    return new Character((char) 0);
  else if (int.class.equals(cl))
    return Integer.valueOf(0);
  else if (long.class.equals(cl))
    return Long.valueOf(0);
  else if (float.class.equals(cl))
    return Float.valueOf(0);
  else if (double.class.equals(cl))
    return Double.valueOf(0);
  else
    throw new UnsupportedOperationException();
}

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

Object getValue(ClassLoader cl, ClassPool cp, Method m) {
  return new Byte(getValue());
}

代码示例来源:origin: google/guava

@Generates
private Byte generateByteObject() {
 return new Byte(generateByte());
}

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

@Override
public Object coerceElement(Class arrType, Object value) {
  if ( value instanceof Number ) {
    Number n = (Number) value;
    if ( arrType == Byte.class ) {
      return new Byte(n.byteValue());
    } else if ( arrType == Short.class ) {
      return new Short(n.shortValue());
    } else if ( arrType == Integer.class ) {
      return new Integer(n.intValue());
    } else if ( arrType == Long.class ) {
      return new Long(n.longValue());
    } else if ( arrType == Double.class ) {
      return new Double(n.doubleValue());
    } else if ( arrType == Float.class ) {
      return new Float(n.floatValue());
    } else if ( arrType == Character.class ) {
      return new Character((char) n.intValue());
    }
  }
  return value;
}

代码示例来源:origin: commons-collections/commons-collections

/**
 * Get a byte associated with the given configuration key.
 *
 * @param key The configuration key.
 * @param defaultValue The default value.
 * @return The associated byte.
 * @throws ClassCastException is thrown if the key maps to an
 * object that is not a Byte.
 * @throws NumberFormatException is thrown if the value mapped
 * by the key has not a valid number format.
 */
public byte getByte(String key, byte defaultValue) {
  return getByte(key, new Byte(defaultValue)).byteValue();
}

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

public Object read(InputStream in) {
    return new Byte(in.read_octet());
  }
}

代码示例来源:origin: commons-collections/commons-collections

public Object[] getSampleValues() {
  Object[] values = new Object[] {
    new Integer(1234),
    new Long(1298341928234L),
    new Double(123423.34),
    new Float(1213332.12f),
    new Short((short)134),
    new Byte((byte)10),
    new Character('a'),
    new Integer(1432),
    "SomeStringValue",
    objectInFullMap,
    BeanWithProperties.class,
  };
  return values;
}

代码示例来源:origin: commons-collections/commons-collections

public Object[] getNewSampleValues() {
  Object[] values = new Object[] {
    new Integer(223),
    new Long(23341928234L),
    new Double(23423.34),
    new Float(213332.12f),
    new Short((short)234),
    new Byte((byte)20),
    new Character('b'),
    new Integer(232),
    "SomeNewStringValue",
    new Object(),
    null,
  };
  return values;
}

代码示例来源:origin: commons-beanutils/commons-beanutils

/**
 * Sets the default value for Byte conversions.
 * @param newDefaultByte The default Byte value
 * @deprecated Register replacement converters for Byte.TYPE and
 *  Byte.class instead
 */
@Deprecated
public void setDefaultByte(final byte newDefaultByte) {
  defaultByte = new Byte(newDefaultByte);
  register(new ByteConverter(defaultByte), Byte.TYPE);
  register(new ByteConverter(defaultByte), Byte.class);
}

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

/**
 * Sets the default value for Byte conversions.
 * @param newDefaultByte The default Byte value
 * @deprecated Register replacement converters for Byte.TYPE and
 *  Byte.class instead
 */
@Deprecated
public void setDefaultByte(final byte newDefaultByte) {
  defaultByte = new Byte(newDefaultByte);
  register(new ByteConverter(defaultByte), Byte.TYPE);
  register(new ByteConverter(defaultByte), Byte.class);
}

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

@Test
public void testByteType() {
  final Byte original = 0;
  final Byte copy = new Byte( (byte) 0 );
  final Byte different = 9;
  runBasicTests( ByteType.INSTANCE, original, copy, different );
}

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

/**
 * @throws Exception If failed.
 */
@Test
public void testByte() throws Exception {
  byte val = 10;
  assertEquals(new Byte(val), marshalUnmarshal(val));
}

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

public void testByteDataTypeAsDays() throws HiveException {
 GenericUDFDateAdd udf = new GenericUDFDateAdd();
 ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
 ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaByteObjectInspector;
 ObjectInspector[] arguments = {valueOI1, valueOI2};
 udf.initialize(arguments);
 DeferredObject valueObj1 = new DeferredJavaObject(new DateWritableV2(Date.of(109, 06, 20)));
 DeferredObject valueObj2 = new DeferredJavaObject(new Byte("4"));
 DeferredObject[] args = {valueObj1, valueObj2};
 DateWritableV2 output = (DateWritableV2) udf.evaluate(args);
 assertEquals("date_add() test for BYTE failed ", "0109-06-24", output.toString());
}

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

public void testByteDataTypeAsDays() throws HiveException {
 GenericUDFDateSub udf = new GenericUDFDateSub();
 ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
 ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaByteObjectInspector;
 ObjectInspector[] arguments = {valueOI1, valueOI2};
 udf.initialize(arguments);
 DeferredObject valueObj1 = new DeferredJavaObject(new DateWritableV2(Date.of(109, 06, 20)));
 DeferredObject valueObj2 = new DeferredJavaObject(new Byte("4"));
 DeferredObject[] args = {valueObj1, valueObj2};
 DateWritableV2 output = (DateWritableV2) udf.evaluate(args);
 assertEquals("date_add() test for BYTE failed ", "0109-06-16", output.toString());
}

相关文章