src/java.naming/share/classes/javax/naming/ldap/Rfc2253Parser.java
author stefank
Mon, 25 Nov 2019 15:00:32 +0100
changeset 59255 a74627659f96
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234602: ZGC: Windows compile error in ZHeuristic Reviewed-by: pliden, eosterlund
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
     2
 * Copyright (c) 2003, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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
package javax.naming.ldap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.naming.InvalidNameException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * RFC2253Parser implements a recursive descent parser for a single DN.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
final class Rfc2253Parser {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        private final String name;      // DN being parsed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
        private final char[] chars;     // characters in LDAP name being parsed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        private final int len;  // length of "chars"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        private int cur = 0;    // index of first unconsumed char in "chars"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
         * Given an LDAP DN in string form, returns a parser for it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        Rfc2253Parser(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
            this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
            len = name.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
            chars = name.toCharArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
         * Parses the DN, returning a List of its RDNs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        // public List<Rdn> getDN() throws InvalidNameException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    57
        List<Rdn> parseDn() throws InvalidNameException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            cur = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
            // ArrayList<Rdn> rdns =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            //  new ArrayList<Rdn>(len / 3 + 10);  // leave room for growth
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    63
            ArrayList<Rdn> rdns =
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    64
                new ArrayList<>(len / 3 + 10);  // leave room for growth
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            if (len == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                return rdns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            rdns.add(doParse(new Rdn()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            while (cur < len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                if (chars[cur] == ',' || chars[cur] == ';') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                    ++cur;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                    rdns.add(0, doParse(new Rdn()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                    throw new InvalidNameException("Invalid name: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            return rdns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
         * Parses the DN, if it is known to contain a single RDN.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        Rdn parseRdn() throws InvalidNameException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            return parseRdn(new Rdn());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
         * Parses the DN, if it is known to contain a single RDN.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        Rdn parseRdn(Rdn rdn) throws InvalidNameException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            rdn = doParse(rdn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            if (cur < len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                throw new InvalidNameException("Invalid RDN: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            return rdn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
         * Parses the next RDN and returns it.  Throws an exception if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
         * none is found.  Leading and trailing whitespace is consumed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
         private Rdn doParse(Rdn rdn) throws InvalidNameException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            while (cur < len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                consumeWhitespace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                String attrType = parseAttrType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                consumeWhitespace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                if (cur >= len || chars[cur] != '=') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                    throw new InvalidNameException("Invalid name: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                ++cur;          // consume '='
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                consumeWhitespace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                String value = parseAttrValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                consumeWhitespace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                rdn.put(attrType, Rdn.unescapeValue(value));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                if (cur >= len || chars[cur] != '+') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                ++cur;          // consume '+'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            rdn.sort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            return rdn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
         * Returns the attribute type that begins at the next unconsumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
         * char.  No leading whitespace is expected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
         * This routine is more generous than RFC 2253.  It accepts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
         * attribute types composed of any nonempty combination of Unicode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
         * letters, Unicode digits, '.', '-', and internal space characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        private String parseAttrType() throws InvalidNameException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            final int beg = cur;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            while (cur < len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                char c = chars[cur];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                if (Character.isLetterOrDigit(c) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                        c == '.' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                        c == '-' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                        c == ' ') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                    ++cur;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            // Back out any trailing spaces.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            while ((cur > beg) && (chars[cur - 1] == ' ')) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                --cur;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            if (beg == cur) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                throw new InvalidNameException("Invalid name: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            return new String(chars, beg, cur - beg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
         * Returns the attribute value that begins at the next unconsumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
         * char.  No leading whitespace is expected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        private String parseAttrValue() throws InvalidNameException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            if (cur < len && chars[cur] == '#') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                return parseBinaryAttrValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            } else if (cur < len && chars[cur] == '"') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                return parseQuotedAttrValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                return parseStringAttrValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        private String parseBinaryAttrValue() throws InvalidNameException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            final int beg = cur;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            ++cur;                      // consume '#'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            while ((cur < len) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                    Character.isLetterOrDigit(chars[cur])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                ++cur;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            return new String(chars, beg, cur - beg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        private String parseQuotedAttrValue() throws InvalidNameException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            final int beg = cur;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            ++cur;                      // consume '"'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            while ((cur < len) && chars[cur] != '"') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                if (chars[cur] == '\\') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                    ++cur;              // consume backslash, then what follows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                ++cur;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            if (cur >= len) {   // no closing quote
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                throw new InvalidNameException("Invalid name: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            ++cur;      // consume closing quote
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            return new String(chars, beg, cur - beg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        private String parseStringAttrValue() throws InvalidNameException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            final int beg = cur;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            int esc = -1;       // index of the most recently escaped character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            while ((cur < len) && !atTerminator()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                if (chars[cur] == '\\') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                    ++cur;              // consume backslash, then what follows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                    esc = cur;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                ++cur;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            if (cur > len) {            // 'twas backslash followed by nothing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                throw new InvalidNameException("Invalid name: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            // Trim off (unescaped) trailing whitespace.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            int end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            for (end = cur; end > beg; end--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                if (!isWhitespace(chars[end - 1]) || (esc == end - 1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            return new String(chars, beg, end - beg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        private void consumeWhitespace() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            while ((cur < len) && isWhitespace(chars[cur])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                ++cur;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
         * Returns true if next unconsumed character is one that terminates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
         * a string attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        private boolean atTerminator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            return (cur < len &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                    (chars[cur] == ',' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                        chars[cur] == ';' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                        chars[cur] == '+'));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
         * Best guess as to what RFC 2253 means by "whitespace".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        private static boolean isWhitespace(char c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            return (c == ' ' || c == '\r');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }