All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.w3c.css.util.Codecs

java.lang.Object
   |
   +----org.w3c.css.util.Codecs

public class Codecs
extends Object
This class collects various encoders and decoders.


Method Index

 o getParameter(String, String)
retrieves the value associated with the parameter param in a given header string.
 o mpFormDataDecode(byte[], String)
This method decodes a multipart/form-data encoded string.

Methods

 o mpFormDataDecode
 public static final synchronized NVPair[] mpFormDataDecode(byte data[],
                                                            String cont_type) throws IOException
This method decodes a multipart/form-data encoded string. The boundary is parsed from the cont_type parameter, which must be of the form 'multipart/form-data; boundary=...'.
Any encoded files are created in the directory specified by dir using the encoded filename.
Note: Does not handle nested encodings (yet).
Example:
     NVPair[] opts = Codecs.mpFormDataDecode(resp.getData(),
                                      resp.getHeader("Content-length"),
                                      ".");
 
Assuming the data received looked something like:
 -----------------------------114975832116442893661388290519
 Content-Disposition: form-data; name="option"
                                                          
 doit
 -----------------------------114975832116442893661388290519
 Content-Disposition: form-data; name="comment"; filename="comment.txt"
                                                          
 Gnus and Gnats are not Gnomes.
 -----------------------------114975832116442893661388290519--
 
you would get one file called comment.txt in the current directory, and opts would contain two elements: {"option", "doit"} and {"comment", "comment.txt"}

Parameters:
data - the form-data to decode.
cont_type - the content type header (must contain the boundary string).
Returns:
an array of name/value pairs, one for each part; the name is the 'name' attribute given in the Content-Disposition header; the value is either the name of the file if a filename attribute was found, or the contents of the part.
Throws: IOException
If any file operation fails.
 o getParameter
 public static final String getParameter(String param,
                                         String hdr)
retrieves the value associated with the parameter param in a given header string. This is used especially in headers like 'Content-type' and 'Content-Disposition'. Here is the syntax it expects:
";" param "=" ( token | quoted-string )

Parameters:
param - the parameter name
hdr - the header value
Returns:
the value for this parameter, or null if not found.

All Packages  Class Hierarchy  This Package  Previous  Next  Index