List of usage examples for javax.lang.model.element Name toString
public String toString();
From source file:com.thoratou.exact.processors.ExactProcessor.java
private void readAnnotations(RoundEnvironment roundEnv, HashMap<String, ArrayList<Item>> itemMap, HashMap<String, ArrayList<ExtensionItem>> extItemMap) throws Exception { //retrieve all classes with @ExactNode annotation for (TypeElement typeElement : ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(ExactNode.class))) { Name qualifiedName = typeElement.getQualifiedName(); String className = qualifiedName.toString(); logger.info("Exact class : " + className); classMap.put(className, typeElement); for (ExecutableElement methodElement : ElementFilter.methodsIn(typeElement.getEnclosedElements())) { {//from w w w . j a va 2s . co m ExactPath annotation = methodElement.getAnnotation(ExactPath.class); if (annotation != null) { String methodName = methodElement.getSimpleName().toString(); String returnType = methodElement.getReturnType().toString(); String xPathString = annotation.value(); logger.info( "Exact method : " + methodName + " , " + annotation.value() + " , " + returnType); XPathParser parser = new XPathParser(xPathString); XPathPathExpr xPathPathExpr = parser.parse(); logger.info("XPath value = " + xPathPathExpr.toString()); Item item = new Item(); item.setxPathPathExpr(xPathPathExpr); item.setMethodName(methodName); item.setReturnType(returnType); if (itemMap.containsKey(className)) { ArrayList<Item> items = itemMap.get(className); items.add(item); } else { ArrayList<Item> items = new ArrayList<Item>(); items.add(item); itemMap.put(className, items); } methodMap.put(new Pair<String, String>(className, methodName), methodElement); } } { ExactExtension annotation = methodElement.getAnnotation(ExactExtension.class); if (annotation != null) { String methodName = methodElement.getSimpleName().toString(); String returnType = methodElement.getReturnType().toString(); String name = annotation.name(); String element = annotation.element(); String filter = annotation.filter(); logger.info("Exact extension : " + methodName + " , " + returnType + " , " + name + " , " + element + " , " + filter); XPathParser elementParser = new XPathParser(element); XPathPathExpr elementXPathPathExpr = elementParser.parse(); logger.info("XPath element = " + elementXPathPathExpr.toString()); XPathParser filterParser = new XPathParser(filter); XPathPathExpr filterXPathPathExpr = filterParser.parse(); logger.info("XPath filter = " + filterXPathPathExpr.toString()); ExtensionItem item = new ExtensionItem(); item.setName(name); item.setElement(elementXPathPathExpr); item.setFilter(filterXPathPathExpr); item.setMethodName(methodName); item.setReturnType(returnType); if (extItemMap.containsKey(className)) { ArrayList<ExtensionItem> items = extItemMap.get(className); items.add(item); } else { ArrayList<ExtensionItem> items = new ArrayList<ExtensionItem>(); items.add(item); extItemMap.put(className, items); } } } } } }
From source file:com.codiscope.analyzer.JSONSerializer.java
/** * Write out a {@code Name} as a JSON object with a given key. * * @param name The key name./*from w w w .j ava2s . co m*/ * @param n The Name to output. */ public void output(final String name, final Name n) { try { writer.key(name); writer.value(n.toString()); } catch (final JSONException e) { throw new RuntimeException(e); } }