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

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/io/SongLoader.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mfrom: (1.1.1 upstream) (2.1.3 hardy)
  • Revision ID: james.westby@ubuntu.com-20080619003030-agens2gvd5m4dacu
New upstream release (Closes: #481728) also (LP: #176979, #212207)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Created on 19-dic-2005
3
 
 *
4
 
 * TODO To change the template for this generated file go to
5
 
 * Window - Preferences - Java - Code Style - Code Templates
6
 
 */
7
 
package org.herac.tuxguitar.io;
8
 
 
9
 
import org.herac.tuxguitar.io.gp.GP3InputStream;
10
 
import org.herac.tuxguitar.io.gp.GP4InputStream;
11
 
import org.herac.tuxguitar.io.gp.GP5InputStream;
12
 
import org.herac.tuxguitar.io.pt.PTB4InputStream;
13
 
import org.herac.tuxguitar.io.tg.TGInputStream;
14
 
import org.herac.tuxguitar.song.models.Song;
15
 
 
16
 
/**
17
 
 * @author julian
18
 
 *
19
 
 * TODO To change the template for this generated type comment go to
20
 
 * Window - Preferences - Java - Code Style - Code Templates
21
 
 */
22
 
public class SongLoader {    
23
 
    private String fileName;
24
 
    
25
 
    public SongLoader(String fileName){
26
 
        this.fileName = fileName;
27
 
    }
28
 
 
29
 
    public Song load() throws FileFormatFormatException{
30
 
        Song song = null;
31
 
        try{
32
 
                //TuxGuitar Format
33
 
                TGInputStream tg = new TGInputStream(this.fileName);
34
 
                if(tg.isSupportedVersion()){
35
 
                        return tg.read();
36
 
                }
37
 
                //Guitar Pro 3 Format
38
 
                GP3InputStream gp3 = new GP3InputStream(this.fileName);
39
 
                if(gp3.isSupportedVersion()){
40
 
                        return gp3.readSong();
41
 
                }
42
 
                //Guitar Pro 4 Format        
43
 
                GP4InputStream gp4 = new GP4InputStream(this.fileName);
44
 
                if(gp4.isSupportedVersion()){
45
 
                        return gp4.readSong();
46
 
                }        
47
 
                //Guitar Pro 5 Format        
48
 
                GP5InputStream gp5 = new GP5InputStream(this.fileName);
49
 
                if(gp5.isSupportedVersion()){
50
 
                        return gp5.readSong();
51
 
                }   
52
 
        
53
 
                //Power Tab 1.7 Format
54
 
                PTB4InputStream ptb = new PTB4InputStream(this.fileName);
55
 
                if(ptb.isSupportedVersion()){
56
 
                        return ptb.readSong();
57
 
                }           
58
 
        }catch(Exception e){
59
 
                throw new FileFormatFormatException(e); 
60
 
        }catch(Error e){
61
 
                throw new FileFormatFormatException(e); 
62
 
        }
63
 
        
64
 
        throw new UnsupportedFormatException();
65
 
    }    
66
 
    
67
 
}