本文整理了Java中java.lang.Number.shortValue()
方法的一些代码示例,展示了Number.shortValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Number.shortValue()
方法的具体详情如下:
包路径:java.lang.Number
类名称:Number
方法名:shortValue
[英]Returns this object's value as a short. Might involve rounding and/or truncating the value, so it fits into a short.
[中]以短字符串形式返回此对象的值。可能涉及舍入和/或截断该值,因此它适合于短字符串。
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return ((Number) jv).shortValue();
}
return (short) 0;
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return ((Number) jv).shortValue();
}
return (short) 0;
}
};
代码示例来源:origin: spring-projects/spring-framework
@Override
public Character convert(Number source) {
return (char) source.shortValue();
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Adds a value to the value of this instance.
*
* @param operand the value to add, not null
* @throws NullPointerException if the object is null
* @since 2.2
*/
public void add(final Number operand) {
this.value += operand.shortValue();
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Constructs a new MutableShort with the specified value.
*
* @param value the initial value to store, not null
* @throws NullPointerException if the object is null
*/
public MutableShort(final Number value) {
super();
this.value = value.shortValue();
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Sets the value from any Number instance.
*
* @param value the value to set, not null
* @throws NullPointerException if the object is null
*/
@Override
public void setValue(final Number value) {
this.value = value.shortValue();
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Subtracts a value from the value of this instance.
*
* @param operand the value to subtract, not null
* @throws NullPointerException if the object is null
* @since 2.2
*/
public void subtract(final Number operand) {
this.value -= operand.shortValue();
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Increments this instance's value by {@code operand}; this method returns the value associated with the instance
* immediately after the addition operation. This method is not thread safe.
*
* @param operand the quantity to add, not null
* @throws NullPointerException if {@code operand} is null
* @return the value associated with this instance after adding the operand
* @since 3.5
*/
public short addAndGet(final Number operand) {
this.value += operand.shortValue();
return value;
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return Short.valueOf(((Number) jv).shortValue());
}
return (Short) null;
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return Short.valueOf(((Number) jv).shortValue());
}
return (Short) null;
}
};
代码示例来源:origin: alibaba/druid
public static Short castToShort(Object val) {
if (val == null || val == EVAL_VALUE_NULL) {
return null;
}
if (val instanceof Short) {
return (Short) val;
}
if (val instanceof String) {
return Short.parseShort((String) val);
}
return ((Number) val).shortValue();
}
代码示例来源:origin: alibaba/druid
@Override
public short getShort(int columnIndex) throws SQLException {
Number number = (Number) getObject(columnIndex);
if (number == null) {
return 0;
}
return number.shortValue();
}
代码示例来源:origin: alibaba/druid
@Override
public short getShort(int columnIndex) throws SQLException {
Number number = (Number) getObject(columnIndex);
if (number == null) {
return 0;
}
return number.shortValue();
}
代码示例来源:origin: apache/incubator-dubbo
public short getParameter(String key, short defaultValue) {
Number n = getNumbers().get(key);
if (n != null) {
return n.shortValue();
}
String value = getParameter(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
short s = Short.parseShort(value);
getNumbers().put(key, s);
return s;
}
代码示例来源:origin: apache/incubator-dubbo
public short getParameter(String key, short defaultValue) {
Number n = getNumbers().get(key);
if (n != null) {
return n.shortValue();
}
String value = getParameter(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
short s = Short.parseShort(value);
getNumbers().put(key, s);
return s;
}
代码示例来源:origin: apache/incubator-dubbo
public short getMethodParameter(String method, String key, short defaultValue) {
String methodKey = method + "." + key;
Number n = getNumbers().get(methodKey);
if (n != null) {
return n.shortValue();
}
String value = getMethodParameter(method, key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
short s = Short.parseShort(value);
getNumbers().put(methodKey, s);
return s;
}
代码示例来源:origin: apache/incubator-dubbo
public short getMethodParameter(String method, String key, short defaultValue) {
String methodKey = method + "." + key;
Number n = getNumbers().get(methodKey);
if (n != null) {
return n.shortValue();
}
String value = getMethodParameter(method, key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
short s = Short.parseShort(value);
getNumbers().put(methodKey, s);
return s;
}
代码示例来源:origin: prestodb/presto
@Override
public short getShort(int columnIndex)
throws SQLException
{
return toNumber(column(columnIndex)).shortValue();
}
代码示例来源:origin: prestodb/presto
@Override
public short getShort(String columnLabel)
throws SQLException
{
return toNumber(column(columnLabel)).shortValue();
}
代码示例来源:origin: prestodb/presto
protected final short _parseShortPrimitive(JsonParser p, DeserializationContext ctxt)
throws IOException
{
int value = _parseIntPrimitive(p, ctxt);
// So far so good: but does it fit?
if (_shortOverflow(value)) {
Number v = (Number) ctxt.handleWeirdStringValue(_valueClass, String.valueOf(value),
"overflow, value cannot be represented as 16-bit value");
return _nonNullNumber(v).shortValue();
}
return (short) value;
}
内容来源于网络,如有侵权,请联系作者删除!