📄 hello.java
字号:
package net.jxta.impl.shell.bin.hello;
import net.jxta.impl.shell.*;
import java.io.*;
import java.util.*;
import net.jxta.pipe.*;
import net.jxta.document.*;
import net.jxta.protocol.*;
import net.jxta.endpoint.*;
/**
* Our first shell command
*/
public class hello extends ShellApp {
/**
* For access to the shell environment
*/
ShellEnv env;
public hello() {
}
/**
* Called when the shell application stops running.
*/
public void stopApp () {
}
/**
* Called when the shell application is launched in the shell.
*/
public int startApp (String[] args) {
env = getEnv();
if(args.length==2 && "-store".equals(args[0])) {
// Create a new shell object and add it to the environment
// variable space
env.add("helloname", new ShellObject(null,args[1]));
println("stored name");
}
if(args.length==0) {
// Retrieve the shell object with label 'helloname'
// If it's not null use it
ShellObject nameObj = env.get("helloname");
if(nameObj==null) {
println ("Hello World!!");
} else {
println("Hi "+(String)nameObj.getObject()+"!");
}
}
// Return no error
return ShellApp.appNoError;
}
/**
* Returns a description of this command.
*/
public String getDescription() {
return "Says hello to the world!";
}
/**
* Called to trigger help (e.g. when doing a 'man hello')
*/
public void help() {
println("hello [-store name]");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -