1 package com.puppycrawl.tools.checkstyle.checks.javadoc; 20 21 import java.io.File ; 22 import java.util.Iterator ; 23 import java.util.Set ; 24 import java.util.HashSet ; 25 26 import com.puppycrawl.tools.checkstyle.api.MessageDispatcher; 27 import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck; 28 29 34 public class PackageHtmlCheck extends AbstractFileSetCheck 35 { 36 39 public PackageHtmlCheck() 40 { 41 setFileExtensions(new String []{"java"}); 44 } 45 46 51 public void process(File [] aFiles) 52 { 53 final File [] javaFiles = filter(aFiles); 54 final Set directories = getParentDirs(javaFiles); 55 for (final Iterator it = directories.iterator(); it.hasNext();) { 56 final File dir = (File ) it.next(); 57 final File packageHtml = new File (dir, "package.html"); 58 final MessageDispatcher dispatcher = getMessageDispatcher(); 59 final String path = packageHtml.getPath(); 60 dispatcher.fireFileStarted(path); 61 if (!packageHtml.exists()) { 62 log(0, "javadoc.packageHtml"); 63 fireErrors(path); 64 } 65 dispatcher.fireFileFinished(path); 66 } 67 } 68 69 74 protected final Set getParentDirs(File [] aFiles) 75 { 76 final Set directories = new HashSet (); 77 for (int i = 0; i < aFiles.length; i++) { 78 final File f = aFiles[i].getAbsoluteFile(); 79 if (f.getName().endsWith(".java")) { 80 final File dir = f.getParentFile(); 81 directories.add(dir); } 83 } 84 return directories; 85 } 86 } 87 | Popular Tags |