@NotThreadSafe
public class JavaMetricsCollector
extends java.lang.Object
collect(String, InputStream, Charset). The collected
metrics can then be retrieved by calling getCollectedMetrics().
Instances of this class are not safe for use by multiple threads without external synchronization.
| Modifier and Type | Class | Description |
|---|---|---|
static class |
JavaMetricsCollector.LanguageLevel |
The supported Java language levels.
|
| Constructor | Description |
|---|---|
JavaMetricsCollector() |
Create a new
JavaMetricsCollector for the default language level as specified by
JavaMetricsCollector.LanguageLevel.getDefault(). |
JavaMetricsCollector(JavaMetricsCollector.LanguageLevel pLanguageLevel) |
Create a new
JavaMetricsCollector for a specific language level. |
| Modifier and Type | Method | Description |
|---|---|---|
void |
collect(java.lang.String pName,
java.io.InputStream pJavaSource,
java.nio.charset.Charset pEncoding) |
Parse an
InputStream containing Java source code and collect metrics from it. |
void |
collect(java.lang.String pName,
java.lang.String pJavaSource) |
Parse a string containing Java source code and collect metrics from it.
|
JavaMetrics |
getCollectedMetrics() |
Get the metrics collected in all calls to
collect. |
public JavaMetricsCollector()
JavaMetricsCollector for the default language level as specified by
JavaMetricsCollector.LanguageLevel.getDefault().public JavaMetricsCollector(@Nonnull
JavaMetricsCollector.LanguageLevel pLanguageLevel)
JavaMetricsCollector for a specific language level.pLanguageLevel - The language level.java.lang.NullPointerException - if pLanguageLevel is null.public void collect(@Nonnull
java.lang.String pName,
@Nonnull
java.io.InputStream pJavaSource,
@Nonnull
java.nio.charset.Charset pEncoding)
throws java.text.ParseException
InputStream containing Java source code and collect metrics from it. The
resulting metrics will be stored in this instance and returned when
getCollectedMetrics() is called.pName - The name of the stream's origin, will be used as the name of the
CompilationUnitMetrics where the collected metrics are put.pJavaSource - The input stream containing the source code to parse and collect metrics
for.pEncoding - The encoding of the stream's bytes.java.text.ParseException - if the stream's source code is lexically or syntactically invalid.java.lang.NullPointerException - if any of the parameters is null.public void collect(@Nonnull
java.lang.String pName,
@Nonnull
java.lang.String pJavaSource)
throws java.text.ParseException
getCollectedMetrics() is called.pName - The name of the string's origin, will be used as the name of the
CompilationUnitMetrics where the collected metrics are put.pJavaSource - The string containing the source code to parse and collect metrics for.java.text.ParseException - if the string's source code is lexically or syntactically invalid.java.lang.NullPointerException - if any of the parameters is null.@Nonnull public JavaMetrics getCollectedMetrics()
collect.JavaMetrics containing the collected metrics, never null.