src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 45215 langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java@c9477e22877f
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     1
/*
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     2
 * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     4
 *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    10
 *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    15
 * accompanied this code).
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    16
 *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    20
 *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    23
 * questions.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    24
 */
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    25
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    26
package jdk.internal.jshell.tool;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    27
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    28
import java.util.ArrayList;
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    29
import java.util.Arrays;
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    30
import java.util.HashMap;
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    31
import java.util.List;
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    32
import java.util.Map;
42827
36468b5fa7f4 8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents: 41635
diff changeset
    33
import java.util.Map.Entry;
36468b5fa7f4 8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents: 41635
diff changeset
    34
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    35
import static java.util.stream.Collectors.toList;
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    36
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    37
/**
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    38
 * Parse command arguments, derived from StreamTokenizer by
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    39
 * @author  James Gosling
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    40
 */
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    41
class ArgTokenizer {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    42
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    43
    private final String str;
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36494
diff changeset
    44
    private final String prefix;
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    45
    private final int length;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    46
    private int next = 0;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    47
    private char buf[] = new char[20];
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    48
    private int mark;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    49
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    50
    private final byte ctype[] = new byte[256];
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    51
    private static final byte CT_ALPHA = 0;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    52
    private static final byte CT_WHITESPACE = 1;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    53
    private static final byte CT_QUOTE = 8;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    54
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    55
    private String sval;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    56
    private boolean isQuoted = false;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    57
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    58
    private final Map<String, Boolean> options = new HashMap<>();
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    59
    private final List<String> badOptions = new ArrayList<>();
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36494
diff changeset
    60
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36494
diff changeset
    61
    ArgTokenizer(String prefix, String arg) {
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    62
        this.str = arg;
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    63
        this.prefix = prefix + " ";
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    64
        this.length = arg.length();
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    65
        quoteChar('"');
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    66
        quoteChar('\'');
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    67
        whitespaceChars(0x09, 0x0D);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    68
        whitespaceChars(0x1C, 0x20);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    69
        whitespaceChars(0x85, 0x85);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    70
        whitespaceChars(0xA0, 0xA0);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    71
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    72
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    73
    /**
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    74
     * Return the next non-option argument. Encountered options are stored.
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    75
     *
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    76
     * @return the token string, or null if there are no more tokens
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    77
     */
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    78
    String next() {
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    79
        while (true) {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    80
            nextToken();
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    81
            if (sval != null && !isQuoted() && sval.startsWith("-")) {
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38539
diff changeset
    82
                // allow POSIX getopt() option format,
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38539
diff changeset
    83
                // to be consistent with command-line
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38539
diff changeset
    84
                String opt = sval.startsWith("--")
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38539
diff changeset
    85
                        ? sval.substring(1)
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38539
diff changeset
    86
                        : sval;
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38539
diff changeset
    87
                foundOption(opt);
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    88
            } else {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    89
                break;
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    90
            }
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    91
        }
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    92
        return sval;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    93
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    94
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    95
    private void foundOption(String opt) {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    96
        if (options.containsKey(opt)) {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    97
            options.put(opt, true);
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    98
            return;
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    99
        }
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   100
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   101
        List<Map.Entry<String,Boolean>> matches =
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   102
                options.entrySet()
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   103
                       .stream()
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   104
                       .filter(e -> e.getKey().startsWith(opt))
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   105
                       .collect(toList());
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   106
        if (matches.size() == 1) {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   107
            matches.get(0).setValue(true);
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   108
        } else {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   109
            badOptions.add(opt);
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   110
        }
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   111
    }
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   112
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   113
    /**
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   114
     * Set the allowed options. Must be called before any options would be read
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   115
     * and before calling any of the option functionality below.
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   116
     */
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   117
    void allowedOptions(String... opts) {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   118
        for (String opt : opts) {
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38539
diff changeset
   119
            options.putIfAbsent(opt, false);
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   120
        }
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   121
    }
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   122
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   123
    /**
45215
c9477e22877f 8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents: 42827
diff changeset
   124
     * Is the specified option allowed.
c9477e22877f 8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents: 42827
diff changeset
   125
     *
c9477e22877f 8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents: 42827
diff changeset
   126
     * @param opt the option to check
c9477e22877f 8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents: 42827
diff changeset
   127
     * @return true if the option is allowed
c9477e22877f 8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents: 42827
diff changeset
   128
     */
c9477e22877f 8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents: 42827
diff changeset
   129
    boolean isAllowedOption(String opt) {
c9477e22877f 8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents: 42827
diff changeset
   130
        Boolean has = options.get(opt);
c9477e22877f 8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents: 42827
diff changeset
   131
        return has != null;
c9477e22877f 8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents: 42827
diff changeset
   132
    }
c9477e22877f 8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents: 42827
diff changeset
   133
c9477e22877f 8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents: 42827
diff changeset
   134
    /**
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   135
     * Has the specified option been encountered.
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   136
     *
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   137
     * @param opt the option to check
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   138
     * @return true if the option has been encountered
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   139
     */
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   140
    boolean hasOption(String opt) {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   141
        Boolean has = options.get(opt);
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   142
        if (has == null) {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   143
            throw new InternalError("hasOption called before allowedOptions or on bad option");
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   144
        }
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   145
        return has;
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   146
    }
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   147
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   148
    /**
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   149
     * Return the number of encountered options
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   150
     *
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   151
     * @return the option count
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   152
     */
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   153
    int optionCount() {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   154
        return (int) options.entrySet().stream()
42827
36468b5fa7f4 8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents: 41635
diff changeset
   155
                .filter(Entry::getValue)
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   156
                .count();
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   157
    }
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   158
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   159
    /**
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   160
     * Return the bad options encountered. Bad options are those that were not
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   161
     * listed in the call to allowedOptions().
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   162
     *
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   163
     * @return as space-separated list the bad options encountered, or the empty
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   164
     * string if none.
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   165
     */
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   166
    String badOptions() {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   167
        return String.join(" ", badOptions);
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   168
    }
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   169
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   170
    /**
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   171
     * Consume the remainder of the input. This is useful to sure all options
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   172
     * have been encountered and to check to unexpected additional non-option
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   173
     * input.
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   174
     *
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   175
     * @return the string-separated concatenation of all remaining non-option
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   176
     * arguments.
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   177
     */
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   178
    String remainder() {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   179
        List<String> rem = new ArrayList<>();
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   180
        while (next() != null) {
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   181
            rem.add(sval);
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   182
        }
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   183
        return String.join(" ", rem);
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   184
    }
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   185
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   186
    String val() {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   187
        return sval;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   188
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   189
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   190
    boolean isQuoted() {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   191
        return isQuoted;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   192
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   193
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   194
    String whole() {
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 36494
diff changeset
   195
        return prefix + str;
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   196
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   197
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   198
    void mark() {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   199
        mark = next;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   200
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   201
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   202
    void rewind() {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   203
        next = mark;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   204
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   205
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   206
    /**
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   207
     * Reads a single character.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   208
     *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   209
     * @return The character read, or -1 if the end of the stream has been
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   210
     * reached
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   211
     */
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   212
    private int read() {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   213
        if (next >= length) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   214
            return -1;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   215
        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   216
        return str.charAt(next++);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   217
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   218
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   219
    /**
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   220
     * Specifies that all characters <i>c</i> in the range
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   221
     * <code>low&nbsp;&lt;=&nbsp;<i>c</i>&nbsp;&lt;=&nbsp;high</code>
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   222
     * are white space characters. White space characters serve only to
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   223
     * separate tokens in the input stream.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   224
     *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   225
     * <p>Any other attribute settings for the characters in the specified
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   226
     * range are cleared.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   227
     *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   228
     * @param   low   the low end of the range.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   229
     * @param   hi    the high end of the range.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   230
     */
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   231
    private void whitespaceChars(int low, int hi) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   232
        if (low < 0)
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   233
            low = 0;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   234
        if (hi >= ctype.length)
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   235
            hi = ctype.length - 1;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   236
        while (low <= hi)
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   237
            ctype[low++] = CT_WHITESPACE;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   238
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   239
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   240
    /**
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   241
     * Specifies that matching pairs of this character delimit string
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   242
     * constants in this tokenizer.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   243
     * <p>
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   244
     * If a string quote character is encountered, then a string is
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   245
     * recognized, consisting of all characters after (but not including)
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   246
     * the string quote character, up to (but not including) the next
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   247
     * occurrence of that same string quote character, or a line
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   248
     * terminator, or end of file. The usual escape sequences such as
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   249
     * {@code "\u005Cn"} and {@code "\u005Ct"} are recognized and
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   250
     * converted to single characters as the string is parsed.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   251
     *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   252
     * <p>Any other attribute settings for the specified character are cleared.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   253
     *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   254
     * @param   ch   the character.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   255
     */
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   256
    private void quoteChar(int ch) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   257
        if (ch >= 0 && ch < ctype.length)
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   258
            ctype[ch] = CT_QUOTE;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   259
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   260
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   261
    private int unicode2ctype(int c) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   262
        switch (c) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   263
            case 0x1680:
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   264
            case 0x180E:
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   265
            case 0x200A:
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   266
            case 0x202F:
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   267
            case 0x205F:
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   268
            case 0x3000:
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   269
                return CT_WHITESPACE;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   270
            default:
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   271
                return CT_ALPHA;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   272
        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   273
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   274
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   275
    /**
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   276
     * Parses the next token of this tokenizer.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   277
     */
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   278
    public void nextToken() {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   279
        byte ct[] = ctype;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   280
        int c;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   281
        int lctype;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   282
        sval = null;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   283
        isQuoted = false;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   284
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   285
        do {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   286
            c = read();
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   287
            if (c < 0) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   288
                return;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   289
            }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   290
            lctype = (c < 256) ? ct[c] : unicode2ctype(c);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   291
        } while (lctype == CT_WHITESPACE);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   292
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   293
        if (lctype == CT_ALPHA) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   294
            int i = 0;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   295
            do {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   296
                if (i >= buf.length) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   297
                    buf = Arrays.copyOf(buf, buf.length * 2);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   298
                }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   299
                buf[i++] = (char) c;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   300
                c = read();
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   301
                lctype = c < 0 ? CT_WHITESPACE : (c < 256)? ct[c] : unicode2ctype(c);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   302
            } while (lctype == CT_ALPHA);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   303
            if (c >= 0) --next; // push last back
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   304
            sval = String.copyValueOf(buf, 0, i);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   305
            return;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   306
        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   307
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   308
        if (lctype == CT_QUOTE) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   309
            int quote = c;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   310
            int i = 0;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   311
            /* Invariants (because \Octal needs a lookahead):
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   312
             *   (i)  c contains char value
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   313
             *   (ii) d contains the lookahead
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   314
             */
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   315
            int d = read();
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   316
            while (d >= 0 && d != quote) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   317
                if (d == '\\') {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   318
                    c = read();
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   319
                    int first = c;   /* To allow \377, but not \477 */
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   320
                    if (c >= '0' && c <= '7') {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   321
                        c = c - '0';
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   322
                        int c2 = read();
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   323
                        if ('0' <= c2 && c2 <= '7') {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   324
                            c = (c << 3) + (c2 - '0');
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   325
                            c2 = read();
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   326
                            if ('0' <= c2 && c2 <= '7' && first <= '3') {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   327
                                c = (c << 3) + (c2 - '0');
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   328
                                d = read();
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   329
                            } else
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   330
                                d = c2;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   331
                        } else
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   332
                          d = c2;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   333
                    } else {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   334
                        switch (c) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   335
                        case 'a':
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   336
                            c = 0x7;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   337
                            break;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   338
                        case 'b':
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   339
                            c = '\b';
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   340
                            break;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   341
                        case 'f':
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   342
                            c = 0xC;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   343
                            break;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   344
                        case 'n':
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   345
                            c = '\n';
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   346
                            break;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   347
                        case 'r':
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   348
                            c = '\r';
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   349
                            break;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   350
                        case 't':
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   351
                            c = '\t';
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   352
                            break;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   353
                        case 'v':
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   354
                            c = 0xB;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   355
                            break;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   356
                        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   357
                        d = read();
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   358
                    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   359
                } else {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   360
                    c = d;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   361
                    d = read();
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   362
                }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   363
                if (i >= buf.length) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   364
                    buf = Arrays.copyOf(buf, buf.length * 2);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   365
                }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   366
                buf[i++] = (char)c;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   367
            }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   368
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   369
            if (d == quote) {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   370
                isQuoted = true;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   371
            }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   372
            sval = String.copyValueOf(buf, 0, i);
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   373
        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   374
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   375
}