From 40710f788d7518d37cd2058563b0c9b57be37b85 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Fri, 31 Jul 2015 22:49:13 +1200 Subject: [PATCH] No effective change - remove unused --- .../server/lib/util/MapFromString.java | 63 ------------------- .../server/lib/util/MimeTypeHelper.java | 40 ------------ .../server/lib/util/NotFoundException.java | 23 ------- .../resource/ResourceManagerFactory.java | 3 +- 4 files changed, 1 insertion(+), 128 deletions(-) delete mode 100644 src/main/java/com/avaje/ebeaninternal/server/lib/util/MapFromString.java delete mode 100644 src/main/java/com/avaje/ebeaninternal/server/lib/util/MimeTypeHelper.java delete mode 100644 src/main/java/com/avaje/ebeaninternal/server/lib/util/NotFoundException.java diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/util/MapFromString.java b/src/main/java/com/avaje/ebeaninternal/server/lib/util/MapFromString.java deleted file mode 100644 index 8d8c350eb..000000000 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/util/MapFromString.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.avaje.ebeaninternal.server.lib.util; - -import java.util.LinkedHashMap; - -/** - * Utility String class that supports String manipulation functions. - */ -public class MapFromString { - - final LinkedHashMap map = new LinkedHashMap(); - - String mapToString; - - int stringLength; - int keyStart = 0; - int eqPos = 0; - int valEnd = 0; - - public static LinkedHashMap parse(String mapToString) { - MapFromString c = new MapFromString(mapToString); - return c.parse(); - } - - private MapFromString(String mapToString) { - if (mapToString.charAt(0) == '{'){ - mapToString = mapToString.substring(1); - } - if (mapToString.charAt(mapToString.length()-1) == '}'){ - mapToString = mapToString.substring(0, mapToString.length()-1); - } - - this.mapToString = mapToString; - this.stringLength = mapToString.length(); - } - - private LinkedHashMap parse() { - while(findNext()){ - } - return map; - } - - private boolean findNext() { - if (keyStart > stringLength){ - return false; - } - eqPos = mapToString.indexOf("=",keyStart); - if (eqPos == -1){ - throw new RuntimeException("No = after "+keyStart); - } - valEnd = mapToString.indexOf(", ",eqPos); - if (valEnd == -1){ - valEnd = mapToString.length(); - } - // check that the next valEnd occurs after the next eqPos - - String keyValue = mapToString.substring(keyStart,eqPos); - String valValue = mapToString.substring(eqPos+1,valEnd); - map.put(keyValue, valValue); - keyStart = valEnd + 2; - return true; - } - -} diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/util/MimeTypeHelper.java b/src/main/java/com/avaje/ebeaninternal/server/lib/util/MimeTypeHelper.java deleted file mode 100644 index a265f213e..000000000 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/util/MimeTypeHelper.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.avaje.ebeaninternal.server.lib.util; - - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * Helper methods to determine the mime type based on a file name. - */ -public class MimeTypeHelper { - - /** - * Return the mimeType for a given file path. - * This will extract the file extension, and then use that - * to look up an appropriate mime type (from the mimetypes.props file). - * - * To add a new mime type, add it to the mimetype.props file. - */ - public static String getMimeType(String filePath) { - - int lastPeriod = filePath.lastIndexOf("."); - if (lastPeriod > -1) { - filePath = filePath.substring(lastPeriod+1); - } - - try { - return resources.getString(filePath.toLowerCase()); - - } catch (MissingResourceException e) { - return null; - //String m = "Unable to locate mimetype for ["+filePath.toLowerCase()+"] in mimetypes.properties"; - //throw new NotFoundException(m); - } - - } - - private static final ResourceBundle resources = ResourceBundle.getBundle("com.avaje.lib.util.mimetypes"); - - -} diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/util/NotFoundException.java b/src/main/java/com/avaje/ebeaninternal/server/lib/util/NotFoundException.java deleted file mode 100644 index 89665573c..000000000 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/util/NotFoundException.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.avaje.ebeaninternal.server.lib.util; - - -/** - * A general exception where data is not found. - */ -public class NotFoundException extends RuntimeException -{ - static final long serialVersionUID = 7061559938704539845L; - - public NotFoundException(Exception cause) { - super(cause); - } - - public NotFoundException(String s, Exception cause) { - super(s, cause); - } - - public NotFoundException(String s) { - super(s); - } - -} diff --git a/src/main/java/com/avaje/ebeaninternal/server/resource/ResourceManagerFactory.java b/src/main/java/com/avaje/ebeaninternal/server/resource/ResourceManagerFactory.java index 77a72d2b7..a32fd5625 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/resource/ResourceManagerFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/resource/ResourceManagerFactory.java @@ -4,7 +4,6 @@ import com.avaje.ebean.config.ServerConfig; import com.avaje.ebeaninternal.server.lib.resource.DirectoryFinder; import com.avaje.ebeaninternal.server.lib.resource.FileResourceSource; import com.avaje.ebeaninternal.server.lib.resource.ResourceSource; -import com.avaje.ebeaninternal.server.lib.util.NotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -86,7 +85,7 @@ public class ResourceManagerFactory { return new FileResourceSource(fileDir); } else { String msg = "ResourceManager could not find directory [" + fileDir + "]"; - throw new NotFoundException(msg); + throw new IllegalArgumentException(msg); } }