source: trunk/gli/src/org/greenstone/gatherer/metadata/DocXMLFileManager.java@ 8622

Last change on this file since 8622 was 8164, checked in by mdewsnip, 20 years ago

Added headers at the top of each file.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/**
2 *############################################################################
3 * A component of the Greenstone Librarian Interface, part of the Greenstone
4 * digital library suite from the New Zealand Digital Library Project at the
5 * University of Waikato, New Zealand.
6 *
7 * Author: Michael Dewsnip, NZDL Project, University of Waikato, NZ
8 *
9 * Copyright (C) 2004 New Zealand Digital Library Project
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *############################################################################
25 */
26
27package org.greenstone.gatherer.metadata;
28
29
30import java.io.*;
31import java.util.*;
32
33
34/** This class is a static class that manages the doc.xml files */
35public class DocXMLFileManager
36{
37 static private ArrayList doc_xml_files = new ArrayList();
38
39
40 static public void clearDocXMLFiles()
41 {
42 doc_xml_files.clear();
43 }
44
45
46 static public ArrayList getMetadataExtractedFromFile(File file)
47 {
48 // Build up a list of metadata values extracted from this file
49 ArrayList metadata_values = new ArrayList();
50
51 // Look at each loaded doc.xml file to see if any have extracted metadata for this file
52 for (int i = 0; i < doc_xml_files.size(); i++) {
53 DocXMLFile doc_xml_file = (DocXMLFile) doc_xml_files.get(i);
54 metadata_values.addAll(doc_xml_file.getMetadataExtractedFromFile(file));
55 }
56
57 return metadata_values;
58 }
59
60
61 static public void loadDocXMLFiles(File directory)
62 {
63 // Make sure the directory (archives) exists
64 if (directory.exists() == false) {
65 return;
66 }
67
68 // Look recursively at each subfile of the directory for doc.xml files
69 File[] directory_files = directory.listFiles();
70 for (int i = 0; i < directory_files.length; i++) {
71 File child_file = directory_files[i];
72 if (child_file.isDirectory()) {
73 loadDocXMLFiles(child_file);
74 }
75 else if (child_file.getName().equals("doc.xml")) {
76 loadDocXMLFile(child_file);
77 }
78 }
79 }
80
81
82 static private void loadDocXMLFile(File doc_xml_file_file)
83 {
84 DocXMLFile doc_xml_file = new DocXMLFile(doc_xml_file_file.getAbsolutePath());
85 doc_xml_file.skimFile();
86 doc_xml_files.add(doc_xml_file);
87 }
88}
Note: See TracBrowser for help on using the repository browser.