|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tinyjee.maven.dim.spi.SnippetExtractor
public final class SnippetExtractor
Implements a singleton that uses snippet selectors and sources to extract portions of content and format it as a map of selected lines, indexed by their starting line numbers.
| Field Summary | |
|---|---|
static String |
LB
Defines the system dependent line break to use. |
| Method Summary | |
|---|---|
SortedMap<Integer,List<String>> |
convert(Reader contentReader)
Low level method that converts the complete source to the snippet map format. |
SortedMap<Integer,List<String>> |
extractSnippets(Reader reader,
Set<Integer> includedLines,
Set<Integer> excludedLines)
Low level method that extracts the snippets of the given source content. |
List<SortedSet<Integer>> |
findSelectedLines(Source source)
Finds the selected lines given the specified source. |
static SnippetExtractor |
getInstance()
Returns a singleton instance of this class. |
boolean |
isSnippetSelectionRequired(Source source)
Returns true if the given source require snippet selection. |
SortedMap<Integer,List<String>> |
selectSnippets(Source source)
Selects the snippets of the given source. |
String[] |
splitExpression(String expression)
Splits a given snippet expression into the individual sub-expression parts. |
String |
toString(List<String> lines)
Flattens the given lines to pure text using system specific line breaks. |
StringBuilder |
toString(List<String> lines,
StringBuilder out)
Flattens the given lines to pure text using system specific line breaks. |
String |
toString(Map<Integer,List<String>> content,
boolean addEmptyLineBreaks)
Flattens the given content to pure text using system specific line breaks. |
void |
unIndent(SortedMap<Integer,List<String>> snippetMap,
boolean blockScope)
Removes unnecessary indents. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String LB
| Method Detail |
|---|
public static SnippetExtractor getInstance()
public String[] splitExpression(String expression)
expression - the expression to split.
public boolean isSnippetSelectionRequired(Source source)
source - the source to test.
public SortedMap<Integer,List<String>> selectSnippets(Source source)
throws IOException
source - the source to select the snippets in.
IOException - in case of reading the source failed.
public SortedMap<Integer,List<String>> extractSnippets(Reader reader,
Set<Integer> includedLines,
Set<Integer> excludedLines)
throws IOException
reader - the reader containing the source.includedLines - the line numbers to include, if empty all is included (as long as exclusions exist).excludedLines - the line numbers to exclude.
IOException - in case of reading the source failed.
public SortedMap<Integer,List<String>> convert(Reader contentReader)
throws IOException
extractSnippets(contentReader, emptySet(), singleton(-1)).
contentReader - the reader containing the source.
IOException - in case of reading the source failed.
public String toString(Map<Integer,List<String>> content,
boolean addEmptyLineBreaks)
content - the content to write.addEmptyLineBreaks - If true, will add any additional line breaks to re-construct the number of lines of the original document.
public String toString(List<String> lines)
lines - the lines to write.
public StringBuilder toString(List<String> lines,
StringBuilder out)
lines - the lines to write.out - The StringBuilder instance to write to.
public void unIndent(SortedMap<Integer,List<String>> snippetMap,
boolean blockScope)
snippetMap - the snippets.blockScope - true to process every snippet separately, false to detect indent to remove using a global scope.
public List<SortedSet<Integer>> findSelectedLines(Source source)
throws IOException
source - the source to process.
IOException - in case of reading the source failed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||