src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HeaderParser.java
changeset 48083 b1c1b4ef4be2
parent 47216 71c04702a3d5
child 55973 4d9b002587db
equal deleted inserted replaced
48081:89829dd3cc54 48083:b1c1b4ef4be2
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    56         this.raw = raw;
    56         this.raw = raw;
    57         tab = new String[asize][2];
    57         tab = new String[asize][2];
    58         parse();
    58         parse();
    59     }
    59     }
    60 
    60 
    61     private HeaderParser () { }
    61 //    private HeaderParser () { }
    62 
    62 
    63     /**
    63 //    /**
    64      * Creates a new HeaderParser from this, whose keys (and corresponding
    64 //     * Creates a new HeaderParser from this, whose keys (and corresponding
    65      * values) range from "start" to "end-1"
    65 //     * values) range from "start" to "end-1"
    66      */
    66 //     */
    67     public HeaderParser subsequence(int start, int end) {
    67 //    public HeaderParser subsequence(int start, int end) {
    68         if (start == 0 && end == nkeys) {
    68 //        if (start == 0 && end == nkeys) {
    69             return this;
    69 //            return this;
    70         }
    70 //        }
    71         if (start < 0 || start >= end || end > nkeys) {
    71 //        if (start < 0 || start >= end || end > nkeys) {
    72             throw new IllegalArgumentException("invalid start or end");
    72 //            throw new IllegalArgumentException("invalid start or end");
    73         }
    73 //        }
    74         HeaderParser n = new HeaderParser();
    74 //        HeaderParser n = new HeaderParser();
    75         n.tab = new String [asize][2];
    75 //        n.tab = new String [asize][2];
    76         n.asize = asize;
    76 //        n.asize = asize;
    77         System.arraycopy (tab, start, n.tab, 0, (end-start));
    77 //        System.arraycopy (tab, start, n.tab, 0, (end-start));
    78         n.nkeys= (end-start);
    78 //        n.nkeys= (end-start);
    79         return n;
    79 //        return n;
    80     }
    80 //    }
    81 
    81 
    82     private void parse() {
    82     private void parse() {
    83 
    83 
    84         if (raw != null) {
    84         if (raw != null) {
    85             raw = raw.trim();
    85             raw = raw.trim();
   214 
   214 
   215     public Iterator<String> keys () {
   215     public Iterator<String> keys () {
   216         return new ParserIterator (false);
   216         return new ParserIterator (false);
   217     }
   217     }
   218 
   218 
   219     public Iterator<String> values () {
   219 //    public Iterator<String> values () {
   220         return new ParserIterator (true);
   220 //        return new ParserIterator (true);
   221     }
   221 //    }
   222 
   222 
   223     @Override
   223     @Override
   224     public String toString () {
   224     public String toString () {
   225         Iterator<String> k = keys();
   225         Iterator<String> k = keys();
   226         StringBuilder sb = new StringBuilder();
   226         StringBuilder sb = new StringBuilder();
   240         }
   240         }
   241         sb.append (" }");
   241         sb.append (" }");
   242         return sb.toString();
   242         return sb.toString();
   243     }
   243     }
   244 
   244 
   245     public int findInt(String k, int Default) {
   245 //    public int findInt(String k, int Default) {
   246         try {
   246 //        try {
   247             return Integer.parseInt(findValue(k, String.valueOf(Default)));
   247 //            return Integer.parseInt(findValue(k, String.valueOf(Default)));
   248         } catch (Throwable t) {
   248 //        } catch (Throwable t) {
   249             return Default;
   249 //            return Default;
   250         }
   250 //        }
   251     }
   251 //    }
   252 }
   252 }