1 17 18 package org.apache.james.imapserver; 19 20 import java.io.Serializable ; 21 22 28 public class MessageHeader implements Serializable { 29 public static final String CRLF = "\r\n"; 30 public static final String CRLFHTAB = "\r\n\t"; 31 public static final String CRLFWS = "\r\n "; 32 33 private final String name; 34 private final String value; 35 36 public MessageHeader(String headerLine) { 37 int colon = headerLine.indexOf(":"); 38 name = headerLine.substring(0, colon); 39 StringBuffer unwrapped = new StringBuffer (headerLine.length()); 40 boolean finished = false; 41 int pos = colon + 1; 42 while (!finished) { 43 int crlf = headerLine.indexOf(CRLF, pos); 44 if (crlf == -1) { 45 unwrapped.append(headerLine.substring(pos)); 46 finished = true; 47 } else { 48 unwrapped.append(headerLine.substring(pos, crlf)); 49 unwrapped.append(" "); 50 pos = crlf +3; 51 } 52 } 53 value = unwrapped.toString(); 54 } 55 56 public MessageHeader(String name, String value) { 57 this.name = name; 58 this.value = value; 59 } 60 61 66 public String getName() { 67 return name; 68 } 69 70 75 public String getValue() { 76 return value; 77 } 78 } 79 80 81 | Popular Tags |