protected void initialize(String input)
{
StringTemplateCSSLexer lexer = new StringTemplateCSSLexer(new ANTLRInputStream(input));
CommonTokenStream tokens = new CommonTokenStream(lexer);
StringTemplateCSSParser parser = new StringTemplateCSSParser(tokens);
parser.setErrorHandler(new BailErrorStrategy());
ParseTree tree = parser.css();
Collection<ParseTree> selectorCombinations = XPath.findAll(tree, "//selectorCombination", parser);
final StringUtils stringUtils = StringUtils.getInstance();
this.selectors = new ArrayList<List<String>>(selectorCombinations.size());
this.properties = new HashMap<List<String>, Map<String, String>>();
for (ParseTree selectorCombination : selectorCombinations) {
List<String> currentSelectors = new ArrayList<String>(selectorCombination.getChildCount());
this.selectors.add(currentSelectors);
for (int index = 0; index < selectorCombination.getChildCount(); index++) {
String text = selectorCombination.getChild(index).getText();
currentSelectors.add(text);
}
Map<String, String> block = retrieveProperties(selectorCombination, stringUtils);
this.properties.put(currentSelectors, block);
}
}
StringTemplateCSSHelper.java 文件源码
java
阅读 17
收藏 0
点赞 0
评论 0
项目:JavaCSS
作者:
评论列表
文章目录