< prev index next >

jaxws/src/java.activation/share/classes/javax/activation/MimeTypeParameterList.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  41 public class MimeTypeParameterList {
  42     private Hashtable parameters;
  43 
  44     /**
  45      * A string that holds all the special chars.
  46      */
  47     private static final String TSPECIALS = "()<>@,;:/[]?=\\\"";
  48 
  49 
  50     /**
  51      * Default constructor.
  52      */
  53     public MimeTypeParameterList() {
  54         parameters = new Hashtable();
  55     }
  56 
  57     /**
  58      * Constructs a new MimeTypeParameterList with the passed in data.
  59      *
  60      * @param parameterList an RFC 2045, 2046 compliant parameter list.

  61      */
  62     public MimeTypeParameterList(String parameterList)
  63                                         throws MimeTypeParseException {
  64         parameters = new Hashtable();
  65 
  66         //    now parse rawdata
  67         parse(parameterList);
  68     }
  69 
  70     /**
  71      * A routine for parsing the parameter list out of a String.
  72      *
  73      * @param parameterList an RFC 2045, 2046 compliant parameter list.

  74      */
  75     protected void parse(String parameterList) throws MimeTypeParseException {
  76         if (parameterList == null)
  77             return;
  78 
  79         int length = parameterList.length();
  80         if (length <= 0)
  81             return;
  82 
  83         int i;
  84         char c;
  85         for (i = skipWhiteSpace(parameterList, 0);
  86                 i < length && (c = parameterList.charAt(i)) == ';';
  87                 i = skipWhiteSpace(parameterList, i)) {
  88             int lastIndex;
  89             String name;
  90             String value;
  91 
  92             //    eat the ';'
  93             i++;


   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  41 public class MimeTypeParameterList {
  42     private Hashtable parameters;
  43 
  44     /**
  45      * A string that holds all the special chars.
  46      */
  47     private static final String TSPECIALS = "()<>@,;:/[]?=\\\"";
  48 
  49 
  50     /**
  51      * Default constructor.
  52      */
  53     public MimeTypeParameterList() {
  54         parameters = new Hashtable();
  55     }
  56 
  57     /**
  58      * Constructs a new MimeTypeParameterList with the passed in data.
  59      *
  60      * @param parameterList an RFC 2045, 2046 compliant parameter list.
  61      * @exception       MimeTypeParseException  if the MIME type can't be parsed
  62      */
  63     public MimeTypeParameterList(String parameterList)
  64                                         throws MimeTypeParseException {
  65         parameters = new Hashtable();
  66 
  67         //    now parse rawdata
  68         parse(parameterList);
  69     }
  70 
  71     /**
  72      * A routine for parsing the parameter list out of a String.
  73      *
  74      * @param parameterList an RFC 2045, 2046 compliant parameter list.
  75      * @exception       MimeTypeParseException  if the MIME type can't be parsed
  76      */
  77     protected void parse(String parameterList) throws MimeTypeParseException {
  78         if (parameterList == null)
  79             return;
  80 
  81         int length = parameterList.length();
  82         if (length <= 0)
  83             return;
  84 
  85         int i;
  86         char c;
  87         for (i = skipWhiteSpace(parameterList, 0);
  88                 i < length && (c = parameterList.charAt(i)) == ';';
  89                 i = skipWhiteSpace(parameterList, i)) {
  90             int lastIndex;
  91             String name;
  92             String value;
  93 
  94             //    eat the ';'
  95             i++;


< prev index next >