Overview | Package | Class | Tree | Deprecated | Index | Help

Simian - Similarity Analyser v2.3.33
PREV NEXT | FRAMES NO FRAMES

# Simian - Similarity Analyser, v 2.3.33 API Specification

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

See:
Description

Packages
com.harukizaemon.simian |

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

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 listener = new MyAuditListener();

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

            Checker checker = new Checker(listener, 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 listener 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.

Overview | Package | Class | Tree | Deprecated | Index | Help

Simian - Similarity Analyser v2.3.33
PREV NEXT | FRAMES NO FRAMES

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