1 24 package org.columba.mail; 25 26 import java.util.StringTokenizer ; 27 28 36 class ContentType 37 { 38 39 private String mType; 40 private String mSubType; 41 private String mParameters; 42 private String mBoundary; 44 45 46 public ContentType(String input) 47 { 48 49 String s = input.trim(); 50 mType = s.substring(0, s.indexOf('/')); 51 mSubType = (new StringTokenizer (s.substring(s.indexOf('/') + 1))).nextToken(); 52 mParameters = s.substring(s.indexOf('/') + mSubType.length() + 1); int pos = s.indexOf("boundary="); 54 pos = pos + 9; 55 if (s.indexOf(';', pos) == -1) 56 mBoundary = s.substring(pos).trim(); 57 else 58 mBoundary = s.substring(pos, s.indexOf(';', pos)).trim(); 59 if (mBoundary.startsWith("\"")) 60 mBoundary = mBoundary.substring(1, mBoundary.length()-1); } 62 63 public String getType() { return mType; } 64 65 public String getSubType() { return mSubType; } 66 67 public String getBoundary() { return mBoundary; } 68 69 70 public String toString() 71 { 72 return mType + "/" + mSubType + mParameters; 73 } 74 } 75 | Popular Tags |