Skip to content

Instantly share code, notes, and snippets.

@nasminspy
Created June 8, 2016 09:56
Show Gist options
  • Save nasminspy/b9bfa7e00ef737cd1bd6b2562f40ad36 to your computer and use it in GitHub Desktop.
Save nasminspy/b9bfa7e00ef737cd1bd6b2562f40ad36 to your computer and use it in GitHub Desktop.
package com.sdl.qdox.demo;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import com.thoughtworks.qdox.JavaDocBuilder;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaMethod;
import com.thoughtworks.qdox.model.JavaPackage;
import com.thoughtworks.qdox.model.JavaSource;
public class QDoxDemo {
public static void main(String[] args) {
JavaDocBuilder builder = new JavaDocBuilder();
try {
builder.addSource(new File("//DemoJava.java"));
JavaSource src = builder.getSources()[0];
JavaPackage pkg = src.getPackage();
String name = pkg.getName();
String toString = pkg.toString();
JavaPackage parent = pkg.getParentPackage();
JavaClass[] classes = pkg.getClasses();
JavaMethod[] methods = classes[0].getMethods();
for(JavaMethod method :methods){
System.out.println("Method Name : "+method.getName());
}
System.out.println("pkg name : "+name);
System.out.println("pkg to String : "+toString);
System.out.println("pkg parent name : "+parent);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment