1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| package org.apache.maven.author.resolver; |
18 |
| |
19 |
| import java.io.File; |
20 |
| import java.util.List; |
21 |
| |
22 |
| import xjavadoc.SourceSet; |
23 |
| import xjavadoc.XClass; |
24 |
| import xjavadoc.XDoc; |
25 |
| import xjavadoc.XJavaDoc; |
26 |
| import xjavadoc.XTag; |
27 |
| import xjavadoc.filesystem.FileSourceSet; |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| public class JavadocAuthorResolver implements AuthorResolver { |
36 |
| |
37 |
| |
38 |
| private static final String AUTHOR_TAG_NAME = "author"; |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
11
| public final String[] resolveAuthors(final File file) {
|
44 |
| |
45 |
11
| if (file == null) {
|
46 |
1
| throw new IllegalArgumentException("Argument [file] should not be null");
|
47 |
| } |
48 |
10
| if (file.isDirectory()) {
|
49 |
1
| throw new IllegalArgumentException("Argument [file] should not be a directory");
|
50 |
| } |
51 |
| |
52 |
| |
53 |
9
| XJavaDoc xJavaDoc = new XJavaDoc();
|
54 |
9
| SourceSet fileSourceSet = new FileSourceSet(file);
|
55 |
9
| xJavaDoc.addSourceSet(fileSourceSet);
|
56 |
| |
57 |
| |
58 |
9
| XClass xClass = xJavaDoc.getXClass(fileSourceSet.getQualifiedName(0));
|
59 |
| |
60 |
| |
61 |
9
| if (xClass == null) {
|
62 |
0
| throw new IllegalStateException(
|
63 |
| "xjavadoc.XClass.getXClass(String qualifiedName) has returned a null value. Check version of xjavadoc used"); |
64 |
| } |
65 |
| |
66 |
| |
67 |
9
| XDoc xDoc = xClass.getDoc();
|
68 |
9
| if (xDoc != null) {
|
69 |
9
| List authorTags = xDoc.getTags(AUTHOR_TAG_NAME);
|
70 |
9
| if (authorTags != null && authorTags.size() > 0) {
|
71 |
6
| String[] authors = new String[authorTags.size()];
|
72 |
6
| for (int i = 0; i < authorTags.size(); i++) {
|
73 |
12
| authors[i] = ((XTag) authorTags.get(i)).getValue();
|
74 |
| } |
75 |
6
| return authors;
|
76 |
| } |
77 |
| } |
78 |
| |
79 |
| |
80 |
3
| return new String[0];
|
81 |
| } |
82 |
| } |