java syntax parser
[javainspect.git] / src / main / java / eu / svjatoslav / inspector / java / methods / Project.java
1 package eu.svjatoslav.inspector.java.methods;
2
3 import java.io.File;
4 import java.io.IOException;
5
6 import eu.svjatoslav.commons.file.FilePathParser;
7
8 public class Project {
9
10         private final File projectPath;
11
12         public Project(final File projectPath) {
13                 this.projectPath = projectPath;
14                 parse();
15         }
16
17         public void parse() {
18
19                 if (!projectPath.exists())
20                         System.out.println("Project not found on path: " + projectPath);
21
22                 if (!projectPath.canRead())
23                         System.out.println("Cannot read project path: " + projectPath);
24
25                 if (projectPath.isDirectory())
26                         parseDirectory(projectPath);
27
28                 if (projectPath.isFile())
29                         parseFile(projectPath);
30         }
31
32         public void parseDirectory(final File file) {
33
34                 for (final File subFile : file.listFiles()) {
35
36                         if (subFile.isFile())
37                                 parseFile(subFile);
38
39                         if (subFile.isDirectory())
40                                 parseDirectory(subFile);
41                 }
42         }
43
44         public void parseFile(final File file) {
45                 final String fileExtension = FilePathParser.getFileExtension(file);
46                 if ("java".equalsIgnoreCase(fileExtension))
47                         try {
48                                 final JavaFile javaFile = new JavaFile(file);
49                         } catch (final IOException e) {
50                                 System.out.println("Error parsing file: " + file.toString()
51                                                 + ", " + e.toString());
52                         }
53         }
54
55 }