java.nio.file.FileVisitor<java.nio.file.Path>@NotThreadSafe
public class JavaFileMetricsCollector
extends java.nio.file.SimpleFileVisitor<java.nio.file.Path>
FileVisitor that collects source code metrics for each visited Java file. The metrics
are collected by calling JavaMetricsCollector.collect(String, InputStream, Charset).
Instances of this class are not safe for use by multiple threads without external synchronization.
| Constructor | Description |
|---|---|
JavaFileMetricsCollector(JavaMetricsCollector pDelegate) |
Create a new
JavaFileMetricsCollector that operates on files encoded with UTF-8. |
JavaFileMetricsCollector(JavaMetricsCollector pDelegate,
java.nio.charset.Charset pFileEncoding) |
Create a new
JavaFileMetricsCollector. |
| Modifier and Type | Method | Description |
|---|---|---|
protected JavaMetricsCollector |
getDelegate() |
Get the
JavaMetricsCollector passed to the constructor. |
int |
getNumFiles() |
Get the number of files that metrics have been collected for.
|
java.nio.file.FileVisitResult |
visitFile(java.nio.file.Path pFile,
java.nio.file.attribute.BasicFileAttributes pAttributes) |
public JavaFileMetricsCollector(@Nonnull
JavaMetricsCollector pDelegate)
JavaFileMetricsCollector that operates on files encoded with UTF-8.pDelegate - The instance to collect metrics with.java.lang.NullPointerException - if pDelegate is null.public JavaFileMetricsCollector(@Nonnull
JavaMetricsCollector pDelegate,
@Nonnull
java.nio.charset.Charset pFileEncoding)
JavaFileMetricsCollector.pDelegate - The instance to collect metrics with.pFileEncoding - The charset the files are encoded with.java.lang.NullPointerException - if any of the parameters is null.public java.nio.file.FileVisitResult visitFile(@Nonnull
java.nio.file.Path pFile,
@Nullable
java.nio.file.attribute.BasicFileAttributes pAttributes)
throws java.io.IOException
visitFile in interface java.nio.file.FileVisitor<java.nio.file.Path>visitFile in class java.nio.file.SimpleFileVisitor<java.nio.file.Path>java.io.IOExceptionpublic int getNumFiles()
@Nonnull protected JavaMetricsCollector getDelegate()
JavaMetricsCollector passed to the constructor. The Java file parsing and
metrics collection is delegated to that instance.JavaMetricsCollector, never null.