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

Method readEvents

input/StandardEventsReader.java:80–204  ·  view source on GitHub ↗
(int nrof)

Source from the content-addressed store, hash-verified

78
79
80 public List<ExternalEvent> readEvents(int nrof) {
81 ArrayList<ExternalEvent> events = new ArrayList<ExternalEvent>(nrof);
82 int eventsRead = 0;
83 // skip empty and comment lines
84 Pattern skipPattern = Pattern.compile("(#.*)|(^\\s*$)");
85
86 String line;
87 try {
88 line = this.reader.readLine();
89 } catch (IOException e1) {
90 throw new SimError("Reading from external event file failed.");
91 }
92 while (eventsRead < nrof && line != null) {
93 Scanner lineScan = new Scanner(line);
94 if (skipPattern.matcher(line).matches()) {
95 // skip empty and comment lines
96 try {
97 line = this.reader.readLine();
98 } catch (IOException e) {
99 throw new SimError("Reading from external event file " +
100 "failed.");
101 }
102 continue;
103 }
104
105 double time;
106 String action;
107 String msgId;
108 int hostAddr;
109 int host2Addr;
110
111 try {
112 time = lineScan.nextDouble();
113 action = lineScan.next();
114
115 if (action.equals(DROP)) {
116 msgId = lineScan.next();
117 hostAddr = getHostAddress(lineScan.next());
118 events.add(new MessageDeleteEvent(hostAddr, msgId,
119 time, true));
120 }
121 else if (action.equals(REMOVE)) {
122 msgId = lineScan.next();
123 hostAddr = getHostAddress(lineScan.next());
124 events.add(new MessageDeleteEvent(hostAddr, msgId,
125 time, false));
126 }
127 else if (action.equals(CONNECTION)) {
128 String connEventType;
129 boolean isUp;
130 hostAddr = getHostAddress(lineScan.next());
131 host2Addr = getHostAddress(lineScan.next());
132 connEventType = lineScan.next();
133
134 String interfaceId = null;
135 if (lineScan.hasNext()) {
136 interfaceId = lineScan.next();
137 }

Callers 1

testBinaryEEQMethod · 0.95

Calls 5

getHostAddressMethod · 0.95
nextMethod · 0.80
addMethod · 0.80
hasNextMethod · 0.80
equalsMethod · 0.45

Tested by 1

testBinaryEEQMethod · 0.76