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

org.opentripplanner.api.parameter.MIMEImageFormat Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
package org.opentripplanner.api.parameter;

import java.util.Arrays;
import java.util.Collection;
import javax.ws.rs.BadRequestException;

public class MIMEImageFormat {

  public static final Collection acceptedTypes = Arrays.asList(
    "png",
    "gif",
    "jpeg",
    "geotiff"
  );

  public final String type;

  public MIMEImageFormat(String s) {
    String[] parts = s.split("/");
    if (parts.length == 2 && parts[0].equals("image")) {
      if (acceptedTypes.contains(parts[1])) {
        type = parts[1];
      } else {
        throw new BadRequestException("unsupported image format: " + parts[1]);
      }
    } else {
      throw new BadRequestException("malformed image format mime type: " + s);
    }
  }

  public String toString() {
    return "image/" + type;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy