com.github.andyshao.system.NoMatchTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Gear Show documentation
Show all versions of Gear Show documentation
Enhance and formating the coding of JDK
The newest version!
package com.github.andyshao.system;
import com.github.andyshao.reflect.ArrayOperation;
/**
*
* Title:
* Descript:
* Copyright: Copryright(c) Sep 10, 2015
* Encoding:UNIX UTF-8
*
* @author Andy.Shao
*
*/
public class NoMatchTask implements Task {
private Task nextTask;
@Override
public Task getNextTask() {
return this.nextTask;
}
private void goHelp() {
this.getNextTask().run(new String[] { HelpTask.KEY_WORDS });
}
@Override
public boolean isDuty(String[] args) {
return true;
}
@Override
public void process(String[] args) {
if (args == null || args.length <= 1) {
this.goHelp();
return;
}
int position = 1;
boolean status = true;
do
status = !args[position].startsWith("-");
while (status && ++position < args.length);
if (position == args.length - 1 && status) {
this.goHelp();
return;
} else this.getNextTask().run(ArrayOperation.splitArray(args , position , args.length));
}
/**
* set next task
* @param nextTask next task
*/
public void setNextTask(Task nextTask) {
this.nextTask = nextTask;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy