Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/management/DiagnosticCommandArgumentInfo.java
38827 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.management;2627/**28* Diagnostic Command Argument information. It contains the description29* of one parameter of the diagnostic command. A parameter can either be an30* option or an argument. Options are identified by the option name while31* arguments are identified by their position in the command line. The generic32* syntax of a diagnostic command is:33* <blockquote>34* <command name> [<option>=<value>] [<argument_value>]35* </blockquote>36* Example:37* <blockquote>38* command_name option1=value1 option2=value argumentA argumentB argumentC39* </blockquote>40* In this command line, the diagnostic command receives five parameters, two41* options named {@code option1} and {@code option2}, and three arguments.42* argumentA's position is 0, argumentB's position is 1 and argumentC's43* position is 2.44*45* @since 846*/4748class DiagnosticCommandArgumentInfo {49private final String name;50private final String description;51private final String type;52private final String defaultValue;53private final boolean mandatory;54private final boolean option;55private final boolean multiple;56private final int position;5758/**59* Returns the argument name.60*61* @return the argument name62*/63String getName() {64return name;65}6667/**68* Returns the argument description.69*70* @return the argument description71*/72String getDescription() {73return description;74}7576/**77* Returns the argument type.78*79* @return the argument type80*/81String getType() {82return type;83}8485/**86* Returns the default value as a String if a default value87* is defined, null otherwise.88*89* @return the default value as a String if a default value90* is defined, null otherwise.91*/92String getDefault() {93return defaultValue;94}9596/**97* Returns {@code true} if the argument is mandatory,98* {@code false} otherwise.99*100* @return {@code true} if the argument is mandatory,101* {@code false} otherwise102*/103boolean isMandatory() {104return mandatory;105}106107/**108* Returns {@code true} if the argument is an option,109* {@code false} otherwise. Options have to be specified using the110* <key>=<value> syntax on the command line, while other111* arguments are specified with a single <value> field and are112* identified by their position on command line.113*114* @return {@code true} if the argument is an option,115* {@code false} otherwise116*/117boolean isOption() {118return option;119}120121/**122* Returns {@code true} if the argument can be specified multiple times,123* {@code false} otherwise.124*125* @return {@code true} if the argument can be specified multiple times,126* {@code false} otherwise127*/128boolean isMultiple() {129return multiple;130}131132/**133* Returns the expected position of this argument if it is not an option,134* -1 otherwise. Argument position if defined from left to right,135* starting at zero and ignoring the diagnostic command name and136* options.137*138* @return the expected position of this argument if it is not an option,139* -1 otherwise.140*/141int getPosition() {142return position;143}144145DiagnosticCommandArgumentInfo(String name, String description,146String type, String defaultValue,147boolean mandatory, boolean option,148boolean multiple, int position) {149this.name = name;150this.description = description;151this.type = type;152this.defaultValue = defaultValue;153this.mandatory = mandatory;154this.option = option;155this.multiple = multiple;156this.position = position;157}158}159160161