Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.internal.opt/share/classes/jdk/internal/joptsimple/OptionDeclarer.java
40948 views
1
/*
2
* Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
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
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package jdk.internal.joptsimple;
27
28
import java.util.List;
29
30
/**
31
* Trains the option parser. This interface aids integration that disposes declaration of options but not actual
32
* command-line parsing.
33
*
34
* Typical use is for another class to implement {@code OptionDeclarer} as a facade, forwarding calls to an
35
* {@code OptionParser} instance.
36
*
37
* Note that although this is an interface, the returned values of calls are concrete jopt-simple classes.
38
*
39
* @author <a href="mailto:[email protected]">Paul Holser</a>
40
* @see OptionParser
41
* @since 4.6
42
*/
43
public interface OptionDeclarer {
44
/**
45
* Tells the parser to recognize the given option.
46
*
47
* <p>This method returns an instance of {@link OptionSpecBuilder} to allow the formation of parser directives
48
* as sentences in a fluent interface language. For example:</p>
49
*
50
* <pre><code>
51
* OptionDeclarer parser = new OptionParser();
52
* parser.<strong>accepts( "c" )</strong>.withRequiredArg().ofType( Integer.class );
53
* </code></pre>
54
*
55
* <p>If no methods are invoked on the returned {@link OptionSpecBuilder}, then the parser treats the option as
56
* accepting no argument.</p>
57
*
58
* @param option the option to recognize
59
* @return an object that can be used to flesh out more detail about the option
60
* @throws OptionException if the option contains illegal characters
61
* @throws NullPointerException if the option is {@code null}
62
*/
63
OptionSpecBuilder accepts( String option );
64
65
/**
66
* Tells the parser to recognize the given option.
67
*
68
* @see #accepts(String)
69
* @param option the option to recognize
70
* @param description a string that describes the purpose of the option. This is used when generating help
71
* information about the parser.
72
* @return an object that can be used to flesh out more detail about the option
73
* @throws OptionException if the option contains illegal characters
74
* @throws NullPointerException if the option is {@code null}
75
*/
76
OptionSpecBuilder accepts( String option, String description );
77
78
/**
79
* Tells the parser to recognize the given options, and treat them as synonymous.
80
*
81
* @see #accepts(String)
82
* @param options the options to recognize and treat as synonymous
83
* @return an object that can be used to flesh out more detail about the options
84
* @throws OptionException if any of the options contain illegal characters
85
* @throws NullPointerException if the option list or any of its elements are {@code null}
86
*/
87
OptionSpecBuilder acceptsAll( List<String> options );
88
89
/**
90
* Tells the parser to recognize the given options, and treat them as synonymous.
91
*
92
* @see #acceptsAll(List)
93
* @param options the options to recognize and treat as synonymous
94
* @param description a string that describes the purpose of the option. This is used when generating help
95
* information about the parser.
96
* @return an object that can be used to flesh out more detail about the options
97
* @throws OptionException if any of the options contain illegal characters
98
* @throws NullPointerException if the option list or any of its elements are {@code null}
99
* @throws IllegalArgumentException if the option list is empty
100
*/
101
OptionSpecBuilder acceptsAll( List<String> options, String description );
102
103
/**
104
* Gives an object that represents an access point for non-option arguments on a command line.
105
*
106
* @return an object that can be used to flesh out more detail about the non-option arguments
107
*/
108
NonOptionArgumentSpec<String> nonOptions();
109
110
/**
111
* Gives an object that represents an access point for non-option arguments on a command line.
112
*
113
* @see #nonOptions()
114
* @param description a string that describes the purpose of the non-option arguments. This is used when generating
115
* help information about the parser.
116
* @return an object that can be used to flesh out more detail about the non-option arguments
117
*/
118
NonOptionArgumentSpec<String> nonOptions( String description );
119
120
/**
121
* Tells the parser whether or not to behave "POSIX-ly correct"-ly.
122
*
123
* @param setting {@code true} if the parser should behave "POSIX-ly correct"-ly
124
*/
125
void posixlyCorrect( boolean setting );
126
127
/**
128
* <p>Tells the parser to treat unrecognized options as non-option arguments.</p>
129
*
130
* <p>If not called, then the parser raises an {@link OptionException} when it encounters an unrecognized
131
* option.</p>
132
*/
133
void allowsUnrecognizedOptions();
134
135
/**
136
* Tells the parser either to recognize or ignore {@code -W}-style long options.
137
*
138
* @param recognize {@code true} if the parser is to recognize the special style of long options
139
*/
140
void recognizeAlternativeLongOptions( boolean recognize );
141
}
142
143