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 |
|
---|
43 |
|
---|
44 | public MetadataValue(MetadataElement metadata_element, MetadataValueTreeNode metadata_value_tree_node)
|
---|
45 | {
|
---|
46 | this.metadata_element = metadata_element;
|
---|
47 | this.metadata_value_tree_node = metadata_value_tree_node;
|
---|
48 | }
|
---|
49 |
|
---|
50 |
|
---|
51 | public int compareTo(Object metadata_value_object)
|
---|
52 | {
|
---|
53 | MetadataValue metadata_value = (MetadataValue) metadata_value_object;
|
---|
54 |
|
---|
55 | // First compare the metadata elements
|
---|
56 | int c = MetadataSetManager.compareMetadataElements(this.getMetadataElement(), metadata_value.getMetadataElement());
|
---|
57 | if (c != 0) {
|
---|
58 | return c;
|
---|
59 | }
|
---|
60 |
|
---|
61 | // Then use the metadata values
|
---|
62 | return this.getFullValue().compareTo(metadata_value.getFullValue());
|
---|
63 | }
|
---|
64 |
|
---|
65 |
|
---|
66 | public File getFolderMetadataInheritedFrom()
|
---|
67 | {
|
---|
68 | return folder_metadata_inherited_from;
|
---|
69 | }
|
---|
70 |
|
---|
71 |
|
---|
72 | public MetadataElement getMetadataElement()
|
---|
73 | {
|
---|
74 | return metadata_element;
|
---|
75 | }
|
---|
76 |
|
---|
77 |
|
---|
78 | public String getFullValue()
|
---|
79 | {
|
---|
80 | return metadata_value_tree_node.getFullValue();
|
---|
81 | }
|
---|
82 |
|
---|
83 |
|
---|
84 | public String getValue()
|
---|
85 | {
|
---|
86 | return metadata_value_tree_node.getValue();
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | public MetadataValueTreeNode getMetadataValueTreeNode()
|
---|
91 | {
|
---|
92 | return metadata_value_tree_node;
|
---|
93 | }
|
---|
94 |
|
---|
95 |
|
---|
96 | public void inheritsMetadataFromFolder(File folder_metadata_inherited_from)
|
---|
97 | {
|
---|
98 | this.folder_metadata_inherited_from = folder_metadata_inherited_from;
|
---|
99 | }
|
---|
100 |
|
---|
101 |
|
---|
102 | public boolean isAccumulatingMetadata()
|
---|
103 | {
|
---|
104 | return is_accumulating_metadata;
|
---|
105 | }
|
---|
106 |
|
---|
107 |
|
---|
108 | public boolean isInheritedMetadata()
|
---|
109 | {
|
---|
110 | return (folder_metadata_inherited_from != null);
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | public void setIsAccumulatingMetadata(boolean is_accumulating_metadata)
|
---|
115 | {
|
---|
116 | this.is_accumulating_metadata = is_accumulating_metadata;
|
---|
117 | }
|
---|
118 | }
|
---|