Mercurial > hg > digilib-old
annotate servlet/src/digilib/io/Directory.java @ 305:c118e503f625
Servlet version 1.5.1b -- the beginning of the next generation :-)
- code restructuring to improve scaleability
- new Initialiser servlet that must be run first
- image transformation work moved to DigilibImageWorker class
- Maximum number of concurrent threads limited by Semaphore
- old JIMI toolkit implementation removed
- new option "mo=jpg" to force sending JPEGs
| author | robcast |
|---|---|
| date | Sun, 24 Oct 2004 23:12:56 +0200 |
| parents | 90bab835fc25 |
| children | 4a45cd965133 |
| rev | line source |
|---|---|
| 151 | 1 /* Directory -- Filesystem directory object |
| 149 | 2 |
| 3 Digital Image Library servlet components | |
| 4 | |
| 5 Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de) | |
| 6 | |
| 7 This program is free software; you can redistribute it and/or modify it | |
| 8 under the terms of the GNU General Public License as published by the | |
| 9 Free Software Foundation; either version 2 of the License, or (at your | |
| 10 option) any later version. | |
| 11 | |
| 12 Please read license.txt for the full details. A copy of the GPL | |
| 13 may be found at http://www.gnu.org/copyleft/lgpl.html | |
| 14 | |
| 15 You should have received a copy of the GNU General Public License | |
| 16 along with this program; if not, write to the Free Software | |
| 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 18 | |
| 19 * Created on 26.08.2003 | |
| 20 * | |
| 21 */ | |
| 22 package digilib.io; | |
| 23 | |
| 24 import java.io.File; | |
| 259 | 25 import java.util.Arrays; |
| 26 | |
| 27 import org.apache.log4j.Logger; | |
| 149 | 28 |
| 29 /** Class for filesystem directories | |
| 30 * @author casties | |
| 31 * | |
| 32 */ | |
| 33 public class Directory { | |
| 259 | 34 |
| 35 protected Logger logger = Logger.getLogger(this.getClass()); | |
| 36 | |
| 37 /** File object pointing to the directory */ | |
| 282 | 38 protected File dir = null; |
| 259 | 39 /** parent directory */ |
| 282 | 40 protected Directory parent = null; |
| 259 | 41 /** list of filenames in the directory */ |
| 42 protected String[] list = null; | |
| 149 | 43 |
| 44 /** Default constructor. | |
| 45 * | |
| 46 */ | |
| 47 public Directory() { | |
| 48 super(); | |
| 49 } | |
| 50 | |
| 51 /** Constructor taking a File object. | |
| 52 * | |
| 53 * @param d | |
| 54 */ | |
| 55 public Directory(File d) { | |
| 56 dir = d; | |
| 57 } | |
| 58 | |
| 151 | 59 /** Constructor taking a File object and a parent. |
| 60 * | |
| 159 | 61 * @param dir |
| 62 * @param parent | |
| 151 | 63 */ |
| 64 public Directory(File dir, Directory parent) { | |
| 65 this.dir = dir; | |
| 66 this.parent = parent; | |
| 67 } | |
| 68 | |
| 149 | 69 /** Constructor taking a directory name. |
| 70 * | |
| 71 * @param d | |
| 72 */ | |
| 73 public Directory(String dn) { | |
| 74 dir = new File(dn); | |
| 75 } | |
| 76 | |
| 259 | 77 |
| 78 /** Reads the names of the files in the directory. | |
| 79 * Fills the filenames array. Returns if the operation was successful. | |
| 80 * | |
| 81 * @return | |
| 82 */ | |
| 83 public boolean readDir() { | |
| 84 if (dir != null) { | |
|
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
282
diff
changeset
|
85 //logger.debug("reading dir: "+dir.getPath()); |
| 259 | 86 list = dir.list(); |
| 87 Arrays.sort(list); | |
|
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
282
diff
changeset
|
88 //logger.debug(" done"); |
| 259 | 89 } |
| 90 return (list != null); | |
| 91 } | |
| 92 | |
| 149 | 93 /** |
| 94 * @return | |
| 95 */ | |
| 96 public File getDir() { | |
| 97 return dir; | |
| 98 } | |
| 99 | |
| 100 /** | |
| 101 * @param dir | |
| 102 */ | |
| 103 public void setDir(File dir) { | |
| 104 this.dir = dir; | |
| 105 } | |
| 151 | 106 |
| 107 /** | |
| 108 * @return | |
| 109 */ | |
| 110 Directory getParent() { | |
| 111 return parent; | |
| 112 } | |
| 113 | |
| 114 /** | |
| 115 * @param parent | |
| 116 */ | |
| 117 void setParent(Directory parent) { | |
| 118 this.parent = parent; | |
| 119 } | |
| 120 | |
| 149 | 121 |
| 259 | 122 /** |
| 123 * @return Returns the filenames. | |
| 124 */ | |
| 125 public String[] getFilenames() { | |
| 126 return list; | |
| 127 } | |
| 270 | 128 |
| 259 | 129 /** |
| 130 * @param filenames The filenames to set. | |
| 131 */ | |
| 132 public void setFilenames(String[] filenames) { | |
| 133 this.list = filenames; | |
| 134 } | |
| 270 | 135 |
| 136 public void clearFilenames() { | |
| 137 this.list = null; | |
| 138 } | |
| 149 | 139 } |
