View Javadoc

1   /*
2    *                Doelan development code
3    *
4    * This code may be freely distributed and modified under the
5    * terms of the GNU General Public Licence.  This should
6    * be distributed with the code. If you do not have a copy,
7    * see:
8    *
9    *      http://www.gnu.org/copyleft/gpl.txt
10   *
11   * Copyright (c) 2004-2005 ENS Microarray Platform
12   * Copyright for this code is held jointly by the individual
13   * authors.  These should be listed in @author doc comments.
14   *
15   * For more information on the Doelan project and its aims,
16   * or to join the Doelan mailing list, visit the home page
17   * at:
18   *
19   *      http://www.transcriptome.ens.fr/doelan
20   */
21  
22  
23  package fr.ens.transcriptome.doelan.data;
24  
25  import java.io.File;
26  import java.net.MalformedURLException;
27  import java.net.URL;
28  
29  import org.apache.log4j.Logger;
30  
31  import fr.ens.transcriptome.nividic.platform.PlatformRegistery;
32  
33  /***
34   * This class define a location to a qualtity test suite.
35   * @author Laurent Jourdren
36   */
37  public class QualityTestSuiteURL {
38  
39    //For log system
40    private static Logger log = Logger.getLogger(QualityTestSuiteURL.class);
41  
42    private String name;
43  
44    private URL url;
45  
46    //
47    // Getters
48    //
49  
50    /***
51     * Get the name of the TestSuiteURL
52     * @return The name of the TestSuiteURL
53     */
54    public String getName() {
55      return name;
56    }
57  
58    /***
59     * Get the URL of the test TestSuiteURL
60     * @return the URL of the test suite
61     */
62    public URL getURL() {
63      return url;
64    }
65  
66    //
67    // Setters
68    //
69  
70    /***
71     * Set the name of the TestSuiteURL
72     * @param name Name to set
73     */
74    public void setName(final String name) {
75      this.name = name;
76    }
77  
78    /***
79     * Set the url of the TestSuite
80     * @param url URL to set
81     */
82    public void setURL(final URL url) {
83      this.url = url;
84    }
85  
86    /***
87     * Set the url of the TestSuite
88     * @param url URL to set
89     */
90    public void setUrl(final String url) {
91  
92      if (url == null)
93        return;
94  
95      try {
96        if (url.startsWith("file:") || url.startsWith("ftp:")
97            || url.startsWith("http:"))
98          this.url = new URL(url);
99        else {
100         File f = new File(url);
101         if (!f.isAbsolute())
102           f = new File(PlatformRegistery.getConfDirectory() + File.separator + url);
103         if (f.exists() && !f.isDirectory()) {
104           //this.url = new
105           // URL("file://"+URLEncoder.encode(f.getAbsolutePath(),"UTF-8"));
106           this.url = f.toURL();
107         }
108 
109       }
110     } catch (MalformedURLException e) {
111       log.error("Malformed URL: " + e);
112       return;
113     }
114   }
115 
116 }