本文整理汇总了Java中java.util.Stack.clone方法的典型用法代码示例。如果您正苦于以下问题:Java Stack.clone方法的具体用法?Java Stack.clone怎么用?Java Stack.clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Stack
的用法示例。
在下文中一共展示了Stack.clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printStack
import java.util.Stack; //导入方法依赖的package包/类
public static void printStack(Stack s,String title,JTextArea t)
{
Stack s1 = (Stack)s.clone();
String output = newLineStr + title + ":";
while (!s1.empty())
{
Entry entry = (Entry)s1.pop();
String str = TabConverter.revert(entry.getPart());
output += (newLineStr + str);
int tag = entry.getTag();
if(tag != -1)
str = " < " + analyser.Analyser.Tags.getString(String.valueOf(tag)) + " > ";
else str = "";
output += (str);
}
output += newLineStr + "---------------";
t.append(output);
}
示例2: processPositionalParameter
import java.util.Stack; //导入方法依赖的package包/类
private void processPositionalParameter(Collection<ArgSpec> required, Set<ArgSpec> initialized, Stack<String> args) throws Exception {
if (tracer.isDebug()) {tracer.debug("Processing next arg as a positional parameter at index=%d. Remainder=%s%n", position, reverse((Stack<String>) args.clone()));}
int consumed = 0;
for (PositionalParamSpec positionalParam : commandSpec.positionalParameters()) {
Range indexRange = positionalParam.index();
if (!indexRange.contains(position)) {
continue;
}
@SuppressWarnings("unchecked")
Stack<String> argsCopy = (Stack<String>) args.clone();
Range arity = positionalParam.arity();
if (tracer.isDebug()) {tracer.debug("Position %d is in index range %s. Trying to assign args to %s, arity=%s%n", position, indexRange, positionalParam, arity);}
assertNoMissingParameters(positionalParam, arity.min, argsCopy);
int originalSize = argsCopy.size();
applyOption(positionalParam, arity, argsCopy, initialized, "args[" + indexRange + "] at position " + position);
int count = originalSize - argsCopy.size();
if (count > 0) { required.remove(positionalParam); }
consumed = Math.max(consumed, count);
}
// remove processed args from the stack
for (int i = 0; i < consumed; i++) { args.pop(); }
position += consumed;
if (tracer.isDebug()) {tracer.debug("Consumed %d arguments, moving position to index %d.%n", consumed, position);}
if (consumed == 0 && !args.isEmpty()) {
handleUnmatchedArguments(args.pop());
}
}
示例3: assertNoMissingParameters
import java.util.Stack; //导入方法依赖的package包/类
private void assertNoMissingParameters(Field field, int arity, Stack<String> args) {
if (arity > args.size()) {
int actualSize = 0;
@SuppressWarnings("unchecked")
Stack<String> copy = (Stack<String>) args.clone();
while (!copy.isEmpty()) {
actualSize += split(copy.pop(), field).length;
if (actualSize >= arity) { return; }
}
if (arity == 1) {
if (field.isAnnotationPresent(Option.class)) {
throw new MissingParameterException("Missing required parameter for " +
optionDescription("", field, 0));
}
Range indexRange = Range.parameterIndex(field);
Help.IParamLabelRenderer labelRenderer = Help.createMinimalParamLabelRenderer();
String sep = "";
String names = "";
int count = 0;
for (int i = indexRange.min; i < positionalParametersFields.size(); i++) {
if (Range.parameterArity(positionalParametersFields.get(i)).min > 0) {
names += sep + labelRenderer.renderParameterLabel(positionalParametersFields.get(i),
Help.Ansi.OFF, Collections.<IStyle>emptyList());
sep = ", ";
count++;
}
}
String msg = "Missing required parameter";
Range paramArity = Range.parameterArity(field);
if (paramArity.isVariable) {
msg += "s at positions " + indexRange + ": ";
} else {
msg += (count > 1 ? "s: " : ": ");
}
throw new MissingParameterException(msg + names);
}
throw new MissingParameterException(optionDescription("", field, 0) +
" requires at least " + arity + " values, but only " + args.size() + " were specified.");
}
}