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

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

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

Short.intValue介绍

[英]Returns the value of this Short as an int.
[中]以int的形式返回此Short的值。

代码示例

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

public Integer toInt(Short self) {
  return self.intValue();
}

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

@Override
public Integer toInteger(Object value) {
 return ((Short) value).intValue();
}

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

public void set(String key, Short value) {
  if (value != null) {
    attributes.put(key, value.intValue());
  }
}

代码示例来源:origin: alibaba/mdrill

public static Integer getInt(Object o) {
  if (o instanceof Long) {
    return ((Long) o).intValue();
  } else if (o instanceof Integer) {
    return (Integer) o;
  } else if (o instanceof Short) {
    return ((Short) o).intValue();
  } else {
    throw new IllegalArgumentException("Don't know how to convert " + o
        + " + to int");
  }
}

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

private static Integer extractIntegerValue(Field field) {
    Integer rtn = null;
    try {
      Object value = field.get( null );
      if ( value instanceof Integer ) {
        rtn = (Integer) value;
      }
      else if ( value instanceof Short ) {
        rtn = ( (Short) value ).intValue();
      }
      else if ( value instanceof Long ) {
        if ( (Long) value <= Integer.MAX_VALUE ) {
          rtn = ( (Long) value ).intValue();
        }
      }
    }
    catch (IllegalAccessException ignore) {
    }
    return rtn;
  }
}

代码示例来源:origin: square/moshi

@Override public void toJson(JsonWriter writer, Short value) throws IOException {
 writer.value(value.intValue());
}

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

public static BuilderInstruction buildConstant(Short value, int register) {
  return buildConstant(value.intValue(), register);
}

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

private Integer coerceToInteger(Object o) {
  if(o == null)
    return null;
  Class<?> c = o.getClass();
  if(c == Integer.class)
    return (Integer) o;
  else if(c == Byte.class)
    return ((Byte) o).intValue();
  else if(c == Short.class)
    return ((Short) o).intValue();
  else
    throw new SerializationException("Object of type " + c.getName()
                     + " cannot be coerced to type " + JsonTypes.INT32
                     + " as the schema specifies.");
}

代码示例来源:origin: pxb1988/dex2jar

protected void printAnnotationArrayValue(final Object value) {
  if (value instanceof String[]) {
    print(((String[]) value)[1]);
  } else if (value instanceof AnnotationNode) {
    printAnnotation((AnnotationNode) value, 0, -1);
  } else if (value instanceof String) {
    print(value);
  } else if (value instanceof Byte) {
    pw.print(((Byte) value).intValue());
  } else if (value instanceof Boolean) {
    pw.print(((Boolean) value).booleanValue() ? 1 : 0);
  } else if (value instanceof Character) {
    pw.print(new Integer(((Character) value).charValue()));
  } else if (value instanceof Short) {
    pw.print(((Short) value).intValue());
  } else if (value instanceof Type) {
    pw.print(((Type) value).getDescriptor());
  } else {
    print(value);
  }
}

代码示例来源:origin: rest-assured/rest-assured

/**
 * Get the result of an Object path expression as an int.
 *
 * @param path The Object path.
 * @return The int matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
 * cannot be casted to the expected type.
 */
public int getInt(String path) {
  //The type returned from Groovy depends on the input, so we need to handle different numerical types.
  Object value = get(path);
  if (value instanceof Integer) {
    return (Integer) value;
  } else if (value instanceof Short) {
    return ((Short) value).intValue();
  } else if (value instanceof Long) {
    return ((Long) value).intValue();
  } else {
    return ObjectConverter.convertObjectTo(value, Integer.class);
  }
}

代码示例来源:origin: rest-assured/rest-assured

/**
 * Get the result of an Object path expression as an int.
 *
 * @param path The Object path.
 * @return The int matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
 * cannot be casted to the expected type.
 */
public int getInt(String path) {
  //The type returned from Groovy depends on the input, so we need to handle different numerical types.
  Object value = get(path);
  if (value instanceof Integer) {
    return (Integer) value;
  } else if (value instanceof Short) {
    return ((Short) value).intValue();
  } else if (value instanceof Long) {
    return ((Long) value).intValue();
  } else {
    return ObjectConverter.convertObjectTo(value, Integer.class);
  }
}

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

public Integer getIntProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
 Object value = doGetProperty(key);
 if (value == null) {
   return Integer.valueOf(null);
 } else if (value instanceof Integer) {
   return (Integer) value;
 } else if (value instanceof Byte) {
   return ((Byte) value).intValue();
 } else if (value instanceof Short) {
   return ((Short) value).intValue();
 } else if (value instanceof SimpleString) {
   return Integer.parseInt(((SimpleString) value).toString());
 }
 throw new ActiveMQPropertyConversionException("Invalid conversion: " + key);
}

代码示例来源:origin: json-iterator/java

public final void writeVal(Short val) throws IOException {
  if (val == null) {
    writeNull();
  } else {
    writeVal(val.intValue());
  }
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

public int readUnsignedShort() throws IOException {
  return ((Short)peekCallback().readFromStream()).intValue() & 0xffff;
}

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

@Test
public void parseNumberAsHex() {
  String aByte = "0x" + Integer.toHexString(Byte.valueOf(Byte.MAX_VALUE).intValue());
  String aShort = "0x" + Integer.toHexString(Short.valueOf(Short.MAX_VALUE).intValue());
  String anInteger = "0x" + Integer.toHexString(Integer.MAX_VALUE);
  String aLong = "0x" + Long.toHexString(Long.MAX_VALUE);
  String aReallyBigInt = "FEBD4E677898DFEBFFEE44";
  assertByteEquals(aByte);
  assertShortEquals(aShort);
  assertIntegerEquals(anInteger);
  assertLongEquals(aLong);
  assertEquals("BigInteger did not parse",
      new BigInteger(aReallyBigInt, 16), NumberUtils.parseNumber("0x" + aReallyBigInt, BigInteger.class));
}

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

@Test
public void canGetWithShortIndex() {
  Short index = 0;
  initial.setRegisters(0, new int[] { 0x42 }, "[I", 1, index, "S");
  expected.setRegisters(index.intValue(), 0x42, "I", 1, Short.valueOf(index.shortValue()), "S");
  VMTester.test(CLASS_NAME, "get()V", initial, expected);
}

代码示例来源:origin: pxb1988/dex2jar

@Test
  public void test() throws Exception {
    byte[] data = TestUtils.testDexASMifier(getClass(), "strict", "a");
    Class<?> clz = TestUtils.defineClass("a", data);
    Object c = clz.newInstance();
    Assert.assertNotNull(c);
    java.lang.reflect.Field f = clz.getDeclaredField("theField");
    f.setAccessible(true);
    Short r = (Short) f.get(null);
    Assert.assertEquals(-1, r.intValue());

    // it's already ok to run on JVM and able to convert to dex,
    // // check for I2S instruction
    // ClassReader cr = new ClassReader(data);
    // ClassNode cn = new ClassNode();
    // cr.accept(cn, 0);
    // boolean find = false;
    // for (Object m : cn.methods) {
    // MethodNode method = (MethodNode) m;
    // for (AbstractInsnNode p = method.instructions.getFirst(); p != null; p = p.getNext()) {
    // if (p.getOpcode() == Opcodes.I2S) {
    // find = true;
    // break;
    // }
    // }
    // }
    // Assert.assertTrue("we need an I2S instruction", find);

  }
}

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

return addConstantInteger(((Character) value).charValue());
} else if (value instanceof Short) {
 return addConstantInteger(((Short) value).intValue());
} else if (value instanceof Boolean) {
 return addConstantInteger(((Boolean) value).booleanValue() ? 1 : 0);

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

@Test
public void testIntToCharWithShort() {
  Short value = 0x62;
  initial.setRegisters(0, value, "S");
  expected.setRegisters(0, (char) value.intValue(), "C");
  VMTester.test(CLASS_NAME, "intToChar()V", initial, expected);
}

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

@Test
public void canCreateIntegerArrayWithShortTypeLengthValue() {
  Short length = 1;
  initial.setRegisters(0, length, "S");
  expected.setRegisters(0, new int[length.intValue()], "[I");
  VMTester.test(CLASS_NAME, "createIntegerArray()V", initial, expected);
}

相关文章