ccs.mime
Class MUtil

java.lang.Object
  extended by ccs.mime.MUtil

public class MUtil
extends java.lang.Object

Utility methods for dealing with various MIME constructs.


Method Summary
static java.lang.String getExtn(java.lang.String path, char separator)
          Return the "filename extension" for a path.
static java.lang.String getNotExtn(java.lang.String path, char separator)
          The dual of getExtn; returns everything before the extension.
static java.lang.String getQuery(java.lang.String path, char separator)
          Return any presumed query string found on the supplied path.
static HeaderedEntity[] rawMultipartSet(java.io.InputStream src, int len, java.lang.String contentTypeRaw)
          Separates an input stream, which contains data in the MIME multipart format, into an array of HeaderedEntity objects, each of which represents an individual part of the multipart.
static java.lang.String subValue(java.lang.String body, java.lang.String subname)
          Undocumented.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

subValue

public static java.lang.String subValue(java.lang.String body,
                                        java.lang.String subname)
Undocumented.


rawMultipartSet

public static HeaderedEntity[] rawMultipartSet(java.io.InputStream src,
                                               int len,
                                               java.lang.String contentTypeRaw)
                                        throws java.io.IOException
Separates an input stream, which contains data in the MIME multipart format, into an array of HeaderedEntity objects, each of which represents an individual part of the multipart.

NOTE: This is a simplified and not fully conformant implementation which is designed for reading multipart/form-data coming back from browsers. (It trades improved efficiency for conformance by failing to support some MIME features which are generally not used in this specific context). For all other applications you should use MimeEntity instead.

Parameters:
src - The source inputstream containing the multipart.
len - The length of src, if known; otherwise, supply -1 to swallow the whole stream.
contentTypeRaw - apps which supply multipart MIMEs supply a header field preceding the start of the multipart, which contains a clause specifying the interpart boundary string. Typically this is the content-type header; the header is sthg like multipart/form-data; boundary=--FLKJDHRIUvlckjglfdkjh. Supply the complete header; this method will parse it to retrieve the boundary.
Throws:
java.io.IOException

getExtn

public static java.lang.String getExtn(java.lang.String path,
                                       char separator)
Return the "filename extension" for a path. This is commonly used on "legacy" systems which don't support explicit metadata (ie. most of 'em at the moment) to encode the MIME type; it's far from perfect but it's the best we usually have. Applications should use this rather than attempting to work it out for themselves - it's not always as easy as it appears!

Parameters:
path - The path to extract the extension from. If the path includes a '?' character, this is assumed to be the start of a transplanted URL query string, and is stripped.
separator - The character which separates path elements on the "filesystem" (or pseudo-filesystem in the case of hierarchical URLs) the path belongs to. '\\' for Win32, '/' for pretty much everything else.
Returns:
the extension, or the empty string if there is none such. Never null.

getNotExtn

public static java.lang.String getNotExtn(java.lang.String path,
                                          char separator)
The dual of getExtn; returns everything before the extension.

Parameters:
path - The path to from which to extract everything before the extension. If the path includes a '?' character, this is assumed to be the start of a transplanted URL query string, and is stripped.
separator - The character which separates path elements on the "filesystem" (or pseudo-filesystem in the case of hierarchical URLs) the path belongs to. '\\' for Win32, '/' for pretty much everything else.
Returns:
As above; I am not typing all that out again. :-) Never null.

getQuery

public static java.lang.String getQuery(java.lang.String path,
                                        char separator)
Return any presumed query string found on the supplied path. The corrolary to getExtn and getNotExtn: path === getNotExtn(path) + getExtn(path) + "?" + getQuery(path).

Parameters:
path - The path from which to extract the supposed query string.
separator - The character which separates path elements on the "filesystem" (or pseudo-filesystem in the case of hierarchical URLs) the path belongs to. '\\' for Win32, '/' for pretty much everything else.
Returns:
The query string following the first '?' character, if any; else the empty string. Never null. For consistency with other APIs, the separating '?' character is not included in the query string, but must be added afterwards.