本文整理了Java中org.parboiled.support.ValueStack.size()
方法的一些代码示例,展示了ValueStack.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ValueStack.size()
方法的具体详情如下:
包路径:org.parboiled.support.ValueStack
类名称:ValueStack
方法名:size
[英]Returns the number of elements currently on the stack.
[中]返回堆栈上当前的元素数。
代码示例来源:origin: com.github.edgarespina/handlebars
@Override
public boolean run(final Context<BaseTemplate> context) {
ValueStack<BaseTemplate> stack = context.getValueStack();
if (stack.size() > 1) {
BaseTemplate body = pop();
((Block) section.get()).inverse(body);
}
return addToline(section.get());
}
}
代码示例来源:origin: com.github.edgarespina/handlebars
@Override
public boolean run(final Context<BaseTemplate> context) {
ValueStack<BaseTemplate> stack = context.getValueStack();
if (stack.size() > 1) {
BaseTemplate body = pop();
((Block) section.get()).body(body);
}
return addToline(section.get());
}
}).label("block");
代码示例来源:origin: AlexFalappa/nb-springboot
@Override
public boolean run(Context<CfgElement> context) {
final ValueStack<CfgElement> stack = context.getValueStack();
if (!context.hasError()) {
int size = stack.size();
switch (size) {
case 1:
CfgElement elemKey = stack.pop();
parsedProps.setProperty(unescape(elemKey.getText()), "");
cfgFile.getElements().add(new PairElement(elemKey));
break;
case 2:
// NOTE: stack popping order below is important!
final CfgElement elemValue = stack.pop();
elemKey = stack.pop();
parsedProps.setProperty(unescape(elemKey.getText()), unescape(elemValue.getText()));
cfgFile.getElements().add(new PairElement(elemKey, elemValue));
break;
default:
throw new IllegalStateException(String.format("Cannot manage %d values on the parsing stack", size));
}
} else {
stack.clear();
}
return true;
}
代码示例来源:origin: smartcat-labs/ranger
/**
* Creates CSV value.
*
* @return An CSV value.
*/
protected CsvReaderValue createCsvReaderValue() {
CSVParserSettings parserSettings = null;
switch (getContext().getValueStack().size()) {
case 1:
parserSettings = new CSVParserSettings((String) pop());
break;
case 2:
parserSettings = new CSVParserSettings((String) pop(1), (char) pop());
break;
case 8:
parserSettings = new CSVParserSettings((String) pop(7), (char) pop(6), (String) pop(5), (boolean) pop(4),
peek(3) instanceof NullValue ? null : (Character) pop(3), (char) pop(2), (boolean) pop(1),
peek() instanceof NullValue ? null : (String) pop());
break;
default:
throw new RuntimeException("Unsupported number of parameters, should not happen ever.");
}
return new CsvReaderValue(parserSettings);
}
代码示例来源:origin: io.smartcat/ranger
/**
* Creates CSV value.
*
* @return An CSV value.
*/
protected CsvReaderValue createCsvReaderValue() {
CSVParserSettings parserSettings = null;
switch (getContext().getValueStack().size()) {
case 1:
parserSettings = new CSVParserSettings((String) pop());
break;
case 2:
parserSettings = new CSVParserSettings((String) pop(1), (char) pop());
break;
case 8:
parserSettings = new CSVParserSettings((String) pop(7), (char) pop(6), (String) pop(5), (boolean) pop(4),
peek(3) instanceof NullValue ? null : (Character) pop(3), (char) pop(2), (boolean) pop(1),
peek() instanceof NullValue ? null : (String) pop());
break;
default:
throw new RuntimeException("Unsupported number of parameters, should not happen ever.");
}
return new CsvReaderValue(parserSettings);
}
内容来源于网络,如有侵权,请联系作者删除!