當前位置: 首頁>>代碼示例>>Java>>正文


Java UnsignedLongs.decode方法代碼示例

本文整理匯總了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));
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:27,代碼來源:CircuitId.java

示例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);
	}
}
 
開發者ID:OpenNTF,項目名稱:org.openntf.domino,代碼行數:16,代碼來源:NoteCoordinate.java

示例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);
	}
}
 
開發者ID:OpenNTF,項目名稱:org.openntf.domino,代碼行數:12,代碼來源:NoteCoordinate.java

示例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);
	}
}
 
開發者ID:OpenNTF,項目名稱:org.openntf.domino,代碼行數:15,代碼來源:NoteCoordinate.java

示例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));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:10,代碼來源:OpticalLogicId.java

示例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));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:10,代碼來源:PortNumber.java

示例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));
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:10,代碼來源:PortNumber.java


注:本文中的com.google.common.primitives.UnsignedLongs.decode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。