/** *############################################################################ * A component of the Greenstone Librarian Interface, part of the Greenstone * digital library suite from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * * Author: Michael Dewsnip, NZDL Project, University of Waikato, NZ * * Copyright (C) 2004 New Zealand Digital Library Project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *############################################################################ */ package org.greenstone.gatherer.metadata; import java.io.File; import org.greenstone.gatherer.Configuration; import org.greenstone.gatherer.util.XMLTools; import org.greenstone.gatherer.util.StaticStrings; import org.w3c.dom.*; /** This class represents one Metadata element */ public class MetadataElement { // Language-independent metadata element name, with namespace (eg. dc.Subject) private String metadata_element_name_full = null; private Element metadata_element_element = null; private MetadataValueTreeModel metadata_value_tree_model = null; /* this is true if the metadata element comes with a pre defined set of values */ private boolean predefined_values = false; /* This restricts the user to only the predefined values */ private boolean restricted_values = false; public MetadataElement(String metadata_element_name_full, Element metadata_element_element) { this.metadata_element_name_full = metadata_element_name_full; this.metadata_element_element = metadata_element_element; this.metadata_value_tree_model = new MetadataValueTreeModel(this); if (metadata_element_element.getAttribute(StaticStrings.PREDEFINED_METADATA_ATTRIBUTE).equals("true")) { predefined_values = true; loadOptionList(); if (metadata_element_element.getAttribute(StaticStrings.RESTRICTED_METADATA_ATTRIBUTE).equals("true")) { // cant have restricted values if no predefined values restricted_values = true; } } } // do this better protected boolean loadOptionList() { NodeList values = metadata_element_element.getElementsByTagName("Value"); for (int i=0; i