MCPcopy Index your code
hub / github.com/oshi/oshi / getSerialNo

Method getSerialNo

oshi-core/src/main/java/oshi/util/EdidUtil.java:86–93  ·  view source on GitHub ↗

Gets the Serial number, bytes 12-15 @param edid The EDID byte array @return If all 4 bytes represent alphanumeric characters, a 4-character string, otherwise a hex string.

(byte[] edid)

Source from the content-addressed store, hash-verified

84 * string, otherwise a hex string.
85 */
86 public static String getSerialNo(byte[] edid) {
87 // Bytes 12-15 are Serial number (last 4 characters)
88 if (LOG.isDebugEnabled()) {
89 LOG.debug("Serial number: {}", Arrays.toString(Arrays.copyOfRange(edid, 12, 16)));
90 }
91 return String.format("%s%s%s%s", getAlphaNumericOrHex(edid[15]), getAlphaNumericOrHex(edid[14]),
92 getAlphaNumericOrHex(edid[13]), getAlphaNumericOrHex(edid[12]));
93 }
94
95 private static String getAlphaNumericOrHex(byte b) {
96 return Character.isLetterOrDigit((char) b) ? String.format("%s", (char) b) : String.format("%02X", b);

Callers 2

testGetEdidAttrsMethod · 0.95
toStringMethod · 0.95

Calls 2

getAlphaNumericOrHexMethod · 0.95
toStringMethod · 0.45

Tested by 1

testGetEdidAttrsMethod · 0.76