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 |
|
---|
27 | package org.greenstone.gatherer.metadata;
|
---|
28 |
|
---|
29 |
|
---|
30 | import java.io.*;
|
---|
31 |
|
---|
32 |
|
---|
33 | /** This class represents one metadata (element, value) pair */
|
---|
34 | public class MetadataValue
|
---|
35 | implements Comparable
|
---|
36 | {
|
---|
37 | /** The folder that this piece of metadata was inherited from, if applicable */
|
---|
38 | private File folder_metadata_inherited_from = null;
|
---|
39 | private MetadataElement metadata_element = null;
|
---|
40 | private MetadataValueTreeNode metadata_value_tree_node = null;
|
---|
41 | private boolean is_accumulating_metadata = false;
|
---|
42 | /** Whether this metadata applies to only one file (ie. there are no wildcards in the FileSet value) */
|
---|
43 | private boolean is_one_file_only_metadata = true;
|
---|
44 |
|
---|
45 |
|
---|
46 | public MetadataValue(MetadataElement metadata_element, MetadataValueTreeNode metadata_value_tree_node)
|
---|
47 | {
|
---|
48 | this.metadata_element = metadata_element;
|
---|
49 | this.metadata_value_tree_node = metadata_value_tree_node;
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
53 | public int compareTo(Object metadata_value_object)
|
---|
54 | {
|
---|
55 | MetadataValue metadata_value = (MetadataValue) metadata_value_object;
|
---|
56 |
|
---|
57 | // First compare the metadata elements
|
---|
58 | int c = MetadataSetManager.compareMetadataElements(this.getMetadataElement(), metadata_value.getMetadataElement());
|
---|
59 | if (c != 0) {
|
---|
60 | return c;
|
---|
61 | }
|
---|
62 |
|
---|
63 | // Then use the metadata values
|
---|
64 | return this.getFullValue().compareTo(metadata_value.getFullValue());
|
---|
65 | }
|
---|
66 |
|
---|
67 |
|
---|
68 | public File getFolderMetadataInheritedFrom()
|
---|
69 | {
|
---|
70 | return folder_metadata_inherited_from;
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 | public MetadataElement getMetadataElement()
|
---|
75 | {
|
---|
76 | return metadata_element;
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | public String getFullValue()
|
---|
81 | {
|
---|
82 | return metadata_value_tree_node.getFullValue();
|
---|
83 | }
|
---|
84 |
|
---|
85 |
|
---|
86 | public String getValue()
|
---|
87 | {
|
---|
88 | return metadata_value_tree_node.getValue();
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 | public MetadataValueTreeNode getMetadataValueTreeNode()
|
---|
93 | {
|
---|
94 | return metadata_value_tree_node;
|
---|
95 | }
|
---|
96 |
|
---|
97 |
|
---|
98 | public void inheritsMetadataFromFolder(File folder_metadata_inherited_from)
|
---|
99 | {
|
---|
100 | this.folder_metadata_inherited_from = folder_metadata_inherited_from;
|
---|
101 | }
|
---|
102 |
|
---|
103 |
|
---|
104 | public boolean isAccumulatingMetadata()
|
---|
105 | {
|
---|
106 | return is_accumulating_metadata;
|
---|
107 | }
|
---|
108 |
|
---|
109 |
|
---|
110 | public boolean isInheritedMetadata()
|
---|
111 | {
|
---|
112 | return (folder_metadata_inherited_from != null);
|
---|
113 | }
|
---|
114 |
|
---|
115 |
|
---|
116 | public boolean isOneFileOnlyMetadata()
|
---|
117 | {
|
---|
118 | return is_one_file_only_metadata;
|
---|
119 | }
|
---|
120 |
|
---|
121 |
|
---|
122 | public void setIsAccumulatingMetadata(boolean is_accumulating_metadata)
|
---|
123 | {
|
---|
124 | this.is_accumulating_metadata = is_accumulating_metadata;
|
---|
125 | }
|
---|
126 |
|
---|
127 |
|
---|
128 | public void setIsOneFileOnlyMetadata(boolean is_one_file_only_metadata)
|
---|
129 | {
|
---|
130 | this.is_one_file_only_metadata = is_one_file_only_metadata;
|
---|
131 | }
|
---|
132 | }
|
---|