Changeset 23433 for main/trunk/gli/src/org/greenstone/gatherer/metadata
- Timestamp:
- 2010-12-09T22:27:33+13:00 (13 years ago)
- Location:
- main/trunk/gli/src/org/greenstone/gatherer/metadata
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataValueTableModel.java
r13398 r23433 139 139 140 140 MetadataValueTableEntry metadata_value_table_entry = (MetadataValueTableEntry) metadata_value_table_entries.get(row); 141 142 if(metadata_value_table_entry == null) { 143 System.err.println("\n@@@@@ MetadataValueTableModel.getValueAt(): metadata_value_table_entry is unexpectedly null!\n"); 144 return null; 145 } 146 141 147 if (col == 0 && metadata_value_table_entry.isInheritedMetadata()) { 142 148 return metadata_value_table_entry.getFolderMetadataInheritedFrom(); … … 213 219 { 214 220 MetadataValueTableEntry metadata_value_table_entry = getMetadataValueTableEntry(row); 215 221 if(metadata_value_table_entry == null) { 222 System.err.println("\n@@@@@ MetadataValueTableModel.setValueAt(): metadata_value_table_entry is unexpectedly null!\n"); 223 return; 224 } 225 216 226 // If nothing has changed no action is necessary 217 227 String old_metadata_value = metadata_value_table_entry.getFullValue(); … … 252 262 MetadataValueTreeNode metadata_value_tree_node = metadata_element.addMetadataValue((String) new_metadata_value); 253 263 MetadataValue metadata_value = new MetadataValue(metadata_element, metadata_value_tree_node); 254 metadata_value.setIsAccumulatingMetadata(true); 264 metadata_value.setIsAccumulatingMetadata(true); 255 265 (new AppendMetadataTask(metadata_value)).run(); 256 266 } -
main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFile.java
r23394 r23433 31 31 import java.util.*; 32 32 import org.greenstone.gatherer.DebugStream; 33 import org.greenstone.gatherer.collection.CollectionTreeNode; 33 34 import org.greenstone.gatherer.util.XMLTools; 34 35 import org.w3c.dom.*; … … 45 46 static final private String METADATA_ELEMENT = "Metadata"; 46 47 48 /** Special metadata field: the filename encoding is a unique sort of metadata in 49 * that it is not just information stored with a collection file, but also needs to 50 * be applied in real-time to the collection file (to its filename) for display. */ 51 static final public String FILENAME_ENCODING_METADATA = "gs.filenameEncoding"; 52 47 53 // To speed things up a bit we keep the last accessed metadata.xml file in memory 48 54 static private File loaded_file = null; … … 57 63 58 64 59 public void addMetadata( File file, ArrayList metadata_values)65 public void addMetadata(CollectionTreeNode file_node, ArrayList metadata_values) 60 66 { 61 67 // If this metadata.xml file isn't the one currently loaded, load it now … … 76 82 77 83 // Determine the file's path relative to the location of the metadata.xml file 78 String metadata_xml_file_directory_path = getParentFile().getAbsolutePath();79 String file_relative_path = file .getAbsolutePath().substring(metadata_xml_file_directory_path.length());80 if (file_relative_path.startsWith(File .separator)) {81 file_relative_path = file_relative_path.substring(File .separator.length());84 String metadata_xml_file_directory_path = FilenameEncoding.fileToURLEncoding(getParentFile()); 85 String file_relative_path = file_node.getURLEncodedFilePath().substring(metadata_xml_file_directory_path.length()); 86 if (file_relative_path.startsWith(FilenameEncoding.URL_FILE_SEPARATOR)) { 87 file_relative_path = file_relative_path.substring(FilenameEncoding.URL_FILE_SEPARATOR.length()); 82 88 } 83 89 … … 127 133 appropriate_fileset_element.appendChild(new_description_element); 128 134 135 // add the fileset element for .* at the top: especially important for 136 // non-accumulating (and override mode) meta. Other type fileset elements can be appended 129 137 if(file_path_regexp.equals(DIRECTORY_FILENAME)) { 130 loaded_file_document.getDocumentElement().insertBefore(appropriate_fileset_element, loaded_file_document.getDocumentElement().getFirstChild()); 138 loaded_file_document.getDocumentElement().insertBefore(appropriate_fileset_element, 139 loaded_file_document.getDocumentElement().getFirstChild()); 131 140 } else { 132 141 loaded_file_document.getDocumentElement().appendChild(appropriate_fileset_element); … … 147 156 metadata_value_string = metadata_value_string.replaceAll("\\]", "]"); 148 157 158 // the gs.filenameEncoding metadata is unique in that, when added, removed or 159 // changed, it must be applied on the file(name) whose metadata has been adjusted 160 if(metadata_element_name_full.equals(FILENAME_ENCODING_METADATA)) { 161 metadata_value_string = processFilenameEncoding(file_path_regexp, 162 file_node, metadata_value_string, false); 163 // true only if removing meta 164 } 165 149 166 // Check if this piece of metadata has already been assigned to this FileSet element 150 167 boolean metadata_already_assigned = false; … … 156 173 String current_metadata_element_name_full = current_metadata_element.getAttribute("name"); 157 174 if (current_metadata_element_name_full.equals(metadata_element_name_full)) { 158 // if the metadata must not accumulate, then edit t ehcurrent value175 // if the metadata must not accumulate, then edit the current value 159 176 if (!metadata_value.isAccumulatingMetadata()) { 160 177 XMLTools.setNodeText(current_metadata_element, metadata_value_string); … … 196 213 197 214 198 public ArrayList getMetadataAssignedToFile(File file )215 public ArrayList getMetadataAssignedToFile(File file, boolean fileEncodingOnly) 199 216 { 200 217 // If this metadata.xml file isn't the one currently loaded, load it now … … 214 231 } 215 232 216 // Determine the file's path relative to the location of the metadata.xml file 233 // Determine the file's path relative to the location of the metadata.xml file 234 String file_relative_path = FilenameEncoding.fileToURLEncoding(file); 217 235 File metadata_xml_file_directory = getParentFile(); 218 String file_relative_path = file.getAbsolutePath().substring(metadata_xml_file_directory.getAbsolutePath().length()); 219 if (file_relative_path.startsWith(File.separator)) { 220 file_relative_path = file_relative_path.substring(File.separator.length()); 236 String metadata_xml_file_directory_path = FilenameEncoding.fileToURLEncoding(metadata_xml_file_directory); 237 file_relative_path = file_relative_path.substring(metadata_xml_file_directory_path.length()); 238 239 if (file_relative_path.startsWith(FilenameEncoding.URL_FILE_SEPARATOR)) { 240 file_relative_path = file_relative_path.substring(FilenameEncoding.URL_FILE_SEPARATOR.length()); 221 241 } 222 242 … … 255 275 256 276 // This fileset specifies metadata for the folder the file is in 257 if (file_relative_path.startsWith(current_filename_element_value + File .separator)) {277 if (file_relative_path.startsWith(current_filename_element_value + FilenameEncoding.URL_FILE_SEPARATOR)) { 258 278 current_fileset_matches = true; 259 279 folder_metadata_inherited_from = new File(metadata_xml_file_directory, current_filename_element_value); … … 272 292 Element current_metadata_element = (Element) metadata_elements_nodelist.item(k); 273 293 String metadata_element_name_full = current_metadata_element.getAttribute("name"); 294 // if we're only looking for fileEncoding metadata and this isn't it, skip to the next 295 if(fileEncodingOnly && !metadata_element_name_full.equals(FILENAME_ENCODING_METADATA)) { 296 continue; 297 } 274 298 String metadata_set_namespace = MetadataTools.getMetadataSetNamespace(metadata_element_name_full); 275 299 … … 335 359 336 360 337 public void removeMetadata( File file, ArrayList metadata_values)361 public void removeMetadata(CollectionTreeNode file_node, ArrayList metadata_values) 338 362 { 339 363 // If this metadata.xml file isn't the one currently loaded, load it now … … 354 378 355 379 // Determine the file's path relative to the location of the metadata.xml file 356 String metadata_xml_file_directory_path = getParentFile().getAbsolutePath();357 String file_relative_path = file .getAbsolutePath().substring(metadata_xml_file_directory_path.length());358 if (file_relative_path.startsWith(File .separator)) {359 file_relative_path = file_relative_path.substring(File .separator.length());380 String metadata_xml_file_directory_path = FilenameEncoding.fileToURLEncoding(getParentFile()); 381 String file_relative_path = file_node.getURLEncodedFilePath().substring(metadata_xml_file_directory_path.length()); 382 if (file_relative_path.startsWith(FilenameEncoding.URL_FILE_SEPARATOR)) { 383 file_relative_path = file_relative_path.substring(FilenameEncoding.URL_FILE_SEPARATOR.length()); 360 384 } 361 385 … … 422 446 String current_metadata_value_string = XMLTools.getElementTextValue(current_metadata_element); 423 447 if (current_metadata_value_string.equals(metadata_value_string)) { 448 424 449 // Remove this Metadata element 425 450 current_metadata_element.getParentNode().removeChild(current_metadata_element); 426 451 452 // the gs.filenameEncoding metadata is unique in that, when added, removed or 453 // changed, it must be applied on the file(name) whose metadata has been adjusted 454 if(current_metadata_element_name_full.equals(FILENAME_ENCODING_METADATA)) { 455 456 // metadata_value_string will hereafter be the inherited gs.FilenameEncoding 457 // metadata (if any), now that the value at this level has been removed 458 metadata_value_string = processFilenameEncoding(file_path_regexp, 459 file_node, "", true); // true only if *removing* this meta 460 } 461 427 462 // If there are no Metadata elements left now, remove the (empty) FileSet element 428 463 if (metadata_elements_nodelist.getLength() == 0) { … … 441 476 442 477 443 public void replaceMetadata( File file, MetadataValue old_metadata_value, MetadataValue new_metadata_value)478 public void replaceMetadata(CollectionTreeNode file_node, MetadataValue old_metadata_value, MetadataValue new_metadata_value) 444 479 { 445 480 // If this metadata.xml file isn't the one currently loaded, load it now … … 460 495 461 496 // Determine the file's path relative to the location of the metadata.xml file 462 String metadata_xml_file_directory_path = getParentFile().getAbsolutePath();463 String file_relative_path = file .getAbsolutePath().substring(metadata_xml_file_directory_path.length());464 if (file_relative_path.startsWith(File .separator)) {465 file_relative_path = file_relative_path.substring(File .separator.length());497 String metadata_xml_file_directory_path = FilenameEncoding.fileToURLEncoding(getParentFile()); 498 String file_relative_path = file_node.getURLEncodedFilePath().substring(metadata_xml_file_directory_path.length()); 499 if (file_relative_path.startsWith(FilenameEncoding.URL_FILE_SEPARATOR)) { 500 file_relative_path = file_relative_path.substring(FilenameEncoding.URL_FILE_SEPARATOR.length()); 466 501 } 467 502 … … 541 576 // If the new metadata value already existed, remove the original value 542 577 if (new_metadata_value_already_exists) { 543 metadata_element_to_edit.getParentNode().removeChild(metadata_element_to_edit); 578 if(metadata_element_to_edit != null) { //????????? 579 metadata_element_to_edit.getParentNode().removeChild(metadata_element_to_edit); 580 } else { 581 System.err.println("ERROR MetadataXMLFile: metadata_element_to_edit is null"); 582 } 544 583 } 545 584 // Otherwise replace the old value with the new value 546 585 // Ensure metadata_element_to_edit isn't null (may occur when multiple files are selected) 547 586 else if (metadata_element_to_edit != null) { 587 588 // the gs.filenameEncoding metadata is unique in that, when added, removed or 589 // changed, it must be applied on the file(name) whose metadata has been adjusted 590 if(metadata_element_name_full.equals(FILENAME_ENCODING_METADATA)) { 591 new_metadata_value_string = processFilenameEncoding(file_path_regexp, file_node, new_metadata_value_string, false); 592 // true only if removing meta 593 } 548 594 XMLTools.setElementTextValue(metadata_element_to_edit, new_metadata_value_string); 549 595 } … … 649 695 } 650 696 } 697 698 /** 699 * The gs.filenameEncoding metadata is unique in that, when added, removed or 700 * replaced, it must be applied on the file(name) whose metadata has been 701 * adjusted. 702 * This method handles all that, given the regular expression or filepath name 703 * to match on (.* matches subdirectories), the affected fileNode, the new 704 * encoding value and whether a new encoding value has been added/an existing 705 * one has been replaced or whether the encoding metadata has been removed. 706 * The new adjusted value for the encoding metadata is returned. 707 * 708 * MetadataXMLFileManager maintains a hashmap of (URL-encoded filepaths, encoding) 709 * to allow fast access to previously assigned gs.filenameEncoding metadata (if 710 * any) for each file. This hashmap also needs to be updated, but this update 711 * is complicated by the fact that it concerns regular expressions that could 712 * affect multiple filenames. 713 */ 714 public String processFilenameEncoding(String file_path_regexp, CollectionTreeNode file_node, 715 String encoding_metadata_value, boolean removingMetadata) 716 { 717 if(!FilenameEncoding.MULTIPLE_FILENAME_ENCODINGS_SUPPORTED) { 718 return encoding_metadata_value; 719 } 720 721 // Work out this filenode's new encoding and apply it: 722 723 if(removingMetadata) { // encoding_metadata_value = "" 724 // gs.filenameEncoding metadata being removed, work out 725 // any inherited metadata to replace it with in the meta-table 726 encoding_metadata_value = FilenameEncoding.getInheritedFilenameEncoding( 727 file_node.getURLEncodedFilePath(), file_node.getFile()); 728 // should be canonical encoding already 729 } 730 else if(!encoding_metadata_value.equals("")) { 731 // if adding or replacing filename encoding, 732 // get the canonical encoding name for this alias 733 encoding_metadata_value = FilenameEncoding.canonicalEncodingName(encoding_metadata_value); 734 } 735 // Reencode the display of this filenode only as any affected 736 // childnodes will be reencoded on FileNode.refreshDescendantEncodings() 737 file_node.reencodeDisplayName(encoding_metadata_value); 738 739 740 // Whether removing or adding/replacing the file's gs.filename encoding meta, 741 // store this in the file-to-encoding map for fast access, since the map stores 742 // empty string values when no meta has been assigned at this file level. 743 // In the case of removingMetadata, the value stored will be the fallback value 744 745 String urlpath = file_node.getURLEncodedFilePath(); 746 if(removingMetadata) { 747 // remove it from the map instead of inserting "", so that when folders in the collectiontree 748 // are being deleted or shifted, the removemetada (and addmetadata) calls that get fired 749 // for each affected filenodes does not cause the undesirable effect of multiple "" to be 750 // entered into the filename-to-encoding map for filepaths that no longer exist . 751 FilenameEncoding.map.remove(urlpath); 752 } else { // for adding and replacing, put the encoding into the map (also replaces any existing encoding for it) 753 FilenameEncoding.map.put(urlpath, encoding_metadata_value); 754 } 755 756 // If new folder-level metadata (or metadata for a set of files fitting a pattern) has been 757 // assigned, the file_to_encodings map will be cleared for all descendant folders and files, 758 // so that these can be re-calculated upon refreshing the visible parts of the CollectionTree. 759 // Mark the state as requiring a refresh of the CollectionTree. 760 // This next step also serves to prevent the MetadataValueTableModel from trying to update 761 // itself while a refresh (involving re-encoding of filenames of visible nodes) is in progress. 762 FilenameEncoding.setRefreshRequired(true); 763 764 return encoding_metadata_value; 765 } 651 766 } -
main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java
r23410 r23433 90 90 if (current_file_directory_path.equals(metadata_xml_file.getParentFile().getAbsolutePath())) { 91 91 applicable_metadata_xml_file_found = true; 92 metadata_xml_file.addMetadata( current_file, metadata_values);92 metadata_xml_file.addMetadata(file_nodes[i], metadata_values); 93 93 if (!modified_metadata_xml_files.contains(metadata_xml_file)) { 94 94 modified_metadata_xml_files.add(metadata_xml_file); … … 107 107 108 108 // ...and add the metadata 109 new_metadata_xml_file.addMetadata( current_file, metadata_values);109 new_metadata_xml_file.addMetadata(file_nodes[i], metadata_values); 110 110 if (!modified_metadata_xml_files.contains(new_metadata_xml_file)) { 111 111 modified_metadata_xml_files.add(new_metadata_xml_file); … … 160 160 161 161 // Get the metadata assigned to the specified file from the applicable metadata.xml files 162 ArrayList assigned_metadata = getMetadataAssignedToFile(file, applicable_metadata_xml_files );162 ArrayList assigned_metadata = getMetadataAssignedToFile(file, applicable_metadata_xml_files, false); 163 163 164 164 // Remove any folder-level metadata … … 173 173 174 174 175 /** Returns the metadata assigned to a file inside the collection, excluding folder-level/inherited metadata. */ 176 static public ArrayList getMetadataAssignedDirectlyToFile(File file) 177 { 178 return getMetadataAssignedDirectlyToFile(file, false); 179 } 180 175 181 /** Returns the metadata assigned to a file inside the collection, excluding folder-level/inherited metadata. */ 176 static public ArrayList getMetadataAssignedDirectlyToFile(File file) 177 { 178 // Get all the metadata assigned to the specified file... 179 ArrayList assigned_metadata = getMetadataAssignedToFile(file); 180 181 // ...then remove any folder-level metadata 182 for (int i = assigned_metadata.size() - 1; i >= 0; i--) { 183 if (((MetadataValue) assigned_metadata.get(i)).isInheritedMetadata()) { 184 assigned_metadata.remove(i); 185 } 186 } 187 188 return assigned_metadata; 189 } 190 182 static public ArrayList getMetadataAssignedDirectlyToFile(File file, boolean filenameEncodingMetaOnly) 183 { 184 185 // Get all the metadata assigned to the specified file... 186 ArrayList assigned_metadata = getMetadataAssignedToFile(file, filenameEncodingMetaOnly); 187 188 // ...then remove any folder-level metadata 189 for (int i = assigned_metadata.size() - 1; i >= 0; i--) { 190 if (((MetadataValue) assigned_metadata.get(i)).isInheritedMetadata()) { 191 assigned_metadata.remove(i); 192 } 193 } 194 195 return assigned_metadata; 196 /* 197 // Get all the metadata assigned to the specified file... 198 // Build up a list of applicable metadata.xml files - which in this case 199 // is exclusively the metadata file at this file/folder's own level. 200 ArrayList applicable_metadata_xml_files = new ArrayList(); 201 202 // Find the metadata.xml file (if any) that is at the same level as the file 203 String file_directory_path = (file.isDirectory() ? file : file.getParentFile()).getAbsolutePath() + File.separator; 204 for (int i = 0; i < metadata_xml_files.size(); i++) { 205 MetadataXMLFile metadata_xml_file = (MetadataXMLFile) metadata_xml_files.get(i); 206 207 if (file_directory_path.equals(metadata_xml_file.getParentFile().getAbsolutePath() + File.separator)) { 208 //System.err.println("Found metadata_xml_file: " + metadata_xml_file); 209 applicable_metadata_xml_files.add(metadata_xml_file); 210 } 211 } 212 213 if(applicable_metadata_xml_files.size() == 0) { 214 return new ArrayList(0); 215 } 216 217 // Return the metadata assigned to the specified file from the applicable metadata.xml files 218 return getMetadataAssignedToFile(file, applicable_metadata_xml_files, filenameEncodingMetaOnly); 219 */ 220 } 221 191 222 192 223 /** Returns all the metadata assigned to a file inside the collection. */ 193 224 static public ArrayList getMetadataAssignedToFile(File file) 225 { 226 return getMetadataAssignedToFile(file, false); 227 } 228 229 /** Returns all the metadata assigned to a file inside the collection (or 230 * just gs.filenameEncoding if parameter filenameEncodingMetaOnly is true), 231 * including folder-level/inherited metadata. 232 */ 233 static public ArrayList getMetadataAssignedToFile(File file, boolean filenameEncodingMetaOnly) 194 234 { 195 235 // Build up a list of applicable metadata.xml files … … 207 247 } 208 248 209 // sort the metadataxml files in order starting from those in the249 // Sort the metadataxml files in order starting from those in the 210 250 // topmost folders down to the one in the lowest level folder. 211 251 Collections.sort(applicable_metadata_xml_files, metadataXMLFileComparator); 212 252 // Return the metadata assigned to the specified file from the applicable metadata.xml files 213 return getMetadataAssignedToFile(file, applicable_metadata_xml_files); 214 } 215 216 217 static private ArrayList getMetadataAssignedToFile(File file, ArrayList applicable_metadata_xml_files) 253 return getMetadataAssignedToFile(file, applicable_metadata_xml_files, filenameEncodingMetaOnly); 254 } 255 256 // package access method 257 static ArrayList getMetadataAssignedToFile(File file, ArrayList applicable_metadata_xml_files, 258 boolean filenameEncodingMetaOnly) 218 259 { 219 260 // Build up a list of metadata values assigned to this file … … 225 266 DebugStream.println("Applicable metadata.xml file: " + metadata_xml_file); 226 267 227 ArrayList metadata_values = metadata_xml_file.getMetadataAssignedToFile(file );268 ArrayList metadata_values = metadata_xml_file.getMetadataAssignedToFile(file, filenameEncodingMetaOnly); 228 269 for (int j = 0; j < metadata_values.size(); j++) { 229 270 MetadataValue metadata_value = (MetadataValue) metadata_values.get(j); … … 316 357 // This metadata.xml file is only potentially applicable if it is above or at the same level as the file 317 358 if (current_file_directory_path.startsWith(metadata_xml_file.getParentFile().getAbsolutePath())) { 318 metadata_xml_file.removeMetadata( current_file, metadata_values);359 metadata_xml_file.removeMetadata(file_nodes[i], metadata_values); 319 360 if (!modified_metadata_xml_files.contains(metadata_xml_file)) { 320 361 modified_metadata_xml_files.add(metadata_xml_file); … … 350 391 // This metadata.xml file is only applicable if it is at the same level as the file 351 392 if (current_file_directory_path.equals(metadata_xml_file.getParentFile().getAbsolutePath())) { 352 metadata_xml_file.replaceMetadata( current_file, old_metadata_value, new_metadata_value);393 metadata_xml_file.replaceMetadata(file_nodes[i], old_metadata_value, new_metadata_value); 353 394 if (!modified_metadata_xml_files.contains(metadata_xml_file)) { 354 395 modified_metadata_xml_files.add(metadata_xml_file); … … 399 440 400 441 401 402 * Comparator to order MetadataXMLFiles in ascending order from403 * those in a higher level folder to those in a lower level folder404 * It is based on the assumption that all MetadataXMLFiles sent to405 * it to compare will be linear descendants of one toplevel folder406 * E.g. /A/metadata.xml, /A/B/metadata.xml, /A/B/C/D/metadata.xml.407 * In other words, that each is a substring of one otheruntil we408 * get to the toplevel folder.409 410 411 412 public int compare(Object o1, Object o2) {413 414 return -1;415 416 return 1;417 418 419 420 421 422 423 424 // if 1 is a prefix2, then 1 < 2 in the ordering (1 comes before 2)425 426 return -1;427 428 return 1;429 430 // unlikely that the metadata.xml files will be the same431 // or that neither is a prefix of the other432 return filename1.compareTo(filename2); // sorts in ascending order433 434 435 436 437 438 439 return false;440 441 442 443 444 445 446 442 /** 443 * Comparator to order MetadataXMLFiles in ascending order from 444 * those in a higher level folder to those in a lower level folder 445 * It is based on the assumption that all MetadataXMLFiles sent to 446 * it to compare will be linear descendants of one toplevel folder 447 * E.g. /A/metadata.xml, /A/B/metadata.xml, /A/B/C/D/metadata.xml. 448 * In other words, that each is a substring of one of the others until we 449 * the toplevel folder is reached. 450 */ 451 private static class MetadataXMLFileComparator implements Comparator { 452 453 public int compare(Object o1, Object o2) { 454 if(!(o1 instanceof MetadataXMLFile)) { 455 return -1; 456 } else if (!(o2 instanceof MetadataXMLFile)) { 457 return 1; 458 } 459 460 // Both are MetadataXMLFiles objects. Remove the terminating 461 // "metadata.xml" from their filenames to get their containing folder 462 String filename1 = ((MetadataXMLFile)o1).getParentFile().getAbsolutePath(); 463 String filename2 = ((MetadataXMLFile)o2).getParentFile().getAbsolutePath(); 464 465 // if 1 is a prefix of 2, then 1 < 2 in the ordering (1 comes before 2) 466 if(filename2.startsWith(filename1)) { 467 return -1; 468 } else if(filename1.startsWith(filename2)) { 469 return 1; 470 } else { 471 // unlikely that the metadata.xml files will be the same 472 // or that neither is a prefix of the other 473 return filename1.compareTo(filename2); // sorts in ascending order 474 } 475 476 } 477 478 public boolean equals(Object obj) { 479 if(!(obj instanceof MetadataXMLFileComparator)) { 480 return false; 481 } 482 483 // else it is the same sort of comparator 484 return true; 485 } 486 487 } 447 488 448 489 }
Note:
See TracChangeset
for help on using the changeset viewer.