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)
| 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); |