Skip navigation links
Simian - Similarity Analyser v2.5.10

Simian - Similarity Analyser, v 2.5.10 API Specification

This document is the API specification for Simian, version 2.5.10.

See: Description

Packages 
Package Description
com.harukizaemon.simian  

This document is the API specification for Simian, version 2.5.10.

The programmatic interface allows appropriate license holders to use simian from their own applications such as third-party tools, plugins, etc.

To get you started, here is an example of how the API might be used. Assume that the command-line contains a list of files to load:

    public void main(String[] args) {
        AuditListener auditListener = new MyAuditListener();

        Options options = new Options();
        options.setThreshold(6);
        options.setOption(Option.IGNORE_STRINGS, true);

        Checker checker = new Checker(auditListener, options);

        StreamLoader streamLoader = new StreamLoader(checker);

        FileLoader fileLoader = new FileLoader(streamLoader);

        for (int i = 0; i < args.length; ++i) {
            loader.load(args[i]);
        }

        if (checker.check()) {
            System.out.println("Duplicate lines were found!");
        }
    }

If your files are sourced from other than the file system, say from a socket for example, you can use a StreamLoader instead of a FileLoader:

        StreamLoader streamLoader = new StreamLoader(checker);

        InputStream streamLoader = socket.getInputStream();

        try {
            loader.load("MyFile.java", stream);
        } finally {
            stream.close();
        }

Next you will no doubt need to process the output of the Checker. For this, you must implement the AuditListener interface. The checker will notify the event auditListener on significant events such as the start/end of a check, file processing and of course once for each duplicated block of code.

If for some reason you need to have multiple listeners, or in fact if you don't wish to be notified at all, you can use a CompositeAuditListener as a multi-cast dispatcher.

Skip navigation links
Simian - Similarity Analyser v2.5.10

Copyright (c) 2003-2018 Simon Harris. All rights reserved.