Class SnippetReader
- java.lang.Object
-
- org.apache.maven.doxia.macro.snippet.SnippetReader
-
public class SnippetReader extends java.lang.Object
Utility class for reading snippets.- Version:
- $Id$
-
-
Constructor Summary
Constructors Constructor Description SnippetReader(java.net.URL src)
Constructor.SnippetReader(java.net.URL src, java.lang.String encoding)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
readSnippet
public java.lang.StringBuffer readSnippet(java.lang.String snippetId) throws java.io.IOException
Reads the snippet with given id.- Parameters:
snippetId
- The id of the snippet.- Returns:
- The snippet.
- Throws:
java.io.IOException
- if something goes wrong.
-
minIndent
int minIndent(java.util.List<java.lang.String> lines)
Returns the minimal indent of all the lines in the given List.- Parameters:
lines
- A List of lines.- Returns:
- the minimal indent.
-
indent
int indent(java.lang.String line)
Returns the indent of the given line.- Parameters:
line
- A line.- Returns:
- the indent.
-
readLines
private java.util.List<java.lang.String> readLines(java.lang.String snippetId) throws java.io.IOException
Reads the snippet and returns the lines in a List.- Parameters:
snippetId
- The id of the snippet.- Returns:
- A List of lines.
- Throws:
java.io.IOException
- if something goes wrong.
-
isStart
protected boolean isStart(java.lang.String snippetId, java.lang.String line)
Determines if the given line is a start demarcator.- Parameters:
snippetId
- the id of the snippet.line
- the line.- Returns:
- True, if the line is a start demarcator.
-
isDemarcator
protected static boolean isDemarcator(java.lang.String snippetId, java.lang.String what, java.lang.String line)
Determines if the given line is a demarcator.- Parameters:
snippetId
- the id of the snippet.what
- Identifier for the demarcator.line
- the line.- Returns:
- True, if the line is a start demarcator.
-
isEnd
protected boolean isEnd(java.lang.String snippetId, java.lang.String line)
Determines if the given line is an end demarcator.- Parameters:
snippetId
- the id of the snippet.line
- the line.- Returns:
- True, if the line is an end demarcator.
-
-