本文整理汇总了Java中com.google.common.primitives.UnsignedLongs.parseUnsignedLong方法的典型用法代码示例。如果您正苦于以下问题:Java UnsignedLongs.parseUnsignedLong方法的具体用法?Java UnsignedLongs.parseUnsignedLong怎么用?Java UnsignedLongs.parseUnsignedLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.primitives.UnsignedLongs
的用法示例。
在下文中一共展示了UnsignedLongs.parseUnsignedLong方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseUnsignedLong
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
public static long parseUnsignedLong(String st, TExecutionContext context)
{
Object truncated = CastUtils.truncateNonDigits(st, context);
if (truncated instanceof String)
st = (String)truncated;
else
st = CastUtils.truncateNonDigitPlainString(((BigDecimal)truncated).toPlainString(),
context);
long value;
try
{
value = UnsignedLongs.parseUnsignedLong(st);
} catch (NumberFormatException e) { // overflow error
context.reportOverflow(e.getMessage());
// check wether the value is too big or too small
if (st.charAt(0) == '-')
value = 0;
else
value = UnsignedLongs.MAX_VALUE;
}
return value;
}
示例2: parseSpanId
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
private SpanId parseSpanId(String input) {
try {
return new SpanId(UnsignedLongs.parseUnsignedLong(input));
} catch (NumberFormatException ex) {
return SpanId.invalid();
}
}
示例3: parseUnsignedLong
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
private long parseUnsignedLong(String id) {
if (id == null) {
return 0;
}
return UnsignedLongs.parseUnsignedLong(id, 16);
}
示例4: decode
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
public static long decode(String uuid) {
return UnsignedLongs.parseUnsignedLong(uuid, 16);
}
示例5: readCollating
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
@Override
public void readCollating(ValueSource in, TInstance typeInstance, ValueTarget out) {
BigInteger asBigint = (BigInteger) in.getObject();
long asLong = UnsignedLongs.parseUnsignedLong(asBigint.toString());
out.putInt64(asLong);
}
示例6: protoFromSoy
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
@Override
Object protoFromSoy(SoyValue field) {
return UnsignedLongs.parseUnsignedLong(field.stringValue());
}
示例7: parse
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
@Override
public UUID parse(String uuid) {
checkArgument(uuid.length() == 32, "Not an UUID: " + uuid);
return new UUID(UnsignedLongs.parseUnsignedLong(uuid.substring(0, 16), 16),
UnsignedLongs.parseUnsignedLong(uuid.substring(16), 16));
}
示例8: fromHex
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
/**
* Converts a string from hex to long.
*
* @param string hex number in string form; sans 0x
* @return long value
*/
public static long fromHex(String string) {
return UnsignedLongs.parseUnsignedLong(string, 16);
}
示例9: fromHex
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
/**
* Converts a string from hex to long.
*
* @param string
* hex number in string form; sans 0x
* @return long value
*/
public static long fromHex(String string) {
return UnsignedLongs.parseUnsignedLong(string, 16);
}