- Timestamp:
- 2009-04-17T19:44:48+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/collection/Collection.java
r18945 r19041 182 182 public String getName() { 183 183 return file.getParentFile().getName(); 184 } 185 186 /** @return just the name of the collection group if any, else returns "" */ 187 public String getCollectionGroupName() { 188 String groupAndColName = getGroupWithName(true); 189 190 int slash = groupAndColName.indexOf('/'); 191 if(slash == -1) { 192 return ""; 193 } else { // remove the colName from the end, to get the groupName 194 return groupAndColName.substring(0, slash); 195 } 196 } 197 198 /** 199 * If the collection is part of a collection group, returns the 200 * colgroupname/colname, else returns the colname. 201 * If url = true, then returns the sub-path as a URL (containing / only), 202 * and if url = false, then the sub-path is returned in filepath form 203 * (\ or /, depending on the OS). 204 * @return collection-group-name/collection-name 205 */ 206 public String getGroupWithName(boolean url) { 207 // Subtracting collect dir's path from the current collection's path 208 209 String groupAndCol; 210 String collectDir = Gatherer.getCollectDirectoryPath(); 211 String currentCollDir = file.getParentFile().getAbsolutePath(); 212 213 if(currentCollDir.startsWith(collectDir)) { 214 groupAndCol = currentCollDir.substring(collectDir.length()); 215 } else { 216 // shouldn't happen, but in case it does, just return the collection name. 217 System.err.println("Current collection " + currentCollDir + " is not located inside collectdir " + "collectDir"); 218 groupAndCol = getName(); 219 } 220 221 if(url) { 222 groupAndCol = groupAndCol.replace('\\', '/'); 223 } 224 225 return groupAndCol; 184 226 } 185 227
Note:
See TracChangeset
for help on using the changeset viewer.