Changeset 5785 for trunk/gli/src/org/greenstone/gatherer/util/Utility.java
- Timestamp:
- 2003-11-05T13:46:44+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r5771 r5785 160 160 /** The image for a toggle button whose state is 'off'. */ 161 161 static final public ImageIcon OFF_ICON = new ImageIcon(ClassLoader.getSystemResource("images/cross.gif")); 162 /** Method to turn a file from with the system file tree into a tree path for insertion into a tree.163 * @param file The <strong>File</strong> whose tree path you are attempting to discover.164 * @param in_col A <i>boolean</i> indicating whether we are looking for a file within a collection of not. If <i>true</i> then the tree paths head in the collection name, and no element in the path refers to the import directory. Otherwise the paths head will be one of the system roots and all traversed file locations will exist in the path.165 * @return A <strong>TreePath</strong> which traverses the file system tree to the specified file.166 */167 public static TreePath createTreePath(File file, boolean in_col) {168 TreePath path = null;169 // Get the absolute path of the file.170 String abs_path = file.getAbsolutePath();171 while(file != null) {172 // If we are looking for a node within our collection, we expect173 // its path from root to be <col_name>/... without any higher174 // details and without gimport. So if we encounter a gimport we175 // skip to its parent, add that, then return.176 if(in_col && file.getName().equals("gimport")) {177 file = file.getParentFile();178 if(path == null) {179 path = new TreePath(file.getName());180 }181 else {182 path = path.pathByAddingChild(file.getName());183 }184 file = null;185 }186 else {187 if(path == null) {188 path = new TreePath(file.getName());189 }190 else {191 path = path.pathByAddingChild(file.getName());192 }193 file = file.getParentFile();194 }195 }196 // Unfortunately we've created the path in reverse order so we have to197 // reverse it.198 Object temp[] = new Object[path.getPathCount()];199 for(int i = 0; i < temp.length; i++) {200 temp[(temp.length - 1) - i] = path.getPathComponent(i);201 }202 return new TreePath(temp);203 }204 162 205 163 /** Decodes a string of text so its safe to use in a Greenstone configuration file. Esentially replaces "\n" with a newline. … … 221 179 * @return The decoded <strong>String</strong>. 222 180 */ 223 publicstatic String decodeString(String encoded) {181 /* private static String decodeString(String encoded) { 224 182 String decoded = ""; 225 183 for(int i = 0; i < encoded.length(); i++) { … … 239 197 } 240 198 return decoded; 241 } 199 } */ 242 200 /** It turns out that in Java you have to make sure a directory is empty before you delete it (much like unix I suppose), and so just like unix I'll have to set up a recursive delete function. 243 201 * @param file The <strong>File</strong> you want to delete. … … 260 218 } 261 219 262 static publicString encodeGreenstone(String raw) {220 /* static private String encodeGreenstone(String raw) { 263 221 raw = raw.replaceAll("<", "<"); 264 222 raw = raw.replaceAll(">", ">"); 265 223 raw = raw.replaceAll("\n", "\\\\n"); 266 224 return raw; 267 } 225 } */ 268 226 269 227 /** Using this method we can request that a certain document be written, as valid XML, to a certain output stream. This makes use of the Xerces Serialization suite, which should in no way be confused with the usual method of Serialization used by Java. */ … … 578 536 * @return A <strong>String</strong> representation of the mirroring depth padded to length characters. 579 537 */ 580 publicstatic String getDepthString(int length) {538 /* private static String getDepthString(int length) { 581 539 return pad("" + Gatherer.self.config.getInt("mirroring.depth", false), length); 582 } 540 } */ 583 541 /** Method which constructs the etc directory given a certain collection. 584 542 * @param col_dir The location of the collection directory as a <strong>String</strong>. … … 646 604 647 605 648 static publicFile getRecycleDirectory() {606 /* static private File getRecycleDirectory() { 649 607 return new File(RECYCLE); 650 } 608 } */ 651 609 652 610 /** Determine whether a character is a hexidecimal one. … … 900 858 * @return A filtered <strong>File[]</strong> containing only those drives that are accessible and/or are floppy-disk media drives. 901 859 */ 902 publicstatic File[] validateDrives(File roots[]) {860 /* private static File[] validateDrives(File roots[]) { 903 861 Vector valid = new Vector(); 904 862 for(int i = 0; i < roots.length; i++) { … … 914 872 } 915 873 return roots; 916 } 874 } */ 917 875 }
Note:
See TracChangeset
for help on using the changeset viewer.