本文整理汇总了Java中com.sk89q.intake.parametric.ArgumentParser类的典型用法代码示例。如果您正苦于以下问题:Java ArgumentParser类的具体用法?Java ArgumentParser怎么用?Java ArgumentParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArgumentParser类属于com.sk89q.intake.parametric包,在下文中一共展示了ArgumentParser类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateDescription
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public void updateDescription(Set<Annotation> annotations, ArgumentParser parser, ImmutableDescription.Builder builder) {
for (Annotation annotation : annotations) {
if (annotation instanceof Command) {
Command command = (Command) annotation;
// Handle the case for old commands where no usage is set and all of its
// parameters are provider bindings, so its usage information would
// be blank and would imply that there were no accepted parameters
if (command.usage().isEmpty() && (command.min() > 0 || command.max() > 0)) {
if (!parser.getUserParameters().isEmpty()) {
builder.setUsageOverride("(unknown usage information)");
}
}
}
}
}
示例2: preInvoke
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public boolean preInvoke(List<? extends Annotation> annotations, ArgumentParser parser, Object[] args, CommandArgs commandArgs) throws CommandException, ArgumentException {
for (Annotation annotation : annotations) {
if (annotation instanceof Command) {
Command command = (Command) annotation;
if (commandArgs.size() < command.min()) {
throw new MissingArgumentException();
}
if (command.max() != -1 && commandArgs.size() > command.max()) {
List<String> unconsumedArguments = Lists.newArrayList();
while (true) {
try {
String value = commandArgs.next();
if (commandArgs.position() >= command.max()) {
unconsumedArguments.add(value);
}
} catch (MissingArgumentException ignored) {
break;
}
}
throw new UnusedArgumentException(Joiner.on(" ").join(unconsumedArguments));
}
}
}
return true;
}
示例3: fixCommandCompletion
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
private void fixCommandCompletion(Collection<CommandMapping> commandMappings) {
for (CommandMapping commandMapping : commandMappings) {
final CommandCallable callable = commandMapping.getCallable();
if (callable instanceof Dispatcher) {
fixCommandCompletion(((Dispatcher) callable).getCommands());
} else if (callable.getClass().getSimpleName().equals("MethodCallable")) {
try {
Field field = callable.getClass().getSuperclass().getDeclaredField("builder");
field.setAccessible(true);
final ParametricBuilder builder = (ParametricBuilder) field.get(callable);
field = callable.getClass().getSuperclass().getDeclaredField("parser");
field.setAccessible(true);
final ArgumentParser parser = (ArgumentParser) field.get(callable);
builder.setDefaultCompleter(this);
field = parser.getClass().getDeclaredField("parameters");
field.setAccessible(true);
final List parameterList = (List) field.get(parser);
if (parameterList.isEmpty()) continue;
final Method bindingsMethod = parameterList.get(0).getClass()
.getMethod("getBinding");
bindingsMethod.setAccessible(true);
final List<Binding<?>> bindings = new ArrayList<>();
for (Object o : parameterList) {
final Binding b = (Binding) bindingsMethod.invoke(o);
if (!b.getProvider().isProvided()) bindings.add(b);
}
bindingMap.put(commandMapping, bindings);
} catch (Exception e) {
CraftFX.log().severe("Error occurred while fixing tab completion for " +
"command %s",
MessageUtil.translate(null, callable.getDescription().getUsage()), e);
}
}
}
}
示例4: preProcess
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public boolean preProcess(List<? extends Annotation> annotations, ArgumentParser parser, CommandArgs commandArgs) throws CommandException, ArgumentException {
return true;
}
示例5: preInvoke
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public boolean preInvoke(List<? extends Annotation> annotations, ArgumentParser parser, Object[] args, CommandArgs commandArgs) throws CommandException, ArgumentException {
return true;
}
示例6: postInvoke
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public void postInvoke(List<? extends Annotation> annotations, ArgumentParser parser, Object[] args, CommandArgs commandArgs) throws CommandException, ArgumentException {
//no-op
}
示例7: updateDescription
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public void updateDescription(Set<Annotation> annotations, ArgumentParser parser, ImmutableDescription.Builder descriptionBuilder) {
//no-op
}
示例8: updateDescription
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public void updateDescription(Set<Annotation> annotations, ArgumentParser parser, Builder descriptionBuilder) {
}
示例9: postInvoke
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public void postInvoke(List<? extends Annotation> annotations, ArgumentParser parser, Object[] args, CommandArgs commandArgs) throws CommandException, ArgumentException {
}
示例10: updateDescription
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
/**
* Called to update the description of a command.
*
* @param annotations Annotations on the command
* @param parser The parser containing parameter information
* @param descriptionBuilder The description builder
*/
void updateDescription(Set<Annotation> annotations, ArgumentParser parser, ImmutableDescription.Builder descriptionBuilder);
示例11: preProcess
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
/**
* Called before arguments have been parsed.
*
* @param annotations The list of annotations on the command
* @param parser The argument parser with parameter information
* @param commandArgs The arguments provided by the user
* @return Whether command execution should continue
* @throws CommandException Thrown if there is a general command problem
* @throws ArgumentException Thrown is there is an error with the arguments
*/
boolean preProcess(List<? extends Annotation> annotations, ArgumentParser parser, CommandArgs commandArgs) throws CommandException, ArgumentException;
示例12: preInvoke
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
/**
* Called after arguments have been parsed but the command has yet
* to be executed.
*
* @param annotations The list of annotations on the command
* @param parser The argument parser with parameter information
* @param args The result of the parsed arguments: Java objects to be passed to the command
* @param commandArgs The arguments provided by the user
* @return Whether command execution should continue
* @throws CommandException Thrown if there is a general command problem
* @throws ArgumentException Thrown is there is an error with the arguments
*/
boolean preInvoke(List<? extends Annotation> annotations, ArgumentParser parser, Object[] args, CommandArgs commandArgs) throws CommandException, ArgumentException;
示例13: postInvoke
import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
/**
* Called after the command has been executed.
*
* @param annotations The list of annotations on the command
* @param parser The argument parser with parameter information
* @param args The result of the parsed arguments: Java objects to be passed to the command
* @param commandArgs The arguments provided by the user
* @throws CommandException Thrown if there is a general command problem
* @throws ArgumentException Thrown is there is an error with the arguments
*/
void postInvoke(List<? extends Annotation> annotations, ArgumentParser parser, Object[] args, CommandArgs commandArgs) throws CommandException, ArgumentException;