public V get(K k) { while (true) { Result<V> r = lookupNode(k).get(k); if (r.isValid()) { return r.getValue(); } else { cache.clear(); // TODO: do more efficient } } }
@Override protected boolean parseMsg(String body, Data data) { if (!super.parseMsg(body, data)) return false; // If there is no city, see if we can find it in the info section if (data.strCity.length() == 0) { Result res = parseAddress(StartType.START_ADDR, FLAG_ONLY_CITY, data.strSupp); if (res.isValid()) res.getData(data); } // If city ends with " CO", expand it if (data.strCity.endsWith(" CO")) data.strCity += "UNTY"; // ANd finally, see if this is in West Virginia if (WV_CITY_TABLE.contains(data.strCity)) data.strState = "WV"; // See if there is a callback phone number in the APT field if (data.strApt.startsWith("CALLBK=")) { data.strPhone = data.strApt.substring(7).trim(); data.strApt = ""; } return true; }
@Override protected boolean parseMsg(String subject, String body, Data data) { // New calls have a distinctive subject Matcher match = SUBJECT_PTN.matcher(subject); if (match.matches()) { data.strSource = match.group(1).trim(); parseAddress(StartType.START_CALL, FLAG_FALLBACK_ADDR, body, data); if (data.strCall.length() == 0) { data.strCall = getLeft(); } else { data.strSupp = getLeft(); } return true; } // Otherwise drop back to the old logic // Not enough identification features to positively identify as a text page // so we require that identification be done externally if (!isPositiveId()) return false; // If no body (which gets to us as no subject) treat as special case if (subject.length() == 0) { Parser p = new Parser(body); parseAddress( StartType.START_CALL, FLAG_PREF_TRAILING_DIR | FLAG_ANCHOR_END, p.get(" "), data); if (data.strCall.length() == 0) data.strCall = p.get(" "); data.strSupp = p.get(); } else { if (body.toUpperCase().startsWith(subject.toUpperCase())) { subject = body.substring(0, subject.length()).trim(); body = body.substring(subject.length()).trim(); if (body.toUpperCase().startsWith("AT ")) body = body.substring(3).trim(); } Parser p = new Parser(subject); String sub = p.get(" "); Result res = parseAddress( StartType.START_CALL, FLAG_IMPLIED_INTERSECT | FLAG_PREF_TRAILING_DIR | FLAG_ANCHOR_END, sub); data.strPlace = p.get(); if (res.isValid()) { res.getData(data); String[] flds = body.split("\n"); data.strCall = flds[0].trim(); for (int ii = 1; ii < flds.length; ii++) { data.strSupp = append(data.strSupp, " / ", flds[ii].trim()); } } else { data.strCall = sub; parseAddress( StartType.START_ADDR, FLAG_IMPLIED_INTERSECT | FLAG_PREF_TRAILING_DIR, body, data); data.strSupp = getLeft(); } } return true; }