- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 29 Aug 2005 11:38:44 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/www/mime
In directory hutz:/tmp/cvs-serv12740
Modified Files:
MimeType.java
Log Message:
in sync with Jigsaw's classes
Index: MimeType.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/www/mime/MimeType.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- MimeType.java 8 Aug 2005 13:19:47 -0000 1.2
+++ MimeType.java 29 Aug 2005 11:38:42 -0000 1.3
@@ -5,9 +5,11 @@
package org.w3c.www.mime ;
-import java.io.Serializable;
import java.util.Vector;
+import java.io.PrintStream;
+import java.io.Serializable;
+
/**
* This class is used to represent parsed MIME types.
* It creates this representation from a string based representation of
@@ -199,10 +201,13 @@
* otherwise.
*/
public boolean hasParameter (String name) {
- if ( pnames != null ) {
- for (int i = 0 ; i < pnames.length ; i++) {
- if ( pnames[i].equals(name) )
- return true ;
+ if (name != null) {
+ if ( pnames != null ) {
+ String lname = name.toLowerCase();
+ for (int i = 0 ; i < pnames.length ; i++) {
+ if ( pnames[i].equals(name) )
+ return true ;
+ }
}
}
return false ;
@@ -231,10 +236,13 @@
* @return The parameter value, or <b>null</b> if not found.
*/
public String getParameterValue (String name) {
- if ( pnames != null ) {
- for (int i = 0 ; i < pnames.length ; i++) {
- if ( pnames[i].equals(name) )
- return pvalues[i];
+ if (name != null) {
+ if ( pnames != null ) {
+ String lname = name.toLowerCase();
+ for (int i = 0 ; i < pnames.length ; i++) {
+ if ( pnames[i].equals(lname) )
+ return pvalues[i];
+ }
}
}
return null ;
@@ -263,6 +271,9 @@
pnames = nparam;
pvalues = nvalues;
}
+ for (int i = 0; i < pnames.length; i++) {
+ pnames[i] = pnames[i].toLowerCase();
+ }
external = null;
}
@@ -302,13 +313,14 @@
if (pnames == null) {
addParameter(param, value);
} else {
+ String lparam = param.toLowerCase();
for (int i = 0 ; i < pnames.length ; i++) {
- if (pnames[i].equalsIgnoreCase(param)) {
+ if (pnames[i].equals(lparam)) {
pvalues[i] = value;
return;
}
}
- addParameter(param, value);
+ addParameter(lparam, value);
}
}
@@ -335,7 +347,7 @@
// get the type:
StringBuffer sb = new StringBuffer () ;
while ((start < strl) && ((look = spec.charAt(start)) != '/')) {
- sb.append ((char) look) ;
+ sb.append (Character.toLowerCase((char) look)) ;
start++ ;
}
if ( look != '/' )
@@ -346,7 +358,7 @@
sb.setLength(0) ;
while ((start < strl)
&& ((look = spec.charAt(start)) > ' ') && (look != ';')) {
- sb.append ((char) look) ;
+ sb.append (Character.toLowerCase((char) look)) ;
start++ ;
}
this.subtype = sb.toString().intern() ;
@@ -400,15 +412,15 @@
public MimeType (String type, String subtype
, String pnames[], String pvalues[]) {
- this.type = type.intern() ;
- this.subtype = subtype.intern() ;
+ this.type = type.toLowerCase().intern() ;
+ this.subtype = subtype.toLowerCase().intern() ;
this.pnames = pnames;
this.pvalues = pvalues;
}
public MimeType (String type, String subtype) {
- this.type = type.intern();
- this.subtype = subtype.intern();
+ this.type = type.toLowerCase().intern();
+ this.subtype = subtype.toLowerCase().intern();
}
public static void main (String args[]) {
Received on Monday, 29 August 2005 11:38:50 UTC