本文整理汇总了Java中com.google.common.primitives.UnsignedLongs.decode方法的典型用法代码示例。如果您正苦于以下问题:Java UnsignedLongs.decode方法的具体用法?Java UnsignedLongs.decode怎么用?Java UnsignedLongs.decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.primitives.UnsignedLongs
的用法示例。
在下文中一共展示了UnsignedLongs.decode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
/**
* Deserialize circuit id from byte string.
*
* @param circuitId the circuit id byte string
* @return a Circuit Id
*/
public static CircuitId deserialize(byte[] circuitId) {
String cIdString = new String(circuitId, StandardCharsets.US_ASCII);
List<String> splittedCircuitId = Lists.newArrayList(cIdString.split(SEPARATOR));
checkArgument(splittedCircuitId.size() > 1, "Illegal circuit id.");
// remove last element (vlan id)
String vlanId = splittedCircuitId.remove(splittedCircuitId.size() - 1);
// Reconstruct device Id
String connectPoint = String.join(SEPARATOR, splittedCircuitId);
String[] splittedConnectPoint = connectPoint.split(DEVICE_PORT_SEPARATOR);
// Check connect point is valid or not
checkArgument(splittedConnectPoint.length == 2,
"Connect point must be in \"deviceUri/portNumber\" format");
// Check the port number is a number or not
UnsignedLongs.decode(splittedConnectPoint[1]);
return new CircuitId(connectPoint, VlanId.vlanId(vlanId));
}
示例2: getBytesFromUnid
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
public static byte[] getBytesFromUnid(final CharSequence unid) {
if (unid == null)
return null;
if (DominoUtils.isUnid(unid)) {
String first = "0x" + unid.subSequence(0, 16);
long flong = UnsignedLongs.decode(first);
byte[] fbytes = Longs.toByteArray(flong);
String last = "0x" + unid.subSequence(16, 32);
long llong = UnsignedLongs.decode(last);
byte[] lbytes = Longs.toByteArray(llong);
return Bytes.concat(fbytes, lbytes);
} else {
throw new IllegalArgumentException("Cannot convert a String of length " + unid.length() + ": " + unid);
}
}
示例3: getLongFromReplid
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
public static long getLongFromReplid(final CharSequence replid) throws IllegalArgumentException {
if (replid == null)
throw new IllegalArgumentException("null is not a valid replica id");
if (DominoUtils.isReplicaId(replid)) {
String decode = "0x" + replid.toString();
long result = UnsignedLongs.decode(decode);
return result;
} else {
throw new IllegalArgumentException("Cannot convert a String of length " + replid.length() + ": " + replid);
}
}
示例4: getLongsFromUnid
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
public static long[] getLongsFromUnid(final CharSequence unid) throws IllegalArgumentException {
if (unid == null)
throw new IllegalArgumentException("null is not a valid unid");
if (DominoUtils.isUnid(unid)) {
long[] result = new long[2];
String first = "0x" + unid.subSequence(0, 16);
result[0] = UnsignedLongs.decode(first);
String last = "0x" + unid.subSequence(16, 32);
result[1] = UnsignedLongs.decode(last);
return result;
} else {
throw new IllegalArgumentException("Cannot convert a String of length " + unid.length() + ": " + unid);
}
}
示例5: logicId
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
/**
* Returns the LabelId representing the specified string value.
*
* @param string identifier as string value
* @return LabelId
*/
public static OpticalLogicId logicId(String string) {
return new OpticalLogicId(UnsignedLongs.decode(string));
}
示例6: portNumber
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
/**
* Returns the port number representing the specified string value.
*
* @param string port number as string value
* @return port number
*/
public static PortNumber portNumber(String string) {
return new PortNumber(UnsignedLongs.decode(string));
}
示例7: portNumber
import com.google.common.primitives.UnsignedLongs; //导入方法依赖的package包/类
/**
* Returns the port number representing the specified string value.
*
* @param string port number as decimal, hexadecimal, or octal number string
* @return port number
*/
public static PortNumber portNumber(String string) {
return new PortNumber(UnsignedLongs.decode(string));
}