diff servlet/src/digilib/io/FileOps.java @ 271:d3abaf38fb5f

Servlet version 1.21b3 - searching in directories got faster (real binarySearch now!) - cached file lists get disposed - some code cleaning (Map types instead of HashMap)
author robcast
date Tue, 12 Oct 2004 16:06:43 +0200
parents beed92ee6022
children b3519a49ae51
line wrap: on
line diff
--- a/servlet/src/digilib/io/FileOps.java	Tue Oct 12 16:06:43 2004 +0200
+++ b/servlet/src/digilib/io/FileOps.java	Tue Oct 12 16:06:43 2004 +0200
@@ -75,6 +75,7 @@
 		imageExtensions = new ArrayList();
 		textExtensions = new ArrayList();
 		svgExtensions = new ArrayList();
+		// iterate through file types in ft and fill the Map and Lists
 		for (int i = 0; i < ft.length; i++) {
 			String ext = ft[i][0];
 			String mt = ft[i][1];
@@ -175,6 +176,9 @@
 	 * @return
 	 */
 	public static String basename(String fn) {
+		if (fn == null) {
+			return null;
+		}
 		int i = fn.lastIndexOf('.');
 		if (i > 0) {
 			return fn.substring(0, i);
@@ -193,6 +197,9 @@
 	 * @return
 	 */
 	public static String extname(String fn) {
+		if (fn == null) {
+			return null;
+		}
 		int i = fn.lastIndexOf('.');
 		if (i > 0) {
 			return fn.substring(i + 1);
@@ -211,6 +218,9 @@
 	 * @return
 	 */
 	public static String parent(String fn) {
+		if (fn == null) {
+			return null;
+		}
 		int i = fn.lastIndexOf('/');
 		if (i > 0) {
 			return fn.substring(0, i);
@@ -228,6 +238,9 @@
 	 * @return
 	 */
 	public static String normalName(String pathname) {
+		if (pathname == null) {
+			return null;
+		}
 		// upper-dir references are unwanted
 		if (pathname.indexOf("../") >= 0) {
 			return null;
@@ -366,7 +379,7 @@
 	 * @return
 	 */
 	public static Map newHints(Integer type, Object value) {
-		HashMap m = new HashMap();
+		Map m = new HashMap();
 		if (type != null) {
 			m.put(type, value);
 		}