< prev index next >

src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/packaging/mime/internet/InternetHeaders.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


 268      * Remove all header entries that match the given name
 269      *
 270      * @param   name header name
 271      */
 272     public void removeHeader(String name) {
 273         for (int i = 0; i < headers.size(); i++) {
 274             hdr h = headers.get(i);
 275             if (name.equalsIgnoreCase(h.name)) {
 276                 headers.remove(i);
 277                 i--;    // have to look at i again
 278             }
 279         }
 280     }
 281 
 282     /**
 283      * Return all the headers as an Enumeration of
 284      * {@link Header} objects.
 285      *
 286      * @return  Header objects
 287      */
 288     public FinalArrayList<hdr> getAllHeaders() {
 289         return headers; // conceptually it should be read-only, but for performance reason I'm not wrapping it here
 290     }
 291 
 292     /**
 293      * Add an RFC822 header line to the header store.
 294      * If the line starts with a space or tab (a continuation line),
 295      * add it to the last header line in the list. <p>
 296      * <p/>
 297      * Note that RFC822 headers can only contain US-ASCII characters
 298      *
 299      * @param   line    raw RFC822 header line
 300      */
 301     public void addHeaderLine(String line) {
 302         try {
 303             char c = line.charAt(0);
 304             if (c == ' ' || c == '\t') {
 305                 hdr h = headers.get(headers.size() - 1);
 306                 h.line += "\r\n" + line;
 307             } else
 308                 headers.add(new hdr(line));


   1 /*
   2  * Copyright (c) 1997, 2016, 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


 268      * Remove all header entries that match the given name
 269      *
 270      * @param   name header name
 271      */
 272     public void removeHeader(String name) {
 273         for (int i = 0; i < headers.size(); i++) {
 274             hdr h = headers.get(i);
 275             if (name.equalsIgnoreCase(h.name)) {
 276                 headers.remove(i);
 277                 i--;    // have to look at i again
 278             }
 279         }
 280     }
 281 
 282     /**
 283      * Return all the headers as an Enumeration of
 284      * {@link Header} objects.
 285      *
 286      * @return  Header objects
 287      */
 288     public List<? extends Header> getAllHeaders() {
 289         return headers; // conceptually it should be read-only, but for performance reason I'm not wrapping it here
 290     }
 291 
 292     /**
 293      * Add an RFC822 header line to the header store.
 294      * If the line starts with a space or tab (a continuation line),
 295      * add it to the last header line in the list. <p>
 296      * <p/>
 297      * Note that RFC822 headers can only contain US-ASCII characters
 298      *
 299      * @param   line    raw RFC822 header line
 300      */
 301     public void addHeaderLine(String line) {
 302         try {
 303             char c = line.charAt(0);
 304             if (c == ' ' || c == '\t') {
 305                 hdr h = headers.get(headers.size() - 1);
 306                 h.line += "\r\n" + line;
 307             } else
 308                 headers.add(new hdr(line));


< prev index next >