1 16 package org.apache.commons.vfs.test; 17 18 import org.apache.commons.vfs.FileType; 19 20 import java.util.HashMap ; 21 import java.util.Map ; 22 23 26 class FileInfo 27 { 28 String baseName; 29 FileType type; 30 String content; 31 Map children = new HashMap (); 32 FileInfo parent; 33 34 public FileInfo(final String name, final FileType type) 35 { 36 baseName = name; 37 this.type = type; 38 this.content = null; 39 } 40 41 public FileInfo(final String name, final FileType type, final String content) 42 { 43 baseName = name; 44 this.type = type; 45 this.content = content; 46 } 47 48 public FileInfo getParent() 49 { 50 return parent; 51 } 52 53 56 public void addChild(final FileInfo child) 57 { 58 children.put(child.baseName, child); 59 child.parent = this; 60 } 61 62 65 public FileInfo addFile(final String baseName, final String content) 66 { 67 final FileInfo child = new FileInfo(baseName, FileType.FILE, content); 68 addChild(child); 69 return child; 70 } 71 72 75 public FileInfo addFolder(final String baseName) 76 { 77 final FileInfo child = new FileInfo(baseName, FileType.FOLDER, null); 78 addChild(child); 79 return child; 80 } 81 } 82 | Popular Tags |