Skip to content

Commit 17db40e

Browse files
committed
fix(javadoc): phase 9 — CMF enum, CLIContext/CLI/CLISubSystem expansion, SsmActionBase
- CMF.java: add inline comments to all 163 undocumented enum constants - CLIContext: expand all inline /** @... */ javadocs to multi-line with descriptions (getActiveSubSystem, setActiveSubSystem, isStopped, setStopped, getReader, setReader, getOutputStream, getErrorStream, getInputStream, getUserData, isInteractive, getCLI, printUserData, printThrowable, printLoggeable, print, println, confirm, readSecurely, builder(), Builder class + all 6 builder methods) - CLI: expand all inline javadocs to multi-line with descriptions (running, getCompletionPrefixes, getQ2, isInteractive, getReader, exec(2 overloads), buildTerminal, constructor javadocs) - CLICommandInterface: expand all inline javadocs - CLISubSystem: expand getPrompt() and getCompletionPrefixes() javadocs - CLIPrefixedClassNameCompleter: expand constructor javadoc - SsmActionBase: add constructor + documented checkUsage/doCommand abstract methods - ChannelAdaptor: expand grabSpace() inline javadoc - IRC.java: expand getIRC/isSuccess/isInhibit javadocs
1 parent 20bf6a3 commit 17db40e

File tree

8 files changed

+343
-47
lines changed

8 files changed

+343
-47
lines changed

jpos/src/main/java/org/jpos/q2/CLI.java

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ public CLI(Q2 q2, InputStream in, OutputStream rawout, String line, boolean keep
7878
initCmdInterface(getCompletionPrefixes(), mainHistory);
7979
}
8080

81-
/** @return true if this CLI is still running */
81+
/**
82+
* Returns true if this CLI is still running.
83+
* @return true if running
84+
*/
8285
protected boolean running() {
8386
return getQ2() == null || getQ2().running();
8487
}
@@ -89,7 +92,10 @@ protected void markStopped() { }
8992
/** Called when the CLI is starting; subclasses may override. */
9093
protected void markStarted() { }
9194

92-
/** @return array of command prefixes for tab-completion */
95+
/**
96+
* Returns command prefixes registered for tab-completion.
97+
* @return array of command prefixes
98+
*/
9399
protected String[] getCompletionPrefixes() {
94100
return new String[] {"org.jpos.q2.cli." };
95101
}
@@ -197,22 +203,33 @@ public void run() {
197203
handleExit();
198204
}
199205

200-
/** @return the Q2 instance this CLI is attached to */
206+
/**
207+
* Returns the Q2 instance this CLI is attached to.
208+
* @return the Q2 instance
209+
*/
201210
public Q2 getQ2() {
202211
return q2;
203212
}
204213

205-
/** @return true if this is an interactive session */
214+
/**
215+
* Returns true if this CLI session is interactive.
216+
* @return true if interactive
217+
*/
206218
public boolean isInteractive() {
207219
return interactive;
208220
}
209221

210-
/** @return the JLine3 LineReader for this session */
222+
/**
223+
* Returns the JLine3 LineReader for this session.
224+
* @return the LineReader
225+
*/
211226
public LineReader getReader() {
212227
return reader;
213228
}
214229

215-
/** @param in input stream
230+
/**
231+
* Executes a CLI command with the given I/O streams.
232+
* @param in input stream
216233
* @param out output stream
217234
* @param command command to execute
218235
* @throws Exception on execution failure
@@ -223,7 +240,9 @@ public static void exec (InputStream in, OutputStream out, String command) throw
223240
cli.stop();
224241
}
225242

226-
/** @param command command string to execute
243+
/**
244+
* Executes a CLI command and captures its output as a string.
245+
* @param command command string to execute
227246
* @return captured output
228247
* @throws Exception on execution failure
229248
*/
@@ -233,9 +252,11 @@ public static String exec (String command) throws Exception {
233252
return out.toString();
234253
}
235254

236-
/** @param in input stream
255+
/**
256+
* Builds a JLine3 Terminal for this session.
257+
* @param in input stream
237258
* @param out output stream
238-
* @return a JLine3 Terminal for this session
259+
* @return the Terminal
239260
* @throws IOException on I/O failure
240261
*/
241262
protected Terminal buildTerminal (InputStream in, OutputStream out) throws IOException {

jpos/src/main/java/org/jpos/q2/CLICommandInterface.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,33 @@ public class CLICommandInterface {
3232
CLIContext ctx;
3333
List<String> prefixes = new ArrayList<String>();
3434

35-
/** @return the list of registered command prefixes */
35+
/**
36+
* Returns the list of registered command prefixes.
37+
* @return command prefix list
38+
*/
3639
public List<String> getPrefixes() {
3740
return prefixes;
3841
}
3942

40-
/** @param ctx the CLI context for this interface */
43+
/**
44+
* Creates a CLICommandInterface for the given context.
45+
* @param ctx the CLI context
46+
*/
4147
public CLICommandInterface(CLIContext ctx) {
4248
this.ctx = ctx;
4349
}
4450

45-
/** @param prefix a command prefix to register */
51+
/**
52+
* Registers a command prefix.
53+
* @param prefix the prefix to add
54+
*/
4655
public void addPrefix(String prefix) {
4756
prefixes.add(prefix);
4857
}
4958

50-
/** @param line the full command line to execute
59+
/**
60+
* Executes the given command line.
61+
* @param line the full command line
5162
* @throws IOException on I/O failure
5263
*/
5364
public void execCommand(String line) throws IOException {
@@ -98,7 +109,9 @@ private Object getCommand(String className) throws ClassNotFoundException, Insta
98109
return cl.loadClass(className).newInstance();
99110
}
100111

101-
/** @param line the full command line to parse
112+
/**
113+
* Parses a command line into tokens.
114+
* @param line the full command line
102115
* @return tokens: [prefix, command, args...]
103116
* @throws IOException on I/O failure
104117
*/

jpos/src/main/java/org/jpos/q2/CLIContext.java

Lines changed: 103 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,18 @@ private CLIContext(CLI cli, OutputStream out, OutputStream err, InputStream in,
4848
this.userData = userData;
4949
}
5050

51-
/** @return the name of the active CLI sub-system, or null */
51+
/**
52+
* Returns the name of the active CLI sub-system.
53+
* @return the active sub-system name, or null
54+
*/
5255
public String getActiveSubSystem() {
5356
return activeSubSystem;
5457
}
5558

56-
/** @param subSystem the name of the new active sub-system */
59+
/**
60+
* Sets the active CLI sub-system by name.
61+
* @param subSystem the name of the new active sub-system
62+
*/
5763
public void setActiveSubSystem(String subSystem) {
5864
String activeSubSystem = getActiveSubSystem();
5965
if (subSystem == null && activeSubSystem != null) {
@@ -62,52 +68,82 @@ public void setActiveSubSystem(String subSystem) {
6268
this.activeSubSystem = subSystem;
6369
}
6470

65-
/** @return true if this CLI session has been stopped */
71+
/**
72+
* Returns true if this CLI session has been stopped.
73+
* @return true if stopped
74+
*/
6675
public boolean isStopped() {
6776
return stopped;
6877
}
6978

70-
/** @param stopped true to mark this session as stopped */
79+
/**
80+
* Marks this CLI session as stopped.
81+
* @param stopped true to stop
82+
*/
7183
public void setStopped(boolean stopped) {
7284
this.stopped = stopped;
7385
}
7486

75-
/** @return the JLine3 LineReader for interactive input */
87+
/**
88+
* Returns the JLine3 LineReader for interactive input.
89+
* @return the LineReader
90+
*/
7691
public LineReader getReader() {
7792
return reader;
7893
}
7994

80-
/** @param reader the JLine3 LineReader */
95+
/**
96+
* Sets the JLine3 LineReader.
97+
* @param reader the LineReader
98+
*/
8199
public void setReader(LineReader reader) {
82100
this.reader = reader;
83101
}
84102

85-
/** @return the standard output stream for this session */
103+
/**
104+
* Returns the standard output stream for this session.
105+
* @return the output stream
106+
*/
86107
public OutputStream getOutputStream() {
87108
return out;
88109
}
89110

90-
/** @return the error stream for this session */
111+
/**
112+
* Returns the error stream for this session.
113+
* @return the error stream
114+
*/
91115
public OutputStream getErrorStream() {
92116
return err;
93117
}
94118

95-
/** @return the input stream for this session */
119+
/**
120+
* Returns the input stream for this session.
121+
* @return the input stream
122+
*/
96123
public InputStream getInputStream() {
97124
return in;
98125
}
99126

100-
/** @return mutable user-data map for sharing state across CLI commands */
127+
/**
128+
* Returns the mutable user-data map for sharing state across CLI commands.
129+
* @return user data map
130+
*/
101131
public Map<Object,Object> getUserData() {
102132
return userData;
103133
}
104134

105-
/** @return true if this session is interactive (has a LineReader) */
135+
/**
136+
* Returns true if this session is interactive (has a LineReader).
137+
* @return true if interactive
138+
*/
106139
public boolean isInteractive() {
107140
return cli.isInteractive();
108141
}
109142

110-
/** @return the CLI instance managing this context */
143+
/**
144+
* Returns the CLI instance managing this context.
145+
* @return the CLI
146+
*/
111147
public CLI getCLI() {
112148
return cli;
113149
}
@@ -120,14 +156,19 @@ public void printUserData() {
120156
});
121157
}
122158

123-
/** @param t the throwable to print (stack trace goes to error stream) */
159+
/**
160+
* Prints a throwable stack trace to the error stream.
161+
* @param t the throwable to print
162+
*/
124163
public void printThrowable(Throwable t) {
125164
ByteArrayOutputStream baos = new ByteArrayOutputStream();
126165
t.printStackTrace(new PrintStream(baos));
127166
println (baos.toString());
128167
}
129168

130-
/** @param l the Loggeable to dump
169+
/**
170+
* Dumps a Loggeable to the output stream.
171+
* @param l the Loggeable to dump
131172
* @param indent indentation prefix
132173
*/
133174
public void printLoggeable(Loggeable l, String indent) {
@@ -136,7 +177,10 @@ public void printLoggeable(Loggeable l, String indent) {
136177
println (baos.toString());
137178
}
138179

139-
/** @param s string to print (no trailing newline) */
180+
/**
181+
* Prints a string to the output stream (no trailing newline).
182+
* @param s the string to print
183+
*/
140184
public void print(String s) {
141185
if (isInteractive()) {
142186
PrintWriter writer = getReader().getTerminal().writer();
@@ -153,26 +197,36 @@ public void print(String s) {
153197
}
154198
}
155199

156-
/** @param s string to print followed by a newline */
200+
/**
201+
* Prints a string to the output stream followed by a newline.
202+
* @param s the string to print
203+
*/
157204
public void println(String s) {
158205
print (s + System.getProperty("line.separator"));
159206
}
160207

161-
/** @param prompt the confirmation prompt
208+
/**
209+
* Prompts the user for confirmation.
210+
* @param prompt the confirmation prompt
162211
* @return true if user confirmed
163212
*/
164213
public boolean confirm(String prompt) {
165214
return "yes".equalsIgnoreCase(getReader().readLine(prompt));
166215
}
167216

168-
/** @param prompt the prompt to display
169-
* @return the input string, read without echoing
217+
/**
218+
* Reads a string from the user without echoing (e.g. for passwords).
219+
* @param prompt the prompt to display
220+
* @return the input string
170221
*/
171222
public String readSecurely(String prompt) {
172223
return getReader().readLine(prompt, '*');
173224
}
174225

175-
/** @return a new Builder for constructing a CLIContext */
226+
/**
227+
* Returns a new Builder for constructing a CLIContext.
228+
* @return a new Builder
229+
*/
176230
public static Builder builder() {
177231
return new Builder();
178232
}
@@ -186,37 +240,60 @@ public static class Builder {
186240
CLI cli;
187241
private Builder () { }
188242

189-
/** @param out the standard output stream @return this */
243+
/**
244+
* Sets the standard output stream.
245+
* @param out the standard output stream
246+
* @return this
247+
*/
190248
public Builder out (OutputStream out) {
191249
this.out = out;
192250
return this;
193251
}
194252

195-
/** @param err the error stream @return this */
253+
/**
254+
* Sets the error stream.
255+
* @param err the error stream
256+
* @return this
257+
*/
196258
public Builder err (OutputStream err) {
197259
this.err = err;
198260
return this;
199261
}
200262

201-
/** @param in the input stream @return this */
263+
/**
264+
* Sets the input stream.
265+
* @param in the input stream
266+
* @return this
267+
*/
202268
public Builder in (InputStream in) {
203269
this.in = in;
204270
return this;
205271
}
206272

207-
/** @param reader the JLine3 LineReader @return this */
273+
/**
274+
* Sets the JLine3 LineReader.
275+
* @param reader the LineReader
276+
* @return this
277+
*/
208278
public Builder reader (LineReader reader) {
209279
this.reader = reader;
210280
return this;
211281
}
212282

213-
/** @param cli the CLI instance @return this */
283+
/**
284+
* Sets the CLI instance.
285+
* @param cli the CLI
286+
* @return this
287+
*/
214288
public Builder cli (CLI cli) {
215289
this.cli = cli;
216290
return this;
217291
}
218292

219-
/** @return the constructed CLIContext */
293+
/**
294+
* Builds and returns the CLIContext.
295+
* @return the constructed CLIContext
296+
*/
220297
public CLIContext build() {
221298
if (reader != null) {
222299
if (out == null)

0 commit comments

Comments
 (0)