/** * Get the default shortened server name given the server's path. * * @param path * @return */ public static String getDefaultShortServerName(final String path) { try { String name = new File(path).getName().replaceFirst("[.][^.]+$", ""); return name; } catch (Exception e) {} if (URLTools.checkURL(path)) return URLTools.getNameFromBaseURL(path); return path; }
/** * Read URL as String, with default timeout of 5 seconds. * * @param url * @return */ public static String readURLAsString(final URL url) throws IOException { return readURLAsString(url, 5000); // Here, use 5 second timeout }
/** * Create a ImageServer<BufferedImage> after first reading the image using ImageIO. * * @param path * @throws MalformedURLException * @throws IOException */ public ImageIoImageServer(String path) throws MalformedURLException, IOException { this(path, null, URLTools.checkURL(path) ? ImageIO.read(new URL(path)) : ImageIO.read(new File(path))); }
public static ImageCheckType checkImageType(final String path) { if (URLTools.checkURL(path)) return ImageCheckType.URL;
public ProjectImageEntry(final Project<T> project, final String serverPath, final String imageName, final Map<String, String> metadataMap) { this.project = project; this.serverPath = serverPath; // TODO: Check if this is a remotely acceptable way to achieve relative pathnames! I suspect it is not really... String projectPath = project.getBaseDirectory().getAbsolutePath(); if (this.serverPath.startsWith(projectPath)) this.serverPath = "{$PROJECT_DIR}" + this.serverPath.substring(projectPath.length()); if (imageName == null) { if (URLTools.checkURL(serverPath)) this.imageName = URLTools.getNameFromBaseURL(serverPath); else this.imageName = new File(serverPath).getName(); } else this.imageName = imageName; if (metadataMap != null) metadata.putAll(metadataMap); }