use of org.apache.commons.jxpath.JXPathContext in project freud by LMAX-Exchange.
the class AnnotationJdom method getAnnotationValueForElement.
private String getAnnotationValueForElement(final Element element) {
final JXPathContext context = JXPathContext.newContext(element);
final Element expr = (Element) context.selectSingleNode("/" + JavaSourceTokenType.EXPR.name() + "/*");
if (expr != null) {
return expr.getText();
} else {
final List<Element> exprList = context.selectNodes("//" + JavaSourceTokenType.EXPR.name() + "/*");
StringBuilder sb = new StringBuilder("{");
for (Element item : exprList) {
sb.append(item.getText()).append(",");
}
sb.setCharAt(sb.length() - 1, '}');
return sb.toString();
}
}
use of org.apache.commons.jxpath.JXPathContext in project freud by LMAX-Exchange.
the class CssJdomParser method parseCssRules.
@SuppressWarnings("unchecked")
static Iterable<CssRule> parseCssRules(final Reader reader) throws RecognitionException, IOException {
List<CssRule> cssRuleList = new ArrayList<CssRule>();
Document root = parseCssToDocument(reader);
JXPathContext context = JXPathContext.newContext(root.getRootElement());
List<Element> cssRuleElementList = (List<Element>) context.selectNodes("/RULE");
for (Element element : cssRuleElementList) {
final CssRuleJdom cssRuleJdom = new CssRuleJdom(element, 0);
cssRuleList.add(cssRuleJdom);
for (int i = 1; i < cssRuleJdom.getNumberOfCommaSeparatedSelectorLists(); i++) {
cssRuleList.add(new CssRuleJdom(element, i));
}
}
return cssRuleList;
}
use of org.apache.commons.jxpath.JXPathContext in project freud by LMAX-Exchange.
the class ClassDeclarationJdom method getMethodDeclarationListByNameMap.
// TODO Block getStaticBlock();
public Map<String, List<MethodDeclaration>> getMethodDeclarationListByNameMap() {
if (methodDeclarationListByNameMap == null) {
JXPathContext context = JXPathContext.newContext(classDeclElement);
methodDeclarationListByNameMap = new LinkedHashMap<String, List<MethodDeclaration>>();
getMethodDeclarationListByNameMap(context);
}
return methodDeclarationListByNameMap;
}
use of org.apache.commons.jxpath.JXPathContext in project freud by LMAX-Exchange.
the class ClassDeclarationJdom method getInnerClassDeclarationByNameMap.
@SuppressWarnings("unchecked")
public Map<String, ClassDeclaration> getInnerClassDeclarationByNameMap() {
if (innerClassDeclarationByNameMap == null) {
JXPathContext context = JXPathContext.newContext(classDeclElement);
innerClassDeclarationByNameMap = new LinkedHashMap<String, ClassDeclaration>();
for (JavaSourceTokenType tokenType : POSSIBLE_CLASS_DECLARATION_TYPES) {
final String tokenName = tokenType.getName();
List<Element> innerClassElementList = context.selectNodes("/" + CLASS_TOP_LEVEL_SCOPE.getName() + "/" + tokenName);
for (Element innerClassElement : innerClassElementList) {
ClassDeclaration innerClass = new ClassDeclarationJdom(innerClassElement, DeclarationType.valueOf(tokenName), this);
innerClassDeclarationByNameMap.put(innerClass.getName(), innerClass);
}
}
}
return innerClassDeclarationByNameMap;
}
use of org.apache.commons.jxpath.JXPathContext in project freud by LMAX-Exchange.
the class JavaSourceJdom method parseImportDeclaration.
private List<ImportDeclaration> parseImportDeclaration() {
try {
final JXPathContext context = JXPathContext.newContext(root);
final List importNodes = context.selectNodes("/" + JAVA_SOURCE_ROOT_ELEMENT_NAME + "/" + JavaSourceTokenType.IMPORT.name());
importDeclarations = new ArrayList<ImportDeclaration>(importNodes.size());
for (Object importNode : importNodes) {
importDeclarations.add(new ImportDeclarationJdom((Element) importNode));
}
} catch (JXPathException e) {
importDeclarations = emptyList();
}
return importDeclarations;
}
Aggregations