Ignore:
Timestamp:
2003-05-27T15:40:47+12:00 (21 years ago)
Author:
mdewsnip
Message:

Fixed tabbing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/util/GURL.java

    r4293 r4364  
    6060 */
    6161public class GURL
    62     implements Cloneable, Serializable {
     62    implements Cloneable, Serializable {
    6363
    64     private Integer type;
     64    private Integer type;
    6565
    66     private URL url;
     66    private URL url;
    6767
    68     private String file;
    69     private String host;
    70     private String path;
    71     private String protocol;
    72     private String title = "empty";
     68    private String file;
     69    private String host;
     70    private String path;
     71    private String protocol;
     72    private String title = "empty";
    7373
    74     /** This Vector maintains a record of the url links from within
    75       * this resource, and their type (EXTERNAL vs INTERNAL). Internal
    76       * links can be 'hidden' from the user if desired, or a user can
    77       * opt to have all internal links automatically moved into a
    78       * collection if the page that depends upon them is moved. <BR>
    79       * Each entry in the vector is of the form.
    80       * links[i] = String url
    81       * links[i+1] = int type
    82       */
    83     private Vector links;
     74    /** This Vector maintains a record of the url links from within
     75     * this resource, and their type (EXTERNAL vs INTERNAL). Internal
     76     * links can be 'hidden' from the user if desired, or a user can
     77     * opt to have all internal links automatically moved into a
     78     * collection if the page that depends upon them is moved. <BR>
     79     * Each entry in the vector is of the form.
     80     * links[i] = String url
     81     * links[i+1] = int type
     82     */
     83    private Vector links;
    8484
    85     /* Static Integer identifiers for ease of use. */
    86     static public Integer INTERNAL = new Integer(0);
    87     static public Integer EXTERNAL = new Integer(1);
     85    /* Static Integer identifiers for ease of use. */
     86    static public Integer INTERNAL = new Integer(0);
     87    static public Integer EXTERNAL = new Integer(1);
    8888
    89     public GURL(String url_str) {
    90           this(url_str, GURL.EXTERNAL);
    91     }
     89    public GURL(String url_str) {
     90    this(url_str, GURL.EXTERNAL);
     91    }
    9292
    93     public GURL(URL url) {
    94           this(url, GURL.EXTERNAL);
    95     }
     93    public GURL(URL url) {
     94    this(url, GURL.EXTERNAL);
     95    }
    9696
    97     public GURL(URL url, Integer type) {
    98           this.type = type;
    99           this.url = url;
    100     }
     97    public GURL(URL url, Integer type) {
     98    this.type = type;
     99    this.url = url;
     100    }
    101101
    102     public GURL(String url_str, Integer type) {
    103           this.type = type;
     102    public GURL(String url_str, Integer type) {
     103    this.type = type;
    104104
    105           try {
    106                 if(!url_str.startsWith("file:") && url_str.indexOf("://") == -1) {
    107                      url_str = "http://" + url_str;
    108                 }
    109                 url = new URL(url_str);
    110           }
    111           catch (MalformedURLException e) {
     105    try {
     106        if(!url_str.startsWith("file:") && url_str.indexOf("://") == -1) {
     107        url_str = "http://" + url_str;
     108        }
     109        url = new URL(url_str);
     110    }
     111    catch (MalformedURLException e) {
    112112                // Fix it
    113           }
    114     }
     113    }
     114    }
    115115
    116     public void addLink(String url) {
    117           addLink(url, GURL.EXTERNAL);
    118     }
     116    public void addLink(String url) {
     117    addLink(url, GURL.EXTERNAL);
     118    }
    119119
    120     public void addLink(String url, Integer type) {
    121           if(links == null) {
    122                 links = new Vector();
    123           }
    124           links.add(url);
    125           links.add(type);
    126     }
     120    public void addLink(String url, Integer type) {
     121    if(links == null) {
     122        links = new Vector();
     123    }
     124    links.add(url);
     125    links.add(type);
     126    }
    127127
    128     /** Used by tree renderer to display name. So we'll only return the
    129       * filename.
    130       */
    131     public String getFile() {
    132           return parseFile(url.getFile());
    133     }
     128    /** Used by tree renderer to display name. So we'll only return the
     129     * filename.
     130     */
     131    public String getFile() {
     132    return parseFile(url.getFile());
     133    }
    134134
    135     public String getHost() {
    136           return url.getHost();
    137     }
     135    public String getHost() {
     136    return url.getHost();
     137    }
    138138
    139     public String getLocalFile() {
    140           String local_file = getPath() + File.separator + getFile();
    141           // Strip msdos roots if they're still there.
    142             while(local_file.indexOf(":") != -1) {
    143                 local_file = local_file.substring(0, local_file.indexOf(":")) + local_file.substring(local_file.indexOf(":") + 1);
    144             }
    145           return local_file;
    146     }
     139    public String getLocalFile() {
     140    String local_file = getPath() + File.separator + getFile();
     141    // Strip msdos roots if they're still there.
     142    while(local_file.indexOf(":") != -1) {
     143        local_file = local_file.substring(0, local_file.indexOf(":")) + local_file.substring(local_file.indexOf(":") + 1);
     144    }
     145    return local_file;
     146    }
    147147
    148     public String getPath() {
    149           return getHost() + parsePath(url.getFile());
    150     }
     148    public String getPath() {
     149    return getHost() + parsePath(url.getFile());
     150    }
    151151
    152     public String getProtocol() {
    153           String protocol = url.getProtocol();
    154           if(protocol.equals("file")) {
    155                 return protocol + ":";
    156           }
    157           return protocol + "://";
    158     }
     152    public String getProtocol() {
     153    String protocol = url.getProtocol();
     154    if(protocol.equals("file")) {
     155        return protocol + ":";
     156    }
     157    return protocol + "://";
     158    }
    159159
    160     public URL getURL() {
    161           return url;
    162     }
     160    public URL getURL() {
     161    return url;
     162    }
    163163
    164     public String toString() {
    165           return url.toString();
    166     }
     164    public String toString() {
     165    return url.toString();
     166    }
    167167
    168     public boolean valid() {
    169           return (url != null);
    170     }
     168    public boolean valid() {
     169    return (url != null);
     170    }
    171171
    172     private String parseFile(String raw) {
    173           if(raw != null && !raw.equals("")) {
     172    private String parseFile(String raw) {
     173    if(raw != null && !raw.equals("")) {
    174174                // Remove everything upto and including the last '/'
    175                 if(raw.indexOf("/") != -1) {
    176                      return raw.substring(raw.lastIndexOf("/") + 1);
    177                 }
    178           }
    179           return raw;
    180     }
     175        if(raw.indexOf("/") != -1) {
     176        return raw.substring(raw.lastIndexOf("/") + 1);
     177        }
     178    }
     179    return raw;
     180    }
    181181
    182     private String parsePath(String raw) {
    183           if(raw != null && !raw.equals("")) {
     182    private String parsePath(String raw) {
     183    if(raw != null && !raw.equals("")) {
    184184                // Remove everything after the last "/"
    185                 if(raw.indexOf("/") != -1) {
    186                      return raw.substring(0, raw.lastIndexOf("/"));
    187                 }
    188           }
    189           return raw;
    190     }
     185        if(raw.indexOf("/") != -1) {
     186        return raw.substring(0, raw.lastIndexOf("/"));
     187        }
     188    }
     189    return raw;
     190    }
    191191
    192192}
    193 
Note: See TracChangeset for help on using the changeset viewer.