@Test public void testCorruptMessage1() { TelegesisEvent event = TelegesisEventFactory.getTelegesisFrame( new int[] { 0x52, 0x58, 0x3A, 0x33, 0x44, 0x45, 0x42, 0x2C, 0x30, 0x93, 0x05, 0x00, 0xEA, 0x11 }); assertNull(event); }
public static TelegesisEvent getTelegesisFrame(int[] data) { int hash = 0; int multiplier = 1; for (int value : data) { if (value == '\n' || value == ':' || value == '=') { break; } hash += (value & 0xff) * multiplier; int shifted = multiplier << 5; multiplier = shifted - multiplier; } Class<?> telegesisClass = events.get(hash); if (telegesisClass == null) { return null; } Constructor<?> ctor; try { ctor = telegesisClass.getConstructor(); TelegesisEvent telegesisEvent = (TelegesisEvent) ctor.newInstance(); telegesisEvent.deserialize(data); return telegesisEvent; } catch (Exception e) { logger.debug("Error creating instance of Telegesis event", e); } return null; }
TelegesisEventFactory { public static TelegesisEvent getTelegesisFrame(int[] data) { int hash = 0; int multiplier = 1; for (int value : data) { if (value == '\n' || value == ':' || value == '=') { break; } hash += (value & 0xff) * multiplier; int shifted = multiplier << 5; multiplier = shifted - multiplier; } Class<?> telegesisClass = events.get(hash); if (telegesisClass == null) { return null; } Constructor<?> ctor; try { ctor = telegesisClass.getConstructor(); TelegesisEvent telegesisEvent = (TelegesisEvent) ctor.newInstance(); telegesisEvent.deserialize(data); return telegesisEvent; } catch (Exception e) { logger.debug("Error creating instance of Telegesis event", e); } return null; } }
TelegesisEventFactory { public static TelegesisEvent getTelegesisFrame(int[] data) { int hash = 0; int multiplier = 1; for (int value : data) { if (value == '\n' || value == ':' || value == '=') { break; } hash += (value & 0xff) * multiplier; int shifted = multiplier << 5; multiplier = shifted - multiplier; } Class<?> telegesisClass = events.get(hash); if (telegesisClass == null) { return null; } Constructor<?> ctor; try { ctor = telegesisClass.getConstructor(); TelegesisEvent telegesisEvent = (TelegesisEvent) ctor.newInstance(); telegesisEvent.deserialize(data); return telegesisEvent; } catch (Exception e) { logger.debug("Error creating instance of Telegesis event", e); } return null; }  }
TelegesisEventFactory { public static TelegesisEvent getTelegesisFrame(int[] data) { int hash = 0; int multiplier = 1; for (int value : data) { if (value == '\n' || value == ':' || value == '=') { break; } hash += (value & 0xff) * multiplier; int shifted = multiplier << 5; multiplier = shifted - multiplier; } Class<?> telegesisClass = events.get(hash); if (telegesisClass == null) { return null; } Constructor<?> ctor; try { ctor = telegesisClass.getConstructor(); TelegesisEvent telegesisEvent = (TelegesisEvent) ctor.newInstance(); telegesisEvent.deserialize(data); return telegesisEvent; } catch (Exception e) { logger.debug("Error creating instance of Telegesis event", e); } return null; }  static TelegesisEvent getTelegesisFrame(int[] data); }
TelegesisEventFactory { public static TelegesisEvent getTelegesisFrame(int[] data) { int hash = 0; int multiplier = 1; for (int value : data) { if (value == '\n' || value == ':' || value == '=') { break; } hash += (value & 0xff) * multiplier; int shifted = multiplier << 5; multiplier = shifted - multiplier; } Class<?> telegesisClass = events.get(hash); if (telegesisClass == null) { return null; } Constructor<?> ctor; try { ctor = telegesisClass.getConstructor(); TelegesisEvent telegesisEvent = (TelegesisEvent) ctor.newInstance(); telegesisEvent.deserialize(data); return telegesisEvent; } catch (Exception e) { logger.debug("Error creating instance of Telegesis event", e); } return null; }  static TelegesisEvent getTelegesisFrame(int[] data);  }