source: other-projects/FileTransfer-WebSocketPair/testGXTWithGreenstone/src/org/greenstone/gatherer/metadata/MetadataValue.java@ 33053

Last change on this file since 33053 was 33053, checked in by ak19, 5 years ago

I still had some stuff of Nathan Kelly's (FileTransfer-WebSocketPair) sitting on my USB. Had already commited the Themes folder at the time, 2 years back. Not sure if he wanted this additional folder commited. But I didn't want to delete it and decided it will be better off on SVN. When we use his project, if we find we didn't need this test folder, we can remove it from svn then.

File size: 4.0 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.*;
31
32
33/** This class represents one metadata (element, value) pair */
34public 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 // this will be set to true if the metadata element definition says accumulating = false.
42 private boolean must_not_accumulate = false;
43 private boolean is_accumulating_metadata = false;
44 /** Whether this metadata applies to only one file (ie. there are no wildcards in the FileSet value) */
45 private boolean is_one_file_only_metadata = true;
46
47
48 public MetadataValue(MetadataElement metadata_element, MetadataValueTreeNode metadata_value_tree_node)
49 {
50 this.metadata_element = metadata_element;
51 this.metadata_value_tree_node = metadata_value_tree_node;
52 if (metadata_element != null) {
53 if (!metadata_element.isAccumulating()) {
54 must_not_accumulate = true;
55 }
56 }
57 }
58
59
60 public int compareTo(Object metadata_value_object)
61 {
62 MetadataValue metadata_value = (MetadataValue) metadata_value_object;
63
64 // First compare the metadata elements
65 int c = MetadataSetManager.compareMetadataElements(this.getMetadataElement(), metadata_value.getMetadataElement());
66 if (c != 0) {
67 return c;
68 }
69
70 // Then use the metadata values
71 return this.getFullValue().compareTo(metadata_value.getFullValue());
72 }
73
74
75 public File getFolderMetadataInheritedFrom()
76 {
77 return folder_metadata_inherited_from;
78 }
79
80
81 public MetadataElement getMetadataElement()
82 {
83 return metadata_element;
84 }
85
86
87 public String getFullValue()
88 {
89 return metadata_value_tree_node.getFullValue();
90 }
91
92
93 public String getValue()
94 {
95 return metadata_value_tree_node.getValue();
96 }
97
98
99 public MetadataValueTreeNode getMetadataValueTreeNode()
100 {
101 return metadata_value_tree_node;
102 }
103
104
105 public void inheritsMetadataFromFolder(File folder_metadata_inherited_from)
106 {
107 this.folder_metadata_inherited_from = folder_metadata_inherited_from;
108 }
109
110
111 public boolean isAccumulatingMetadata()
112 {
113 return is_accumulating_metadata;
114 }
115
116
117 public boolean isInheritedMetadata()
118 {
119 return (folder_metadata_inherited_from != null);
120 }
121
122
123 public boolean isOneFileOnlyMetadata()
124 {
125 return is_one_file_only_metadata;
126 }
127
128
129 public void setIsAccumulatingMetadata(boolean is_accumulating_metadata)
130 {
131 if (!must_not_accumulate) {
132 this.is_accumulating_metadata = is_accumulating_metadata;
133 }
134 }
135
136
137 public void setIsOneFileOnlyMetadata(boolean is_one_file_only_metadata)
138 {
139 this.is_one_file_only_metadata = is_one_file_only_metadata;
140 }
141}
Note: See TracBrowser for help on using the repository browser.