Class BlockParser

java.lang.Object
org.glassfish.pfl.basic.tools.file.BlockParser

public class BlockParser extends Object
Utility class used to convert FileWrappers into (lists of) Blocks.
  • Field Details

  • Constructor Details

    • BlockParser

      private BlockParser()
  • Method Details

    • getBlock

      public static Block getBlock(FileWrapper fw) throws IOException
      Return the contents of the text file as a Block.
      Throws:
      IOException
    • parseBlocks

      public static List<Block> parseBlocks(FileWrapper fw, String prefix) throws IOException
      Transform fw into a list of blocks. There are two types of blocks in this list, and they always alternate:
      • Blocks in which every line starts with prefix, Such blocks are given the tag COMMENT_BLOCK_TAG.
      • Blocks in which no line starts with prefix. Such blocks are not tagged.
      Throws:
      IOException
    • parseBlocks

      public static List<Block> parseBlocks(FileWrapper fw, String start, String end) throws IOException
      Transform fw into a list of blocks. There are two types of blocks in this list, and they always alternate:
      • Blocks that start with a String containing start, and end with a String containing end. Such blocks are given the tag COMMENT_BLOCK_TAG.
      • Blocks that do not contain start or end anywhere
      Throws:
      IOException