Clover coverage report - Maven Author Plugin - 1.0
Coverage timestamp: lun. déc. 25 2006 21:58:42 CET
file stats: LOC: 82   Methods: 1
NCLOC: 40   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JavadocAuthorResolver.java 83,3% 94,7% 100% 90,6%
coverage coverage
 1    /*
 2    * Copyright 2006 Eric Ballet Baz
 3    *
 4    * Licensed under the Apache License, Version 2.0 (the "License");
 5    * you may not use this file except in compliance with the License.
 6    * You may obtain a copy of the License at
 7    *
 8    * http://www.apache.org/licenses/LICENSE-2.0
 9    *
 10    * Unless required by applicable law or agreed to in writing, software
 11    * distributed under the License is distributed on an "AS IS" BASIS,
 12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13    * See the License for the specific language governing permissions and
 14    * limitations under the License.
 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    * AuthorResolver based on javadoc.
 31    * This resolver uses author's javadoc tags to resolve the author(s).
 32    *
 33    * @author Eric Ballet Baz
 34    */
 35    public class JavadocAuthorResolver implements AuthorResolver {
 36   
 37    /** Javadoc tag used to declare the author(s) of a file. */
 38    private static final String AUTHOR_TAG_NAME = "author";
 39   
 40    /**
 41    * @see org.apache.maven.author.resolver.AuthorResolver#resolveAuthors(java.io.File)
 42    */
 43  11 public final String[] resolveAuthors(final File file) {
 44    // Check argument
 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    // Prepare resources used to inspect the javadoc of this file
 53  9 XJavaDoc xJavaDoc = new XJavaDoc();
 54  9 SourceSet fileSourceSet = new FileSourceSet(file);
 55  9 xJavaDoc.addSourceSet(fileSourceSet);
 56   
 57    // Find values of author's javadoc tags for this file
 58  9 XClass xClass = xJavaDoc.getXClass(fileSourceSet.getQualifiedName(0));
 59   
 60    // This should never happen
 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    // Inspect javadoc to resolver authors
 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    // No author has been found
 80  3 return new String[0];
 81    }
 82    }