All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fabric3.spi.scanner.AbstractResource Maven / Gradle / Ivy

There is a newer version: 0.7
Show newest version
package org.fabric3.spi.scanner;

import java.io.IOException;

import org.fabric3.spi.scanner.FileSystemResource;
                       
/**
 * Base file system resource implementation
 *
 * @version $Rev: 3581 $ $Date: 2008-04-07 23:04:07 -0700 (Mon, 07 Apr 2008) $
 */
public abstract class AbstractResource implements FileSystemResource {
    protected byte[] checksumValue;

    public boolean isChanged() throws IOException {
        byte[] newValue = checksum();
        if (checksumValue == null || checksumValue.length != newValue.length) {
            checksumValue = newValue;
            return true;
        }
        for (int i = 0; i < newValue.length; i++) {
            if (newValue[i] != checksumValue[i]) {
                checksumValue = newValue;
                return true;
            }
        }
        return false;
    }

    public byte[] getChecksum() {
        return checksumValue;
    }

    public void reset() throws IOException {
        checksumValue = checksum();
    }

    protected abstract byte[] checksum() throws IOException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy