I need to get all names of the classes and some other infos in a java project. Read all the text in .java files, and use Regex expression to get :
- class: name, modifier, attributes, method
- attributes of class: name, modifier, type
- method: name, modifier, return type
Here a project example:
public abstract class Shape {
int numberOfSides;
protected abstract double calculateArea();
public final int getNumberOfSides() {
return numberOfSides;
}
}
public class Circle extends Shape{
int radius;
public Circle(int radius) {
this.radius = radius;
}
@Override
protected double calculateArea() {
// TODO Auto-generated method stub
return Math.PI*radius*radius;
}
}
public class Square extends Shape{
int sideLength;
Square() {
numberOfSides = 4;
}
public void setSideLengt(int sideL) {
sideLength = sideL;
}
@Override
protected double calculateArea() {
// TODO Auto-generated method stub
return this.sideLength*this.sideLength;
}
}
I used this regex: "class\\s*(?<className>[a-zA-Z][a-zA-Z\\d_\\$]*)"
to get the class name.
But getting other info is so difficult. Can you help me??