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

org.schoellerfamily.gedbrowser.api.datamodel.ImageUtils Maven / Gradle / Ivy

There is a newer version: 1.3.0-RC2
Show newest version
package org.schoellerfamily.gedbrowser.api.datamodel;

import java.util.Locale;

/**
 * @author Dick Schoeller
 */
public class ImageUtils {
    /**
     * @param attr the attribute to check
     * @return true if it wraps an image
     */
    public boolean isImageWrapper(final ApiAttribute attr) {
        for (final ApiAttribute attribute : attr.getAttributes()) {
            if (this.isImage(attribute) || this.isImageWrapper(attribute)) {
                return true;
            }
        }
        return false;
    }

    /**
     * @param attribute the attribute to check
     * @return true if it is a reference to an image file type
     */
    public boolean isImage(final ApiAttribute attribute) {
        final String[] types = {
                "bmp", "gif", "ico", "jpg", "jpeg", "png", "tiff",
                "tif", "svg" };
        for (final String t : types) {
            if (attribute.getTail().toLowerCase(Locale.ENGLISH).endsWith(t)) {
                return true;
            }
        }
        return false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy