394 public synchronized void set(String k, String v) {
395 for (int i = nkeys; --i >= 0;)
396 if (k.equalsIgnoreCase(keys[i])) {
397 values[i] = v;
398 return;
399 }
400 add(k, v);
401 }
402
403 /** Set's the value of a key only if there is no
404 * key with that value already.
405 */
406
407 public synchronized void setIfNotSet(String k, String v) {
408 if (findValue(k) == null) {
409 add(k, v);
410 }
411 }
412
413 /** Convert a message-id string to canonical form (strips off
414 leading and trailing <>s) */
415 public static String canonicalID(String id) {
416 if (id == null)
417 return "";
418 int st = 0;
419 int len = id.length();
420 boolean substr = false;
421 int c;
422 while (st < len && ((c = id.charAt(st)) == '<' ||
423 c <= ' ')) {
424 st++;
425 substr = true;
426 }
427 while (st < len && ((c = id.charAt(len - 1)) == '>' ||
428 c <= ' ')) {
429 len--;
430 substr = true;
431 }
432 return substr ? id.substring(st, len) : id;
433 }
434
|
394 public synchronized void set(String k, String v) {
395 for (int i = nkeys; --i >= 0;)
396 if (k.equalsIgnoreCase(keys[i])) {
397 values[i] = v;
398 return;
399 }
400 add(k, v);
401 }
402
403 /** Set's the value of a key only if there is no
404 * key with that value already.
405 */
406
407 public synchronized void setIfNotSet(String k, String v) {
408 if (findValue(k) == null) {
409 add(k, v);
410 }
411 }
412
413 /** Convert a message-id string to canonical form (strips off
414 leading and trailing {@literal <>s}) */
415 public static String canonicalID(String id) {
416 if (id == null)
417 return "";
418 int st = 0;
419 int len = id.length();
420 boolean substr = false;
421 int c;
422 while (st < len && ((c = id.charAt(st)) == '<' ||
423 c <= ' ')) {
424 st++;
425 substr = true;
426 }
427 while (st < len && ((c = id.charAt(len - 1)) == '>' ||
428 c <= ' ')) {
429 len--;
430 substr = true;
431 }
432 return substr ? id.substring(st, len) : id;
433 }
434
|