use of org.beetl.core.parser.BeetlParser.DirectiveExpIDListContext in project beetl2.0 by javamonkey.
the class AntlrProgramBuilder method parseDirectiveStatement.
/**
* directive dynamic xxx,yy
* @param node
* @return
*/
protected DirectiveStatement parseDirectiveStatement(DirectiveStContext node) {
DirectiveStContext stContext = (DirectiveStContext) node;
DirectiveExpContext direExp = stContext.directiveExp();
Token token = direExp.Identifier().getSymbol();
String directive = token.getText().toLowerCase().intern();
TerminalNode value = direExp.StringLiteral();
List<TerminalNode> idNodeList = null;
DirectiveExpIDListContext directExpidLisCtx = direExp.directiveExpIDList();
if (directExpidLisCtx != null) {
idNodeList = directExpidLisCtx.Identifier();
}
Set<String> idList = null;
DirectiveStatement ds = null;
if (value != null) {
String idListValue = this.getStringValue(value.getText());
idList = new HashSet(Arrays.asList(idListValue.split(",")));
ds = new DirectiveStatement(directive, idList, this.getBTToken(token));
} else if (idNodeList != null) {
idList = new HashSet<String>();
for (TerminalNode t : idNodeList) {
idList.add(t.getText());
}
ds = new DirectiveStatement(directive, idList, this.getBTToken(token));
} else {
ds = new DirectiveStatement(directive, Collections.EMPTY_SET, this.getBTToken(token));
}
if (directive.equals("dynamic")) {
if (ds.getIdList().size() == 0) {
data.allDynamic = true;
} else {
data.dynamicObjectSet = ds.getIdList();
}
ds = new DirectiveStatement(directive, Collections.EMPTY_SET, this.getBTToken(token));
return ds;
} else if (directive.equalsIgnoreCase("safe_output_open".intern())) {
this.pbCtx.isSafeOutput = true;
return ds;
} else if (directive.equalsIgnoreCase("safe_output_close".intern())) {
this.pbCtx.isSafeOutput = false;
return ds;
} else {
return ds;
}
}
Aggregations