~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/tools/browser/filesystem/TGBrowserElementImpl.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mto: (5.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20080619003030-h719szrhsngou7c6
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
        
 
16
        public TGBrowserElementImpl(TGBrowserElementImpl parent,File file) {
 
17
                super(file.getName());
 
18
                this.parent = parent;
 
19
                this.file = file;
 
20
        }
 
21
        
 
22
        public File getFile() {
 
23
                return this.file;
 
24
        }
 
25
        
 
26
        public TGBrowserElementImpl getParent() {
 
27
                return this.parent;
 
28
        }
 
29
        
 
30
        public boolean isFolder(){
 
31
                return getFile().isDirectory();
 
32
        }
 
33
        
 
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
}