jdk/src/share/classes/sun/net/www/MessageHeader.java
author chegar
Fri, 16 Sep 2011 12:09:04 -0700
changeset 10596 39b3a979e600
parent 7668 d4a77089c587
child 14766 1f22dd6f2658
permissions -rw-r--r--
7090158: Networking Libraries don't build with javac -Werror Summary: Minor changes to networking java files to remove warnings Reviewed-by: chegar, weijun, hawtin Contributed-by: kurchi.subhra.hazra@oracle.com, sasha_bu@hotmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 7668
diff changeset
     2
 * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*-
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *      news stream opener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
package sun.net.www;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.util.NoSuchElementException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
/** An RFC 844 or MIME message header.  Includes methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    for parsing headers from incoming streams, fetching
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    values, setting values, and printing headers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    Key values of null are legal: they indicate lines in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    the header that don't have a valid key, but do have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    a value (this isn't legal according to the standard,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    but lines like this are everywhere). */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
class MessageHeader {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private String keys[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private String values[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private int nkeys;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    public MessageHeader () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        grow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    public MessageHeader (InputStream is) throws java.io.IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        parseHeader(is);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Reset a message header (all key/values removed)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public synchronized void reset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        keys = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        values = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        nkeys = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        grow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * Find the value that corresponds to this key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * It finds only the first occurrence of the key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param k the key to find.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @return null if not found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public synchronized String findValue(String k) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        if (k == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            for (int i = nkeys; --i >= 0;)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                if (keys[i] == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                    return values[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            for (int i = nkeys; --i >= 0;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                if (k.equalsIgnoreCase(keys[i]))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                    return values[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    // return the location of the key
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public synchronized int getKey(String k) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        for (int i = nkeys; --i >= 0;)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            if ((keys[i] == k) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                (k != null && k.equalsIgnoreCase(keys[i])))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                return i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public synchronized String getKey(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        if (n < 0 || n >= nkeys) return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        return keys[n];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public synchronized String getValue(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        if (n < 0 || n >= nkeys) return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        return values[n];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /** Deprecated: Use multiValueIterator() instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *  Find the next value that corresponds to this key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *  It finds the first value that follows v. To iterate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *  over all the values of a key use:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *  <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *          for(String v=h.findValue(k); v!=null; v=h.findNextValue(k, v)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *              ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *  </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public synchronized String findNextValue(String k, String v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        boolean foundV = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        if (k == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            for (int i = nkeys; --i >= 0;)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                if (keys[i] == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                    if (foundV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                        return values[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                    else if (values[i] == v)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                        foundV = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            for (int i = nkeys; --i >= 0;)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                if (k.equalsIgnoreCase(keys[i]))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                    if (foundV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                        return values[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                    else if (values[i] == v)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                        foundV = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   140
    class HeaderIterator implements Iterator<String> {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        int index = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        int next = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        String key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        boolean haveNext = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        Object lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        public HeaderIterator (String k, Object lock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            key = k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            this.lock = lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        public boolean hasNext () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            synchronized (lock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                if (haveNext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                while (index < nkeys) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                    if (key.equalsIgnoreCase (keys[index])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                        haveNext = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                        next = index++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                    index ++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   167
        public String next() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            synchronized (lock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                if (haveNext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                    haveNext = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                    return values [next];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                if (hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                    return next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                    throw new NoSuchElementException ("No more elements");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        public void remove () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            throw new UnsupportedOperationException ("remove not allowed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * return an Iterator that returns all values of a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * key in sequence
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   189
    public Iterator<String> multiValueIterator (String k) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        return new HeaderIterator (k, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   193
    public synchronized Map<String, List<String>> getHeaders() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        return getHeaders(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   197
    public synchronized Map<String, List<String>> getHeaders(String[] excludeList) {
6876
13fdbd146659 6980004: limit HTTP request cookie headers in HttpURLConnection
michaelm
parents: 5506
diff changeset
   198
        return filterAndAddHeaders(excludeList, null);
13fdbd146659 6980004: limit HTTP request cookie headers in HttpURLConnection
michaelm
parents: 5506
diff changeset
   199
    }
13fdbd146659 6980004: limit HTTP request cookie headers in HttpURLConnection
michaelm
parents: 5506
diff changeset
   200
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 7668
diff changeset
   201
    public synchronized Map<String, List<String>> filterAndAddHeaders(
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 7668
diff changeset
   202
            String[] excludeList, Map<String, List<String>>  include) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        boolean skipIt = false;
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   204
        Map<String, List<String>> m = new HashMap<String, List<String>>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        for (int i = nkeys; --i >= 0;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            if (excludeList != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                // check if the key is in the excludeList.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                // if so, don't include it in the Map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                for (int j = 0; j < excludeList.length; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                    if ((excludeList[j] != null) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                        (excludeList[j].equalsIgnoreCase(keys[i]))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                        skipIt = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            if (!skipIt) {
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   218
                List<String> l = m.get(keys[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                if (l == null) {
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   220
                    l = new ArrayList<String>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                    m.put(keys[i], l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                l.add(values[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                // reset the flag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                skipIt = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
6876
13fdbd146659 6980004: limit HTTP request cookie headers in HttpURLConnection
michaelm
parents: 5506
diff changeset
   230
        if (include != null) {
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 7668
diff changeset
   231
                for (Map.Entry<String,List<String>> entry: include.entrySet()) {
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 7668
diff changeset
   232
                List<String> l = m.get(entry.getKey());
6876
13fdbd146659 6980004: limit HTTP request cookie headers in HttpURLConnection
michaelm
parents: 5506
diff changeset
   233
                if (l == null) {
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 7668
diff changeset
   234
                    l = new ArrayList<String>();
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 7668
diff changeset
   235
                    m.put(entry.getKey(), l);
6876
13fdbd146659 6980004: limit HTTP request cookie headers in HttpURLConnection
michaelm
parents: 5506
diff changeset
   236
                }
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 7668
diff changeset
   237
                l.addAll(entry.getValue());
6876
13fdbd146659 6980004: limit HTTP request cookie headers in HttpURLConnection
michaelm
parents: 5506
diff changeset
   238
            }
13fdbd146659 6980004: limit HTTP request cookie headers in HttpURLConnection
michaelm
parents: 5506
diff changeset
   239
        }
13fdbd146659 6980004: limit HTTP request cookie headers in HttpURLConnection
michaelm
parents: 5506
diff changeset
   240
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   241
        for (String key : m.keySet()) {
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   242
            m.put(key, Collections.unmodifiableList(m.get(key)));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        return Collections.unmodifiableMap(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    /** Prints the key-value pairs represented by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        header.  Also prints the RFC required blank line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        at the end. Omits pairs with a null key. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public synchronized void print(PrintStream p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        for (int i = 0; i < nkeys; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            if (keys[i] != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                p.print(keys[i] +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                    (values[i] != null ? ": "+values[i]: "") + "\r\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        p.print("\r\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        p.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    /** Adds a key value pair to the end of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        header.  Duplicates are allowed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public synchronized void add(String k, String v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        grow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        keys[nkeys] = k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        values[nkeys] = v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        nkeys++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /** Prepends a key value pair to the beginning of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        header.  Duplicates are allowed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public synchronized void prepend(String k, String v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        grow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        for (int i = nkeys; i > 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            keys[i] = keys[i-1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            values[i] = values[i-1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        keys[0] = k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        values[0] = v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        nkeys++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    /** Overwrite the previous key/val pair at location 'i'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * with the new k/v.  If the index didn't exist before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * the key/val is simply tacked onto the end.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    public synchronized void set(int i, String k, String v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        grow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        if (i < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        } else if (i >= nkeys) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            add(k, v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            keys[i] = k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            values[i] = v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /** grow the key/value arrays as needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    private void grow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        if (keys == null || nkeys >= keys.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            String[] nk = new String[nkeys + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            String[] nv = new String[nkeys + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            if (keys != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                System.arraycopy(keys, 0, nk, 0, nkeys);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            if (values != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                System.arraycopy(values, 0, nv, 0, nkeys);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            keys = nk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            values = nv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * Remove the key from the header. If there are multiple values under
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * the same key, they are all removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * Nothing is done if the key doesn't exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * After a remove, the other pairs' order are not changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * @param k the key to remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    public synchronized void remove(String k) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        if(k == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            for (int i = 0; i < nkeys; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                while (keys[i] == null && i < nkeys) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                    for(int j=i; j<nkeys-1; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                        keys[j] = keys[j+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                        values[j] = values[j+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                    nkeys--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            for (int i = 0; i < nkeys; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                while (k.equalsIgnoreCase(keys[i]) && i < nkeys) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                    for(int j=i; j<nkeys-1; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                        keys[j] = keys[j+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                        values[j] = values[j+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                    nkeys--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    /** Sets the value of a key.  If the key already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        exists in the header, it's value will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        changed.  Otherwise a new key/value pair will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        be added to the end of the header. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    public synchronized void set(String k, String v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        for (int i = nkeys; --i >= 0;)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            if (k.equalsIgnoreCase(keys[i])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                values[i] = v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        add(k, v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    /** Set's the value of a key only if there is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     *  key with that value already.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    public synchronized void setIfNotSet(String k, String v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        if (findValue(k) == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            add(k, v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    /** Convert a message-id string to canonical form (strips off
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        leading and trailing <>s) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    public static String canonicalID(String id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        if (id == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        int st = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        int len = id.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        boolean substr = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        int c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        while (st < len && ((c = id.charAt(st)) == '<' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                            c <= ' ')) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            st++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            substr = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        while (st < len && ((c = id.charAt(len - 1)) == '>' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                            c <= ' ')) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            len--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            substr = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        return substr ? id.substring(st, len) : id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    /** Parse a MIME header from an input stream. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    public void parseHeader(InputStream is) throws java.io.IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            nkeys = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        mergeHeader(is);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    /** Parse and merge a MIME header from an input stream. */
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 7668
diff changeset
   401
    @SuppressWarnings("fallthrough")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    public void mergeHeader(InputStream is) throws java.io.IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        if (is == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        char s[] = new char[10];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        int firstc = is.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        while (firstc != '\n' && firstc != '\r' && firstc >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            int len = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            int keyend = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            int c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            boolean inKey = firstc > ' ';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            s[len++] = (char) firstc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    parseloop:{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                while ((c = is.read()) >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                    switch (c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                      case ':':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                        if (inKey && len > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                            keyend = len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                        inKey = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                      case '\t':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                        c = ' ';
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 7668
diff changeset
   423
                      /*fall through*/
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                      case ' ':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                        inKey = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                      case '\r':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                      case '\n':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                        firstc = is.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                        if (c == '\r' && firstc == '\n') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                            firstc = is.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                            if (firstc == '\r')
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                                firstc = is.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                        if (firstc == '\n' || firstc == '\r' || firstc > ' ')
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                            break parseloop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                        /* continuation */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                        c = ' ';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                    if (len >= s.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                        char ns[] = new char[s.length * 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                        System.arraycopy(s, 0, ns, 0, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                        s = ns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                    s[len++] = (char) c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                firstc = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            while (len > 0 && s[len - 1] <= ' ')
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                len--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            String k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            if (keyend <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                k = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                keyend = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                k = String.copyValueOf(s, 0, keyend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                if (keyend < len && s[keyend] == ':')
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                    keyend++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                while (keyend < len && s[keyend] <= ' ')
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                    keyend++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            String v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            if (keyend >= len)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                v = new String();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                v = String.copyValueOf(s, keyend, len - keyend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            add(k, v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    public synchronized String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        String result = super.toString() + nkeys + " pairs: ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        for (int i = 0; i < keys.length && i < nkeys; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            result += "{"+keys[i]+": "+values[i]+"}";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
}