1 package org.herac.tuxguitar.gui.tools.browser.filesystem;
2 
3 import java.io.File;
4 import java.io.FileInputStream;
5 import java.io.FileNotFoundException;
6 import java.io.InputStream;
7 
8 import org.herac.tuxguitar.gui.tools.browser.TGBrowserException;
9 import org.herac.tuxguitar.gui.tools.browser.base.TGBrowserElement;
10 
11 public class TGBrowserElementImpl extends TGBrowserElement{
12 
13 	private TGBrowserElementImpl parent;
14 	private File file;
15 
TGBrowserElementImpl(TGBrowserElementImpl parent,File file)16 	public TGBrowserElementImpl(TGBrowserElementImpl parent,File file) {
17 		super(file.getName());
18 		this.parent = parent;
19 		this.file = file;
20 	}
21 
getFile()22 	public File getFile() {
23 		return this.file;
24 	}
25 
getParent()26 	public TGBrowserElementImpl getParent() {
27 		return this.parent;
28 	}
29 
isFolder()30 	public boolean isFolder(){
31 		return getFile().isDirectory();
32 	}
33 
getInputStream()34 	public InputStream getInputStream() throws TGBrowserException {
35 		if(!isFolder()){
36 			try {
37 				return new FileInputStream(getFile());
38 			} catch (FileNotFoundException e) {
39 				throw new TGBrowserException(e);
40 			}
41 		}
42 		return null;
43 	}
44 
45 }
46