src/main/java/hudson/plugins/dry/parser/DuplicationParserRegistry.java
public Collection<FileAnnotation> parse(final File file, final String moduleName) throws InvocationTargetException {
        String oldProperty = System.getProperty(SAX_DRIVER_PROPERTY);
        if (oldProperty != null) {
            System.setProperty(SAX_DRIVER_PROPERTY, SAXParser.class.getName());
        }

        FileInputStream inputStream = null;
        try {
            for (AbstractDryParser parser : parsers) {
                inputStream = new FileInputStream(file);
                if (parser.accepts(inputStream)) {
                    IOUtils.closeQuietly(inputStream);
                    inputStream = new FileInputStream(file);
                    Collection<DuplicateCode> result = parser.parse(inputStream, moduleName);
                    createLinkNames(result);
                    Set<FileAnnotation> warnings = Sets.newHashSet();
                    warnings.addAll(result);
                    ContextHashCode hashCode = new ContextHashCode();
                    for (FileAnnotation duplication : warnings) {
                        duplication.setContextHashCode(hashCode.create(duplication.getFileName(), duplication.getPrimaryLineNumber(),
                                defaultEncoding));
                    }

                    return warnings;
                }
            }
            throw new IOException("No parser found for duplicated code results file " + file.getAbsolutePath());
        }
        catch (IOException exception) {
            throw new InvocationTargetException(exception);
        }
        finally {
            IOUtils.closeQuietly(inputStream);
            if (oldProperty != null) {
                System.setProperty(SAX_DRIVER_PROPERTY, oldProperty);
            }
        }
    }
public Collection<FileAnnotation> parse(final File file, final String moduleName) throws InvocationTargetException {
        String oldProperty = System.getProperty(SAX_DRIVER_PROPERTY);
        if (oldProperty != null) {
            System.setProperty(SAX_DRIVER_PROPERTY, SAXParser.class.getName());
        }

        FileInputStream inputStream = null;
        try {
            for (AbstractDryParser parser : parsers) {
                inputStream = new FileInputStream(file);
                if (parser.accepts(inputStream)) {
                    IOUtils.closeQuietly(inputStream);
                    inputStream = new FileInputStream(file);
                    Collection<DuplicateCode> result = parser.parse(inputStream, moduleName);
                    createLinkNames(result);
                    Set<FileAnnotation> warnings = Sets.newHashSet();
                    warnings.addAll(result);
                    ContextHashCode hashCode = new ContextHashCode();
                    for (FileAnnotation duplication : warnings) {
                        duplication.setContextHashCode(hashCode.create(duplication.getFileName(), duplication.getPrimaryLineNumber(),
                                defaultEncoding));
                    }

                    return warnings;
                }
            }
            throw new IOException("No parser found for duplicated code results file " + file.getAbsolutePath());
        }
        catch (IOException exception) {
            throw new InvocationTargetException(exception);
        }
        finally {
            IOUtils.closeQuietly(inputStream);
            if (oldProperty != null) {
                System.setProperty(SAX_DRIVER_PROPERTY, oldProperty);
            }
        }
    }
public Collection < FileAnnotation > parse ( final File file , final String moduleName ) throws InvocationTargetException { String oldProperty = System . getProperty ( SAX_DRIVER_PROPERTY ) ; if ( oldProperty != null ) { System . setProperty ( SAX_DRIVER_PROPERTY , SAXParser . class . getName ( ) ) ; } FileInputStream inputStream = null ; try { for ( AbstractDryParser parser : parsers ) { inputStream = new FileInputStream ( file ) ; if ( parser . accepts ( inputStream ) ) { IOUtils . closeQuietly ( inputStream ) ; inputStream = new FileInputStream ( file ) ; Collection < DuplicateCode > result = parser . parse ( inputStream , moduleName ) ; createLinkNames ( result ) ; Set < FileAnnotation > warnings = Sets . newHashSet ( ) ; warnings . addAll ( result ) ; ContextHashCode hashCode = new ContextHashCode ( ) ; for ( FileAnnotation duplication : warnings ) { duplication . setContextHashCode ( hashCode . create ( duplication . getFileName ( ) , duplication . getPrimaryLineNumber ( ) , defaultEncoding ) ) ; } return warnings ; } } throw new IOException ( "No parser found for duplicated code results file " + file . getAbsolutePath ( ) ) ; } catch ( IOException exception ) { throw new InvocationTargetException ( exception ) ; } finally { IOUtils . closeQuietly ( inputStream ) ; if ( oldProperty != null ) { System . setProperty ( SAX_DRIVER_PROPERTY , oldProperty ) ; } } }
{@inheritDoc}
{