MCPcopy Create free account
hub / github.com/akeranen/the-one / readEvents

Method readEvents

input/BinaryEventsReader.java:54–74  ·  view source on GitHub ↗

Read events from a binary file created with storeBinaryFile method @param nrof Maximum number of events to read @return Events in an ArrayList (empty list if didn't read any) @see #storeToBinaryFile(String, List)

(int nrof)

Source from the content-addressed store, hash-verified

52 * @see #storeToBinaryFile(String, List)
53 */
54 @SuppressWarnings("unchecked") // suppress cast warnings
55 public List<ExternalEvent> readEvents(int nrof) {
56 ArrayList<ExternalEvent> events = new ArrayList<ExternalEvent>(nrof);
57
58 if (eventsLeft == 0) {
59 return events;
60 }
61
62 try {
63 for (int i=0; i < nrof && eventsLeft > 0; i++) {
64 events.add((ExternalEvent)in.readObject());
65 eventsLeft--;
66 }
67 if (eventsLeft == 0) {
68 in.close();
69 }
70 } catch (Exception e) { // FIXME: quick 'n' dirty exception handling
71 throw new SimError(e);
72 }
73 return events;
74 }
75
76 /**
77 * Checks if the given file is a binary external events file

Callers 1

isBinaryEeFileMethod · 0.95

Calls 2

addMethod · 0.80
closeMethod · 0.65

Tested by

no test coverage detected