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

me.lightspeed7.mongofs.url.StorageFormat Maven / Gradle / Ivy

Go to download

An extension to the MongoDB Java Driver library that goes beyond what the GridFS feature supports. Compressed file storage, zip files, temporary files

There is a newer version: 0.10.0
Show newest version
package me.lightspeed7.mongofs.url;

public enum StorageFormat {

    GRIDFS(null, false, false), //
    GZIPPED("gz", true, false), //
    ENCRYPTED("enc", false, true), //
    ECRYPTED_GZIP("encgz", true, true) //
    //
    /* */;

    private final String code;
    private final boolean compressed;
    private final boolean encrypted;

    private StorageFormat(final String code, final boolean compressed, final boolean encrypted) {
        this.code = code;
        this.compressed = compressed;
        this.encrypted = encrypted;
    }

    public String getCode() {
        return code;
    }

    public boolean isCompressed() {
        return compressed;
    }

    public boolean isEncrypted() {
        return encrypted;
    }

    public static final StorageFormat find(final String str) {

        if (str == null) {
            return GRIDFS;
        }

        for (StorageFormat fmt : StorageFormat.values()) {
            if (fmt.name().equals(str)) {
                return fmt;
            }

            if (fmt.getCode() != null && fmt.getCode().equals(str)) {
                return fmt;
            }
        }
        return null;
    }

    public static final StorageFormat detect(final boolean compress, final boolean encrypt) {
        for (StorageFormat fmt : StorageFormat.values()) {
            if (fmt.isCompressed() == compress && fmt.isEncrypted() == encrypt) {
                return fmt;
            }
        }
        return GRIDFS;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy