Class CRParser.BlockParser

  • Enclosing class:

    public static class CRParser.BlockParser
    extends java.lang.Object
    A class to parse a block by reading properties and blocks using a scanner.
    • Constructor Detail

      • BlockParser

        public BlockParser()
        Creates a new parser.
    • Method Detail

      • addTagHandler

        public void addTagHandler​(java.lang.String tagName,
                                  CRParser.TagHandler handler)
        Adds a handler that is called if the specified tag (i.e., a line like ";tagName" is encountered.
        tagName - The name of the tag triggering this handler
        handler - The handler for the tag
      • addBeanHandler

        public void addBeanHandler​(java.lang.String tagName,
                                   java.lang.String propertyName,
                                   CRParser.Type type)
        Adds a handler that manipulates a bean.
        tagName - The name of the tag triggering this handler
        propertyName - The property manipulated by the handler
        type - The type of the property
      • addNullHandler

        public void addNullHandler​(java.lang.String tagName)
        Adds a handler that does nothing (but doesn't cause an error) for the specified tag.
        tagName - The tag triggering this handler
      • addBlockHandler

        public void addBlockHandler​(java.lang.String name,
                                    CRParser.TagHandler tagHandler)
        Add a handler for a block, called if a block line like "NAME ..." is read.
        name - the block name, i.e. the first word of the BLOCK line.
        tagHandler - The handler that is called upon reading the block.
      • parse

        public void parse​(CRParser crParser,
                          CRParser.ParseState state)
        Parses the block by calling Scanner.getNextToken() and calling appropriate handlers. Terminates if a block is encountered that has no handler or on end of file.
        crParser - the CRParser, mainly used for calls to CRParser.unknown(String, boolean).
        state - The initial state which is passed to handlers.
        Throws: - If the scanner throws an exception
      • getDefaultTagHandler

        public CRParser.TagHandler getDefaultTagHandler()
        Returns the value of defaultTagHandler.
        Returns defaultTagHandler.
      • setDefaultTagHandler

        public void setDefaultTagHandler​(CRParser.TagHandler defaultTagHandler)
        Sets the value of defaultTagHandler.
        defaultTagHandler - The value for defaultTagHandler.
      • getDefaultBlockHandler

        public CRParser.TagHandler getDefaultBlockHandler()
        Returns the value of defaultBlockHandler.
        Returns defaultBlockHandler.
      • setDefaultBlockHandler

        public void setDefaultBlockHandler​(CRParser.TagHandler defaultBlockHandler)
        Sets the value of defaultBlockHandler.
        defaultBlockHandler - The value for defaultBlockHandler.
      • setBlockName

        public void setBlockName​(java.lang.String blockName)