public class SnippetReader
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
encoding
The encoding of the source.
|
private static java.lang.String |
EOL
System-dependent EOL.
|
private java.net.URL |
source
The source.
|
Constructor and Description |
---|
SnippetReader(java.net.URL src)
Constructor.
|
SnippetReader(java.net.URL src,
java.lang.String encoding)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) int |
indent(java.lang.String line)
Returns the indent of the given line.
|
protected static boolean |
isDemarcator(java.lang.String snippetId,
java.lang.String what,
java.lang.String line)
Determines if the given line is a demarcator.
|
protected boolean |
isEnd(java.lang.String snippetId,
java.lang.String line)
Determines if the given line is an end demarcator.
|
protected boolean |
isStart(java.lang.String snippetId,
java.lang.String line)
Determines if the given line is a start demarcator.
|
(package private) int |
minIndent(java.util.List<java.lang.String> lines)
Returns the minimal indent of all the lines in the given List.
|
private java.util.List<java.lang.String> |
readLines(java.lang.String snippetId)
Reads the snippet and returns the lines in a List.
|
java.lang.StringBuffer |
readSnippet(java.lang.String snippetId)
Reads the snippet with given id.
|
private static final java.lang.String EOL
private java.net.URL source
private java.lang.String encoding
public SnippetReader(java.net.URL src, java.lang.String encoding)
src
- The sourceencoding
- The file encodingpublic SnippetReader(java.net.URL src)
src
- The sourcepublic java.lang.StringBuffer readSnippet(java.lang.String snippetId) throws java.io.IOException
snippetId
- The id of the snippet.java.io.IOException
- if something goes wrong.int minIndent(java.util.List<java.lang.String> lines)
lines
- A List of lines.int indent(java.lang.String line)
line
- A line.private java.util.List<java.lang.String> readLines(java.lang.String snippetId) throws java.io.IOException
snippetId
- The id of the snippet.java.io.IOException
- if something goes wrong.protected boolean isStart(java.lang.String snippetId, java.lang.String line)
snippetId
- the id of the snippet.line
- the line.protected static boolean isDemarcator(java.lang.String snippetId, java.lang.String what, java.lang.String line)
snippetId
- the id of the snippet.what
- Identifier for the demarcator.line
- the line.protected boolean isEnd(java.lang.String snippetId, java.lang.String line)
snippetId
- the id of the snippet.line
- the line.