protected boolean parseLine ( final ParserData parserData , final String line , int lineNumber ) throws IndentationException { assert line != null ; // Trim the whitespace final String trimmedLine = line . trim ( ) ; // If the line is a blank or a comment, then nothing needs processing. So add the line and return if ( isBlankLine ( trimmedLine ) || isCommentLine ( trimmedLine ) ) { return parseEmptyOrCommentLine ( parserData , line ) ; } else { // Calculate the lines indentation level int lineIndentationLevel = calculateLineIndentationLevel ( parserData , line , lineNumber ) ; if ( lineIndentationLevel > parserData . getIndentationLevel ( ) ) { // The line was indented without a new level so throw an error throw new IndentationException ( format ( ProcessorConstants . ERROR_INCORRECT_INDENTATION_MSG , lineNumber , trimmedLine ) ) ; } else if ( lineIndentationLevel < parserData . getIndentationLevel ( ) ) { // The line has left the previous level so move the current level up to the right level Level newCurrentLevel = parserData . getCurrentLevel ( ) ; for ( int i = ( parserData . getIndentationLevel ( ) - lineIndentationLevel ) ; i > 0 ; i -- ) { if ( newCurrentLevel . getParent ( ) != null ) { newCurrentLevel = newCurrentLevel . getParent ( ) ; } } changeCurrentLevel ( parserData , newCurrentLevel , lineIndentationLevel ) ; } // Process the line based on what type the line is try { if ( isMetaDataLine ( parserData , trimmedLine ) ) { parseMetaDataLine ( parserData , line , lineNumber ) ; } else if ( isCommonContentLine ( trimmedLine ) ) { final CommonContent commonContent = parseCommonContentLine ( parserData , line , lineNumber ) ; parserData . getCurrentLevel ( ) . appendChild ( commonContent ) ; } else if ( isLevelInitialContentLine ( trimmedLine ) ) { final Level initialContent = parseLevelLine ( parserData , trimmedLine , lineNumber ) ; parserData . getCurrentLevel ( ) . appendChild ( initialContent ) ; // Change the current level to use the new parsed level changeCurrentLevel ( parserData , initialContent , parserData . getIndentationLevel ( ) + 1 ) ; } else if ( isLevelLine ( trimmedLine ) ) { final Level level = parseLevelLine ( parserData , trimmedLine , lineNumber ) ; if ( level instanceof Process ) { parserData . getProcesses ( ) . add ( ( Process ) level ) ; } parserData . getCurrentLevel ( ) . appendChild ( level ) ; // Change the current level to use the new parsed level changeCurrentLevel ( parserData , level , parserData . getIndentationLevel ( ) + 1 ) ; // } else if (trimmedLine.toUpperCase(Locale.ENGLISH).matches("^CS[ ]*:.*")) { // processExternalLevelLine(getCurrentLevel(), line); } else if ( StringUtilities . indexOf ( trimmedLine , ' ' ) == 0 && parserData . getCurrentLevel ( ) . getLevelType ( ) == LevelType . BASE ) { parseGlobalOptionsLine ( parserData , line , lineNumber ) ; } else { // Process a new topic final SpecTopic tempTopic = parseTopic ( parserData , trimmedLine , lineNumber ) ; // Adds the topic to the current level parserData . getCurrentLevel ( ) . appendSpecTopic ( tempTopic ) ; } } catch ( ParsingException e ) { log . error ( e . getMessage ( ) ) ; return false ; } return true ; } }
Processes a line of the content specification and stores it in objects