Class SnippetReader

java.lang.Object
org.apache.maven.doxia.macro.snippet.SnippetReader

public class SnippetReader extends Object
Utility class for reading snippets.
  • Field Details

    • EOL

      private static final String EOL
      System-dependent EOL.
    • source

      private URL source
      The source.
    • encoding

      private String encoding
      The encoding of the source.
  • Constructor Details

    • SnippetReader

      public SnippetReader(URL src, String encoding)
      Constructor.
      Parameters:
      src - The source
      encoding - The file encoding
    • SnippetReader

      public SnippetReader(URL src)
      Constructor.
      Parameters:
      src - The source
  • Method Details

    • readSnippet

      public StringBuffer readSnippet(String snippetId) throws IOException
      Reads the snippet with given id.
      Parameters:
      snippetId - The id of the snippet.
      Returns:
      The snippet.
      Throws:
      IOException - if something goes wrong.
    • minIndent

      int minIndent(List<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(String line)
      Returns the indent of the given line.
      Parameters:
      line - A line.
      Returns:
      the indent.
    • readLines

      private List<String> readLines(String snippetId) throws IOException
      Reads the snippet and returns the lines in a List.
      Parameters:
      snippetId - The id of the snippet.
      Returns:
      A List of lines.
      Throws:
      IOException - if something goes wrong.
    • isStart

      protected boolean isStart(String snippetId, 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(String snippetId, String what, 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(String snippetId, 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.