use of org.jdom.Element in project freud by LMAX-Exchange.
the class JavaSourceJdom method parseAnnotations.
//////////////////////////////////////////////////////////////////////////////////////////////////
public static List<Annotation> parseAnnotations(final Element element) {
final List<Annotation> annotations;
JXPathContext context = JXPathContext.newContext(element);
List annotationList = context.selectNodes("/" + JavaSourceTokenType.MODIFIER_LIST.getName() + "/" + JavaSourceTokenType.AT.getName());
annotations = new ArrayList<Annotation>(annotationList.size());
for (Object annotationElement : annotationList) {
annotations.add(new AnnotationJdom((Element) annotationElement));
}
return annotations;
}
use of org.jdom.Element in project freud by LMAX-Exchange.
the class JavaSourceJdom method parseClassDeclaration.
///////////////////////////////////////////////////////////////////////////////////////////////////////
private ClassDeclaration parseClassDeclaration() {
JXPathContext context = JXPathContext.newContext(root);
for (JavaSourceTokenType tokenType : POSSIBLE_CLASS_DECLARATION_TYPES) {
try {
final String tokenName = tokenType.name();
final Element element = (Element) context.selectSingleNode("/" + JAVA_SOURCE_ROOT_ELEMENT_NAME + "/" + tokenName);
if (element != null) {
classDeclaration = new ClassDeclarationJdom(element, getDeclarationType(tokenType), null);
}
} catch (JXPathException e) {
// ignore and try another path
}
}
if (classDeclaration == null) {
throw new IllegalStateException("Internal: could not find class declaration in: " + this);
}
return classDeclaration;
}
use of org.jdom.Element in project freud by LMAX-Exchange.
the class MethodDeclarationJdom method getParametersDeclarations.
@Override
@SuppressWarnings("unchecked")
public List<ParamDeclaration> getParametersDeclarations() {
if (paramDeclarations == null) {
final List<Element> paramListChildren = methodDeclElement.getChild(JavaSourceTokenType.FORMAL_PARAM_LIST.getName()).getChildren();
paramDeclarations = new ArrayList<ParamDeclaration>(paramListChildren.size());
for (Element paramDecl : paramListChildren) {
paramDeclarations.add(new ParamDeclarationJdom(paramDecl));
}
}
return paramDeclarations;
}
use of org.jdom.Element in project freud by LMAX-Exchange.
the class CssRuleJdom method parseSelectors.
@SuppressWarnings("unchecked")
private void parseSelectors() {
cssSelectorList = new ArrayList<CssSelector>();
final List<Element> children = ruleElement.getChildren();
int index = 0;
CssSelector.Combinator combinator = null;
for (Element child : children) {
if (CssTokenType.COMMA.name().equals(child.getName())) {
index++;
} else if (getCommaSeparatedSelectorListIndex() == index) {
if (CssSelector.Type.isType(child.getName())) {
final String selectorString = child.getAttributeValue(JdomTreeAdaptor.ID_ATTR);
CssSelector.Type selectorType = CssSelector.Type.valueOf(child.getName());
if (selectorString != null) {
Iterable<String> selectors = breakIdentToSelectors(selectorString);
for (String selector : selectors) {
cssSelectorList.add(new CssSelectorJdom(this, selector, selectorType, combinator));
combinator = CssSelector.Combinator.DESCENDANT;
selectorType = CssSelector.Type.CLASS;
}
} else {
cssSelectorList.add(new CssSelectorJdom(this, null, selectorType, combinator));
combinator = CssSelector.Combinator.DESCENDANT;
}
} else if (CssSelector.Combinator.isCombinator(child.getName())) {
combinator = CssSelector.Combinator.valueOf(child.getName());
}
}
}
}
use of org.jdom.Element in project freud by LMAX-Exchange.
the class CssRuleJdom method parseDeclarations.
@SuppressWarnings("unchecked")
private void parseDeclarations() {
cssDeclarationList = new ArrayList<CssDeclaration>();
JXPathContext context = JXPathContext.newContext(ruleElement);
List<Element> cssSelectorElementList = (List<Element>) context.selectNodes("/" + CssTokenType.PROPERTY.name());
for (Element element : cssSelectorElementList) {
cssDeclarationList.add(new CssDeclarationJdom(this, element));
}
}
Aggregations