1 21 22 27 28 package javax.mail.internet; 29 30 import javax.mail.*; 31 import java.util.*; 32 import java.io.*; 33 34 42 43 public class ContentDisposition { 44 45 private String disposition; private ParameterList list; 48 51 public ContentDisposition() { } 52 53 60 public ContentDisposition(String disposition, ParameterList list) { 61 this.disposition = disposition; 62 this.list = list; 63 } 64 65 74 public ContentDisposition(String s) throws ParseException { 75 HeaderTokenizer h = new HeaderTokenizer (s, HeaderTokenizer.MIME); 76 HeaderTokenizer.Token tk; 77 78 tk = h.next(); 80 if (tk.getType() != HeaderTokenizer.Token.ATOM) 81 throw new ParseException (); 82 disposition = tk.getValue(); 83 84 String rem = h.getRemainder(); 86 if (rem != null) 87 list = new ParameterList (rem); 88 } 89 90 95 public String getDisposition() { 96 return disposition; 97 } 98 99 105 public String getParameter(String name) { 106 if (list == null) 107 return null; 108 109 return list.get(name); 110 } 111 112 119 public ParameterList getParameterList() { 120 return list; 121 } 122 123 128 public void setDisposition(String disposition) { 129 this.disposition = disposition; 130 } 131 132 140 public void setParameter(String name, String value) { 141 if (list == null) 142 list = new ParameterList (); 143 144 list.set(name, value); 145 } 146 147 152 public void setParameterList(ParameterList list) { 153 this.list = list; 154 } 155 156 164 public String toString() { 165 if (disposition == null) 166 return null; 167 168 if (list == null) 169 return disposition; 170 171 StringBuffer sb = new StringBuffer (disposition); 172 173 sb.append(list.toString(sb.length() + 21)); 177 return sb.toString(); 178 } 179 } 180 | Popular Tags |