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

Method getHostAddress

input/StandardEventsReader.java:213–227  ·  view source on GitHub ↗

Parses a host address from a hostId string (the numeric part after optional non-numeric part). @param hostId The id to parse the address from @return The address @throws SimError if no address could be parsed from the id

(String hostId)

Source from the content-addressed store, hash-verified

211 * @throws SimError if no address could be parsed from the id
212 */
213 private int getHostAddress(String hostId) {
214 String addressPart = "";
215 if (hostId.matches("^\\d+$")) {
216 addressPart = hostId; // host id is only the address
217 }
218 else if (hostId.matches("^\\D+\\d+$")) {
219 String [] parts = hostId.split("\\D");
220 addressPart = parts[parts.length-1]; // last occurence is the addr
221 }
222 else {
223 throw new SimError("Invalid host ID '" + hostId + "'");
224 }
225
226 return Integer.parseInt(addressPart);
227 }
228
229 public void close() {
230 try {

Callers 1

readEventsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected