@Test public void testRecognizeInstanceOf() throws Exception { Map<String,ParsingError> resourceNameToErrorCode = new LinkedHashMap<> (); resourceNameToErrorCode.put( "instanceof-invalid-property.instances", new ParsingError( ErrorCode.P_INVALID_PROPERTY_OR_INSTANCE, null, 2 )); resourceNameToErrorCode.put( "instanceof-invalid-property-2.instances", new ParsingError( ErrorCode.P_INVALID_PROPERTY_OR_INSTANCE, null, 3 )); resourceNameToErrorCode.put( "instanceof-invalid-end.instances", new ParsingError( ErrorCode.P_C_C_BRACKET_EXTRA_CHARACTERS, null, 3 )); resourceNameToErrorCode.put( "instanceof-missing-closing-cb.instances", new ParsingError( ErrorCode.P_C_C_BRACKET_MISSING, null, 3 )); resourceNameToErrorCode.put( "instanceof-missing-opening-cb.instances", new ParsingError( ErrorCode.P_O_C_BRACKET_MISSING, null, 1 )); resourceNameToErrorCode.put( "instanceof-extra-char.instances", new ParsingError( ErrorCode.P_O_C_BRACKET_EXTRA_CHARACTERS, null, 1 )); resourceNameToErrorCode.put( "instanceof-line-number.instances", new ParsingError( ErrorCode.P_C_C_BRACKET_MISSING, null, 6 )); resourceNameToErrorCode.put( "instanceof-imbricated-invalid-property.instances", new ParsingError( ErrorCode.P_INVALID_PROPERTY_OR_INSTANCE, null, 4 )); resourceNameToErrorCode.put( "instanceof-imbricated-invalid-end.instances", new ParsingError( ErrorCode.P_C_C_BRACKET_EXTRA_CHARACTERS, null, 5 )); resourceNameToErrorCode.put( "instanceof-imbricated-missing-closing-cb.instances", new ParsingError( ErrorCode.P_C_C_BRACKET_MISSING, null, 7 )); resourceNameToErrorCode.put( "instanceof-imbricated-missing-opening-cb.instances", new ParsingError( ErrorCode.P_O_C_BRACKET_MISSING, null, 3 )); resourceNameToErrorCode.put( "instanceof-imbricated-extra-char.instances", new ParsingError( ErrorCode.P_O_C_BRACKET_EXTRA_CHARACTERS, null, 3 )); resourceNameToErrorCode.put( "instanceof-very-imbricated-invalid-property.instances", new ParsingError( ErrorCode.P_INVALID_PROPERTY_OR_INSTANCE, null, 5 )); resourceNameToErrorCode.put( "instanceof-very-imbricated-invalid-end.instances", new ParsingError( ErrorCode.P_C_C_BRACKET_EXTRA_CHARACTERS, null, 6 )); resourceNameToErrorCode.put( "instanceof-very-imbricated-missing-closing-cb.instances", new ParsingError( ErrorCode.P_C_C_BRACKET_MISSING, null, 8 )); resourceNameToErrorCode.put( "instanceof-very-imbricated-missing-opening-cb.instances", new ParsingError( ErrorCode.P_O_C_BRACKET_MISSING, null, 5 )); resourceNameToErrorCode.put( "instanceof-very-imbricated-extra-char.instances", new ParsingError( ErrorCode.P_O_C_BRACKET_EXTRA_CHARACTERS, null, 4 )); testRecognizePropertiesHolder( resourceNameToErrorCode, AbstractBlock.INSTANCEOF ); }
int recognizeInstanceOf( String line, BufferedReader br, AbstractBlockHolder holderInstance ) throws IOException { int result = P_CODE_NO; if( startsWith( line, ParsingConstants.KEYWORD_INSTANCE_OF )) { String newLine = line.replaceFirst( "(?i)\\s*" + Pattern.quote( ParsingConstants.KEYWORD_INSTANCE_OF ), "" ); BlockInstanceOf newInstance = new BlockInstanceOf( this.definitionFile ); result = recognizePropertiesHolder( newLine, br, newInstance ); if( result == P_CODE_YES && holderInstance != null ) { this.definitionFile.getBlocks().remove( newInstance ); holderInstance.getInnerBlocks().add( newInstance ); } } return result; }
FileDefinitionParser { int recognizeInstanceOf( String line, BufferedReader br, AbstractBlockHolder holderInstance ) throws IOException { int result = P_CODE_NO; if( startsWith( line, ParsingConstants.KEYWORD_INSTANCE_OF )) { String newLine = line.replaceFirst( "(?i)\\s*" + Pattern.quote( ParsingConstants.KEYWORD_INSTANCE_OF ), "" ); BlockInstanceOf newInstance = new BlockInstanceOf( this.definitionFile ); result = recognizePropertiesHolder( newLine, br, newInstance ); if( result == P_CODE_YES && holderInstance != null ) { this.definitionFile.getBlocks().remove( newInstance ); holderInstance.getInnerBlocks().add( newInstance ); } } return result; } }
FileDefinitionParser { int recognizeInstanceOf( String line, BufferedReader br, AbstractBlockHolder holderInstance ) throws IOException { int result = P_CODE_NO; if( startsWith( line, ParsingConstants.KEYWORD_INSTANCE_OF )) { String newLine = line.replaceFirst( "(?i)\\s*" + Pattern.quote( ParsingConstants.KEYWORD_INSTANCE_OF ), "" ); BlockInstanceOf newInstance = new BlockInstanceOf( this.definitionFile ); result = recognizePropertiesHolder( newLine, br, newInstance ); if( result == P_CODE_YES && holderInstance != null ) { this.definitionFile.getBlocks().remove( newInstance ); holderInstance.getInnerBlocks().add( newInstance ); } } return result; } FileDefinitionParser( File relationsFile, boolean ignoreComments ); }
FileDefinitionParser { int recognizeInstanceOf( String line, BufferedReader br, AbstractBlockHolder holderInstance ) throws IOException { int result = P_CODE_NO; if( startsWith( line, ParsingConstants.KEYWORD_INSTANCE_OF )) { String newLine = line.replaceFirst( "(?i)\\s*" + Pattern.quote( ParsingConstants.KEYWORD_INSTANCE_OF ), "" ); BlockInstanceOf newInstance = new BlockInstanceOf( this.definitionFile ); result = recognizePropertiesHolder( newLine, br, newInstance ); if( result == P_CODE_YES && holderInstance != null ) { this.definitionFile.getBlocks().remove( newInstance ); holderInstance.getInnerBlocks().add( newInstance ); } } return result; } FileDefinitionParser( File relationsFile, boolean ignoreComments ); FileDefinition read(); }
FileDefinitionParser { int recognizeInstanceOf( String line, BufferedReader br, AbstractBlockHolder holderInstance ) throws IOException { int result = P_CODE_NO; if( startsWith( line, ParsingConstants.KEYWORD_INSTANCE_OF )) { String newLine = line.replaceFirst( "(?i)\\s*" + Pattern.quote( ParsingConstants.KEYWORD_INSTANCE_OF ), "" ); BlockInstanceOf newInstance = new BlockInstanceOf( this.definitionFile ); result = recognizePropertiesHolder( newLine, br, newInstance ); if( result == P_CODE_YES && holderInstance != null ) { this.definitionFile.getBlocks().remove( newInstance ); holderInstance.getInnerBlocks().add( newInstance ); } } return result; } FileDefinitionParser( File relationsFile, boolean ignoreComments ); FileDefinition read();  }