Class SnippetReader
- java.lang.Object
-
- biz.aQute.bnd.reporter.codesnippet.SnippetReader
-
- Direct Known Subclasses:
JavaSnippetReader
abstract class SnippetReader extends java.lang.Object
Base class for a snippet reader.Snippet readers do the job of extracting snippet from files. They are specific to a programming language.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.String>
_extensions
private java.util.function.Function<java.lang.String,java.lang.String>
_idGenerator
-
Constructor Summary
Constructors Constructor Description SnippetReader(java.lang.String... extensions)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
generateId(java.lang.String baseId)
Generate a unique Id given the base Id in argument.java.util.List<java.lang.String>
getSupportedExtension()
protected void
init(java.util.function.Function<java.lang.String,java.lang.String> idGenerator)
abstract java.util.List<Snippet>
read(java.io.File file)
Read a file and extract snippets from it.
-
-
-
Method Detail
-
init
protected final void init(java.util.function.Function<java.lang.String,java.lang.String> idGenerator)
-
getSupportedExtension
public final java.util.List<java.lang.String> getSupportedExtension()
-
generateId
protected final java.lang.String generateId(java.lang.String baseId)
Generate a unique Id given the base Id in argument.Should be used to generated Ids of snippets.
- Parameters:
baseId
- the base Id- Returns:
- the new Id to be used.
-
read
public abstract java.util.List<Snippet> read(java.io.File file) throws java.lang.Exception
Read a file and extract snippets from it.- Parameters:
file
- the file to analyze- Returns:
- an ordered list of snippets
- Throws:
java.lang.Exception
- if any error occures
-
-