Changeset 5186


Ignore:
Timestamp:
2003-08-19T14:01:43+12:00 (21 years ago)
Author:
kjdon
Message:

added methods for gettign and removing the last link in the path

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSPath.java

    r4020 r5186  
    8686    }
    8787
     88    /** removes the last name in the path
     89     *
     90     * @return the modified path
     91     */
     92    static public String removeLastLink(String path) {
     93    int i = path.lastIndexOf("/");
     94    if (i==-1) { // '/' not found - remove the whole path
     95        return "";
     96    }
     97    return path.substring(0, i); // remove the '/' char
     98    }
     99   
     100    static public String getLastLink(String path) {
     101    int i = path.lastIndexOf("/");
     102    if (i==-1) { // '/' not found - remove the whole path
     103        return path;
     104    }
     105    return path.substring(i+1); // remove the last link
     106    }
     107
     108   
    88109    static public String createPath(String [] links) {
    89110    String path = links[0];
Note: See TracChangeset for help on using the changeset viewer.