Index: /trunk/gli/src/org/greenstone/gatherer/gems/ElementWrapper.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gems/ElementWrapper.java	(revision 9169)
+++ /trunk/gli/src/org/greenstone/gatherer/gems/ElementWrapper.java	(revision 9170)
@@ -266,8 +266,4 @@
     }
 
-    public boolean hasValueTree() {
-	return element.getAttribute(StaticStrings.VALUE_TREE_ATTRIBUTE).equalsIgnoreCase(StaticStrings.TRUE_STR);
-    }
-
     /** Increment the number of occurances of this metadata element.
      * @see org.greenstone.gatherer.msm.MSMUtils
Index: unk/gli/src/org/greenstone/gatherer/gems/GValueModel.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gems/GValueModel.java	(revision 9169)
+++ 	(revision )
@@ -1,300 +1,0 @@
-/**
- *#########################################################################
- *
- * A component of the Gatherer application, part of the Greenstone digital
- * library suite from the New Zealand Digital Library Project at the
- * University of Waikato, New Zealand.
- *
- * Author: John Thompson, Greenstone Digital Library, University of Waikato
- *
- * Copyright (C) 1999 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.gems;
-
-import java.util.*;
-import javax.swing.tree.*;
-import org.greenstone.gatherer.util.PatternTokenizer;
-import org.greenstone.gatherer.util.StaticStrings;
-import org.greenstone.gatherer.util.Utility;
-import org.w3c.dom.*;
-/*
- * @author John Thompson, Greenstone Digital Library, University of Waikato
- * @version 2.1
- */
-public class GValueModel
-    extends DefaultTreeModel {
-
-    private ElementWrapper element;
-
-    public GValueModel() {
-	super(new DefaultMutableTreeNode("Temp"));
-    }
-
-    public GValueModel(String root) {
-	super(new DefaultMutableTreeNode(root));
-    }
-
-    public GValueModel(ElementWrapper e) {
-	super(new DefaultMutableTreeNode("Temp"));
-	this.element = e;
-	// Load the template value tree document.
-	Document document = MSMUtils.getValueTreeTemplate();
-	Element new_root = document.getDocumentElement();
-	new_root.setAttribute("element", e.getName());
-	root = new GValueNode(new_root);
-    }
-
-    public GValueModel(ElementWrapper e, Document document) {
-	super(new DefaultMutableTreeNode("Temp"));
-	this.element = e;
-	Element new_root = document.getDocumentElement();
-	new_root.setAttribute("element", e.getName());
-	root = new GValueNode(new_root);
-    }
-
-    /** Value may include path ie news\newssw */
-    public GValueNode addValue(String value) {
-       try {
-	    // Tokenize the string using the escaped character
-	    PatternTokenizer tokenizer = new PatternTokenizer(value, StaticStrings.PIPE_STR);
-	    GValueNode subject = (GValueNode) root;
-	    while(tokenizer.hasMoreTokens() && subject != null) {
-		String token = tokenizer.nextToken();
-		subject = addValue(token, subject);
-	    }
-	    return subject;
-	}
-	catch (Exception error) {
-	    error.printStackTrace();
-	}
-	return null;
-    }
-
-   public GValueNode addValue(String value, GValueNode subject) {
-	// To add a value we must first ensure it isn't already present in -this- nodes children. The bummer is that the nice getElements functions search the whole tree so...
-	GValueNode value_node = subject.getValue(value);
-	if(value_node == null) {
-	    // Now add the new value.
-	    Document document = subject.getElement().getOwnerDocument();
-	    // Now we create a new subject and add it subject
-	    Element new_subject = document.createElementNS("","Subject");
-	    Element new_value = document.createElementNS("","Value");
-	    new_subject.appendChild(new_value);
-	    Text new_text = document.createTextNode(value);
-	    new_value.appendChild(new_text);
-	    value_node = new GValueNode(new_subject);
-	    ///ystem.err.println("(GValueModel) addValue()... " + value_node);
-
-	    // Figure out where this node will be inserted in subjects
-	    // children.
-	    int position = -1;
-	    for(int i = 0; position == -1 && i < subject.getChildCount(); i++) {
-		Object sibling = subject.getChildAt(i);
-		int rel_pos = value.compareTo(sibling.toString());
-		///ystem.err.println("'"+value+"'.compareTo('"+sibling+"') = " + rel_pos);
-		if(rel_pos <= 0) {
-		    position = i;
-		}
-	    }
-	    if(position == -1) {
-		position = subject.getChildCount();
-	    }
-	    // Insert it. If position is still -1, append it to the end of subjects children.
-	    ///ystem.err.println("Inserting '" + value + "' at position " + position);
-	    insertNodeInto(value_node, subject, position);
-	    ///ystem.err.println("(GValueModel) Done insert node into...");
-	    // SynchronizedTreeModelTools.insertNodeInto(this, subject, value_node);
-	    // Inform listeners that we've changed.
-	    // Gatherer.c_man.getCollection().msm.fireValueChanged(element, null, this);
-	}
-	return value_node;
-    }
-
-    public Document getDocument() {
-	return ((GValueNode)root).getElement().getOwnerDocument();
-    }
-
-    public ElementWrapper getElement() {
-	return element;
-    }
-
-    /** Retrieve the hindex for a certain value within the value tree.
-     * @param value The value whose index you wish to determine as a <strong>String</strong>.
-     * @return A <strong>String</strong> containing an index such as "1", "2.1" or "18.2.5".
-     */
-    public String getHIndex(String value) {
-	///ystem.err.println("getHIndex(" + value + ")");
-	return getHIndex((GValueNode) root, value, null);
-    }
-
-    /** Retrieve a value node given its hierarchical reference or value.
-     * @param index_str The hierarchy index or value as a <strong>String</strong>.
-     */
-    public GValueNode getValue(String index_str) {
-	///ystem.err.println("Retrieve the value for: " + index_str);
-	GValueNode result = null;
-	if(isHierarchy() && isIndex(index_str)) {
-	    // StringTokenize the index
-	    StringTokenizer tokenizer = new StringTokenizer(index_str, ".");
-	    result = (GValueNode) root;
-	    // Using the index numbers retrieve the appropriate node.
-	    try {
-		while(result != null && tokenizer.hasMoreTokens()) {
-		    int index = Integer.parseInt(tokenizer.nextToken()) - 1;
-		    // Retrieve the index'th child of the current result node
-		    if(0 <= index && index < result.getChildCount()) {
-			result = (GValueNode) result.getChildAt(index);
-		    }
-		    // Otherwise we're broken.
-		    else {
-			///ystem.err.println("There is no " + index + "th childnode of " + result);
-			result = null;
-		    }
-		}
-	    }
-	    // Most likely caused by parseInt throwing a wobbly.
-	    catch (Exception error) {
-		result = null;
-	    }
-	}
-	if(result == null) {
-	    ///ystem.err.println("No existing value. Adding " + index_str);
-	    result = addValue(index_str);
-	}
-	return result;
-    }
-
-
-    /** A string is a valid hierarchy index if it matches '[0-9](\.[0-9])*' */
-    public boolean isIndex(String raw) {
-	boolean result = true;
-	for(int i = 0; result && i < raw.length(); i++) {
-	    char c = raw.charAt(i);
-	    if(Character.isDigit(c) || (c == '.' && (i != 0 || i != raw.length() - 1))) {
-		// Valid index
-	    }
-	    else {
-		result = false;
-	    }
-	}
-	return result;
-    }
-
-    public boolean isHierarchy() {
-	boolean result = false;
-	// We are a hierarchy if our element says so....
-	if(element.isHierarchy()) {
-	    return true;
-	}
-	// Or if our children are actually a hierarchy.
-	for(int i = 0; i < root.getChildCount() && !result; i++) {
-	    GValueNode node = (GValueNode) root.getChildAt(i);
-	    if(node != null && node.getChildCount() > 0) {
-		result = true;
-	    }
-	}
-	return result;
-    }
-
-    public void removeValue(GValueNode child) {
-	//SynchronizedTreeModelTools.removeNodeFromParent(this, child);
-	removeNodeFromParent(child);
-	// Gatherer.c_man.getCollection().msm.fireValueChanged(new ElementWrapper(child.getElement()), null, this);
-    }
-
-    public void removeValue(String value) {
-	// Retrieve the node to be removed.
-	GValueNode node = getValue(value);
-	if(node != null) {
-	    removeValue(node);
-	}
-    }
-
-    public int size() {
-	return size(root);
-    }
-
-    private int size(TreeNode current) {
-	int size = 1;
-	for(int i = 0; i < current.getChildCount(); i++) {
-	    size = size + size(current.getChildAt(i));
-	}
-	return size;
-    }
-
-    public String toString() {
-	return element.toString();
-    }
-
-    public Vector traverseTree() {
-	Vector contents = new Vector();
-	contents.addAll(traverseTree((GValueNode) root));
-	contents.remove((GValueNode) root);
-	return contents;
-    }
-
-    private GValueModel copy() {
-	Element document_element = ((GValueNode) root).getElement();
-	Document document_copy = MSMUtils.getValueTreeTemplate();
-	Element document_copy_element = document_copy.getDocumentElement();
-	document_copy_element.setAttribute("element", element.getName());
-	for(Node node = document_element.getFirstChild(); node != null; node = node.getNextSibling()) {
-	    if(node.getNodeName().equals("Subject")) {
-		Node node_copy = document_copy.importNode(node, true);
-		document_copy_element.appendChild(node_copy);
-	    }
-	}
-	return new GValueModel(element, document_copy);
-    }
-
-    private String getHIndex(GValueNode node, String value, String index) {
-	///ystem.err.println("Get the HIndex for: " + value);
-	for(int i = node.size(); i != 0; i--) {
-	    GValueNode next = (GValueNode)node.get(i - 1);
-	    String next_str = next.toString(GValueNode.DOM);
-	    ///ystem.err.println("Does " + value + " start with " + next_str + "?");
-	    if(value.startsWith(next_str)) {
-		if(index == null) {
-		    index = String.valueOf(i);
-		}
-		else {
-		    index = index + "." + i;
-		}
-		value = value.substring(next.toString().length());
-		///ystem.err.println("We matched the start so value is now: " + value);
-		if(value.startsWith(StaticStrings.PIPE_STR) || value.startsWith(StaticStrings.ESCAPE_STR)) {
- 		    value = value.substring(1);
-		    index = getHIndex(next, value, index);
-		}
-		///ystem.err.println("Returning " + index);
-		return index;
-	    }
-	}
-	///ystem.err.println("Returning " + index);
-	return index;
-    }
-
-    private Vector traverseTree(GValueNode node) {
-	Vector contents = new Vector();
-	contents.add(node);
-	for(int i = 0; i < node.getChildCount(); i++) {
-	    contents.addAll(traverseTree((GValueNode)node.getChildAt(i)));
-	}
-	return contents;
-    }
-}
Index: unk/gli/src/org/greenstone/gatherer/gems/GValueNode.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gems/GValueNode.java	(revision 9169)
+++ 	(revision )
@@ -1,407 +1,0 @@
-/**
- *#########################################################################
- *
- * A component of the Gatherer application, part of the Greenstone digital
- * library suite from the New Zealand Digital Library Project at the
- * University of Waikato, New Zealand.
- *
- * <BR><BR>
- *
- * Author: John Thompson, Greenstone Digital Library, University of Waikato
- *
- * <BR><BR>
- *
- * Copyright (C) 1999 New Zealand Digital Library Project
- *
- * <BR><BR>
- *
- * 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.
- *
- * <BR><BR>
- *
- * 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.
- *
- * <BR><BR>
- *
- * 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.gems;
-
-/**
- * Title:        The Gatherer<br>
- * Description:  The Gatherer: a tool for gathering and enriching digital collections.<br>
- * Copyright:    Copyright (c) 2001<br>
- * Company:      The University of Waikato<br>
- * First Coded:  20/06/02
- * Revised:<br>
- * @author John Thompson, Greenstone Digital Libraries
- * @version 2.1
- */
-
-import java.util.*;
-import javax.swing.tree.*;
-import org.greenstone.gatherer.util.Codec;
-import org.greenstone.gatherer.util.StaticStrings;
-import org.greenstone.gatherer.util.XMLTools;
-import org.w3c.dom.*;
-
-/** This class is instantiated using a metadata element. From this parent element, which refers to a specific Element in the mds DOM model, the AssignedValues child is used as the root of a tree data-structure encompassing all of the nodes within the AssignedValues tree. This class also provide methods for adding, updating and removing nodes within this tree, as well as implementing all of the methods necessary for this node to be used as the basis of a tree model.
- */
-public class GValueNode
-    extends DefaultMutableTreeNode {
-
-   static final public int DOM = 0;
-   static final public int GREENSTONE = 1;
-   static final public int TEXT = 2;
-
-    private String element_name = null;
-    private String default_value = null;
-
-    public GValueNode(Element element) {
-	this.children = null;
-	this.userObject = element;
-	this.default_value = null;
-    }
-
-    public GValueNode(String element_name, String default_value) {
-	this.element_name = element_name;
-	this.default_value = default_value;
-    }
-
-    /** Compares two GValueNodes for ordering by using the String.compareTo method.
-     * @param sibling The <strong>Object</strong> representing the GValueNode we are comparing ourselves to.
-     * @return An <i>int</i> indicating the ordering. The value is less than zero if we are before the parameter object, zero if we are equal and greater than zero if we preceed sibling.
-     */
-    public int compareTo(Object sibling) {
-	return toString().compareTo(sibling.toString());
-    }
-
-    /** Returns an enumeration of the child nodes.
-     * @return An <strong>Enumeration</strong> containing the child nodes.
-     */
-    public Enumeration children() {
-	if(default_value != null) {
-	    return null;
-	}
-	if(children == null) {
-	    map();
-	}
-	return children.elements();
-    }
-    public boolean equals(Object other) {
-	return compareTo(other) == 0;
-    }
-
-    public GValueNode get(int index) {
-	GValueNode result = null;
-	if(children != null) {
-	    result = (GValueNode) children.get(index);
-	}
-	return result;
-    }
-
-    /** Returns <I>true</I> if the reciever allows children. */
-    public boolean getAllowsChildren() {
-	return true;
-    }
-
-    /** Returns the child <I>TreeNode</I> at index <I>childIndex</I>.*/
-    public TreeNode getChildAt(int index) {
-	if(default_value != null) {
-	    return this;
-	}
-	if(children == null) {
-	    map();
-	}
-	return (GValueNode) children.get(index);
-    }
-
-    /** Returns the number of children <I>TreeNode</I>s the reciever contains. */
-    public int getChildCount() {
-	int size = 0;
-	if(default_value != null) {
-	    size = 0;
-	}
-	if(children == null) {
-	    map();
-	}
-	return children.size();
-    }
-
-    public Element getElement() {
-	return (Element) userObject;
-    }
-
-    /** Return the path to this node within the value tree model.
-     * @return A <strong>String</strong> representing the path, ie "Titles\Modern\The Green Mile"
-     */
-    public String getFullPath(boolean as_text) {
-	if(default_value != null) {
-	    return default_value;
-	}
-	StringBuffer path = new StringBuffer(toString(DOM));
-	GValueNode node = (GValueNode) getParent();
-	while(node != null && !node.getElement().getNodeName().equalsIgnoreCase("AssignedValues")) {
-	    path.insert(0, StaticStrings.PIPE_STR);
-	    path.insert(0, node.toString(DOM));
-	    node = (GValueNode) node.getParent();
-	}
-	if(as_text) {
-	    String temp = path.toString(); ///odec.transform(path.toString(), codec.GREENSTONE_TO_TEXT);
-	    ///ystem.err.println("Raw: " + temp);
-	    temp = Codec.transform(temp, Codec.DECODE_PATH);
-	    temp = Codec.transform(temp, Codec.DECODE_SQUARE_BRACKETS);
-	    ///ystem.err.println("Decoded: " + temp);
-	    return temp;
-	}
-	else {
-	    return path.toString();
-	}
-    }
-
-    /** Returns the index of <I>node</I> in the recievers children. If the
-     * reciever does not contain <I>node</I>, <I>-1</I> will be returned. */
-    public int getIndex(TreeNode node) {
-	if(default_value != null) {
-	    return 0;
-	}
-	if(children == null) {
-	    map();
-	}
-	return children.indexOf(node);
-    }
-
-    public String getMetadataElementName() {
-	if(default_value != null) {
-	    return element_name;
-	}
-	GValueNode node = this;
-	while(node != null && !node.getElement().getNodeName().equalsIgnoreCase("AssignedValues")) {
-	    node = (GValueNode)node.getParent();
-	}
-	if(node != null) {
-	    return node.getElement().getAttribute("element");
-	}
-	return null;
-    }
-
-
-    public GValueNode getValue(String value)
-    {
-	///ystem.err.println("GValueNode.getValue(" + value + ")");
-	if (default_value != null) {
-	    return this;
-	}
-
-	if (children == null) {
-	    map();
-	}
-
-	for (int i = 0; i < children.size(); i++) {
-	    GValueNode child = (GValueNode) children.get(i);
-	    // System.err.println("Comparing " + value + " and " + child.toString(GValueNode.DOM));
-	    if (value.equals(child.toString(GValueNode.DOM))) {
-		return child;
-	    }
-	}
-
-	return null;
-    }
-
-
-    /** Adds <I>child</I> to the receiever at <I>index</I>. <I>child</I> will
-     * be messaged with setParent().
-     */
-    public void insert(MutableTreeNode child, int index) {
-	if(default_value != null) {
-	    return;
-	}
-	if(index >= children.size()) {
-	    // Append to children.
-	    children.add(child);
-	    // And to document
-	    getElement().appendChild(((GValueNode)child).getElement());
-	}
-	else {
-	    GValueNode sibling = (GValueNode) children.get(index);
-	    // Insert in children
-	    children.add(index, child);
-	    // And in document
-	    getElement().insertBefore(((GValueNode)child).getElement(), sibling.getElement());
-	}
-	child.setParent(this);
-    }
-
-    /** Returns <I>true</I> if the reciever is a leaf. */
-    public boolean isLeaf() {
-	if(default_value != null || getChildCount() > 0) {
-	    return false;
-	}
-	return true;
-    }
-
-    /** Ensure that the children nodes of this tree are instantiated, and record the initial mappings for legacy sake.
-     * @param mapping A <strong>HashMap</strong> into which to write the initial mappings.
-     * @param prefix The prefix to use for indexes, as a <strong>String</strong>.
-     */
-    public void map(HashMap mapping, String prefix) {
-	if(default_value != null) {
-	    return;
-	}
-	children = new Vector();
-	if(prefix.length() > 0) {
-	    prefix = prefix + ".";
-	}
-	int i = 1;
-	for(Node node = getElement().getFirstChild(); node != null; node = node.getNextSibling()) {
-	    if(node.getNodeName().equals("Subject")) {
-		GValueNode child = new GValueNode((Element)node);
-		child.setParent(this);
-		children.add(child);
-		String index = prefix + i;
-		mapping.put(index, child);
-		child.map(mapping, index);
-		i++;
-	    }
-	}
-    }
-
-    /** Resets the user object of the reciever to <I>object</I>. */
-    public void setUserObject(Object object) {
-	// Can't ever change Elements from here. Have to use editor. */
-    }
-
-    public void setValue(String value) {
-	setNodeValue("Value", value);
-    }
-
-    public int size() {
-	int size = 0;
-	if(children != null) {
-	    size = children.size();
-	}
-	return size;
-    }
-
-    /** Returns a <I>String</I> representation of the reciever. If this
-     * happens to be the AssignedValues 'root' then we do something slightly
-     * different, otherwise we return the value of the <I>#Text</I> child of
-     * the <I>Value</I> of this <I>Subject</I> node!
-     */
-    public String toString() {
-	return toString(GValueNode.TEXT);
-    }
-
-    public String toString(int decode_type) {
-	if(default_value != null) {
-	    return default_value;
-	}
-	Element element = getElement();
-	String name = element.getNodeName();
-	String result = null;
-	if(name.equals("Subject")) {
-	    result = XMLTools.getValue(element);
-	    ///ystem.err.print(result);
-	    switch(decode_type) {
-	    case GValueNode.GREENSTONE:
-		// We want this as greenstone format
-		///ystem.err.print(result);
-		//result = /odec.transform(result, /odec.DOM_TO_GREENSTONE);
-		///ystem.err.println(" -> D2G decode -> " + result);
-		break;
-	    case GValueNode.TEXT:
-		//result = /odec.transform(result, /odec.DOM_TO_TEXT);
-		result = Codec.transform(result, Codec.DECODE_PATH);
-		result = Codec.transform(result, Codec.DECODE_SQUARE_BRACKETS);
-		///ystem.err.println(" -> D2T decode -> " + result);
-		break;
-	    default:
-		///ystem.err.println(result + " -> nothing to do.");
-	    }
-	}
-	else if(name.equals("AssignedValues")) {
-	    result = getMetadataElementName();
-	}
-	return result;
-    }
-
-    private void map() {
-	children = new Vector();
-	for(Node node = getElement().getFirstChild(); node != null; node = node.getNextSibling()) {
-	    if(node.getNodeName().equals("Subject")) {
-		GValueNode child = new GValueNode((Element)node);
-		child.setParent(this);
-		children.add(child);
-	    }
-	}
-    }
-
-    /** Removes the child at index from the receiver. */
-    public void remove(int index) {
-	remove((MutableTreeNode)getChildAt(index));
-    }
-
-    /** Removes node from the receiver. */
-    public void remove(MutableTreeNode node) {
-	children.remove(node);
-	node.setParent(null);
-	// Remove from DOM
-	Element child_element = ((GValueNode)node).getElement();
-	Node parent_node = child_element.getParentNode();
-	parent_node.removeChild(child_element);
-    }
-
-    /** Removes the receiver from its parent. */
-    public void removeFromParent() {
-	if(parent != null) {
-	    parent.remove(this);
-	}
-    }
-
-    private void setNodeValue(String name, String value) {
-	boolean found = false;
-	// Attempt to retrieve a child node named name
-	Element element = (Element) userObject;
-	for(Node pos_node = element.getFirstChild(); pos_node != null; pos_node = pos_node.getNextSibling()) {
-	    // And if we find such a node
-	    if(pos_node.getNodeName().equals(name)) {
-		// And the new value is non-null, retrieve its text node and change it.
-		if(value != null) {
-		    for(Node pos_text = pos_node.getFirstChild(); pos_text != null; pos_text = pos_text.getNextSibling()) {
-			// When we find the node...
-			if(pos_text.getNodeName().equals("#text")) {
-			    pos_text.setNodeValue(value);
-			}
-		    }
-		}
-		// Otherwise remove the node altogether
-		else {
-		    element.removeChild(pos_node);
-		}
-		found = true;
-	    }
-	}
-	// Otherwise if no such node exists add it.
-	if(!found && value != null) {
-	    Document document = element.getOwnerDocument();
-	    Node new_node = document.createElementNS("", name);
-	    element.appendChild(new_node);
-	    Node new_text = document.createTextNode(value);
-	    new_node.appendChild(new_text);
-	    new_text = null;
-	    new_node = null;
-	}
-	// Done.
-	element = null;
-	return;
-    }
-}
Index: /trunk/gli/src/org/greenstone/gatherer/gems/MSMUtils.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gems/MSMUtils.java	(revision 9169)
+++ /trunk/gli/src/org/greenstone/gatherer/gems/MSMUtils.java	(revision 9170)
@@ -424,43 +424,4 @@
 
 
-    /** Method to traverse the given value tree, and build up a hashtable of mappings between the value path key names and the Subject nodes of the tree.
-     * @param current The root <strong>Node</strong> of a subtree of the AssignedValues tree.
-     * @param prefix The value path key <strong>String</string>, which shows the path from the root of the AssignedValue tree to <i>current</i>s parent using '\' as a separator.
-     * @param values A <strong>Hashtable</strong> containing the mapping discovered so far in our tree traversal.
-     */ 
-    static final private void getValueMappings(Node current, String prefix, Hashtable values) {
-	if(current != null) {
-	    String name = current.getNodeName();
-	    String new_prefix = prefix;
-	    // If we've found the outer layer of a new value, add it to our mapping
-	    if(name.equals("Subject")) {
-		Node value_node = getNodeFromNamed(current, "Value");
-		String value = getValue(value_node);
-		if(new_prefix != null) {
-		    new_prefix = new_prefix + "\\" + value;
-		}
-		else {
-		    new_prefix = value;
-		}
-		values.put(new_prefix, current);
-	    }
-	    if(name.equals("Subject") || name.equals("AssignedValues")) {
-		for(Node child = current.getFirstChild(); child != null;
-		    child = child.getNextSibling()) {
-		    getValueMappings(child, new_prefix, values);
-		}
-	    }
-	}
-    }
-
-
-    /** Parses the value tree template file.
-     * @return The Document parsed.
-     */
-    static final public Document getValueTreeTemplate() {
-	return Utility.parse(GEMS.METADATA_VALUE_TEMPLATE, true);
-    }
-
-
     /** Determine if the named attribute is language specific for this collection. This information is found in a DOM attribute of the document element, as a comma separated list of attribute names.
      * @param document the Document for which we wish to check the language requirements
@@ -686,23 +647,3 @@
 	}
     }
- 
-
-    /** Method to determine if two Value nodes are equal.
-     * @param av A <strong>Node</strong> representing a value.
-     * @param bv The <strong>Node</strong> we want to compare it to.
-     * @return A <i>boolean</i> which is <i>true</i> if the two value nodes are equal, <i>false</i> otherwise.
-     */
-    static final private boolean valuesEqual(Node av, Node bv) {
-	// Check we are comparing apples and apples...
-	if(av.getNodeName().equals("Value") && 
-	   bv.getNodeName().equals("Value")) {
-	    // Retrieve and then compare their text values.
-	    Node at = av.getFirstChild();
-	    Node bt = bv.getFirstChild();
-	    if(at.getNodeValue().equals(bt.getNodeValue())) {
-		return true;
-	    }
-	}
-	return false;
-    }
 }
Index: /trunk/gli/src/org/greenstone/gatherer/gems/MetadataSet.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gems/MetadataSet.java	(revision 9169)
+++ /trunk/gli/src/org/greenstone/gatherer/gems/MetadataSet.java	(revision 9170)
@@ -60,6 +60,4 @@
     public String old_filename = null;
     private File     file     = null;
-    /** A mapping from metadata elements to the root element of the value trees for that element. */
-    private Hashtable value_trees = null;
     /** The list of metadata elements which are, of course, children of the root node. */
     private ArrayList elements = null;
@@ -85,5 +83,4 @@
 	
 	this.file = new File(metadata_template);
-	this.value_trees = new Hashtable();
 	this.document = Utility.parse(metadata_template, true);
 
@@ -96,5 +93,4 @@
     public MetadataSet(File file) {
 	this.file = file;
-	this.value_trees = new Hashtable();
 	this.document = XMLTools.parseXMLFile(file);
 
@@ -106,5 +102,4 @@
      */
     public MetadataSet(MetadataSet original) {
-	this.value_trees = new Hashtable();
 	// We have to create a new document.
 	document = new DocumentImpl(original.getDocument().getDoctype());
@@ -114,16 +109,4 @@
 	//elements = root.getElementsByTagName("Element");
 	file = original.getFile();
-	// Now for each element read in its value tree if present.
-	for(int i = elements.size() - 1; i >= 0; i--) {
-	    ElementWrapper value_element_wrapper = new ElementWrapper((Element)elements.get(i));
-	    GValueModel value_tree = original.getValueTree(value_element_wrapper);
-	    Document value_document = value_tree.getDocument();
-	    Document value_document_copy = new DocumentImpl(value_document.getDoctype());
-	    Element value_element = value_document.getDocumentElement();
-	    Element value_element_copy = (Element) value_document_copy.importNode(value_element, true);
-	    value_document_copy.appendChild(value_element_copy);
-	    GValueModel value_tree_copy = new GValueModel(value_element_wrapper, value_document_copy);
-	    value_trees.put(value_element_wrapper, value_tree_copy);
-	}
     }
   
@@ -136,33 +119,5 @@
         setChanged = val;
     }
-      /** Conditional copy constructor. 
-     * @param original The original metadata set to copy from.
-     * @param condition An <i>int</i> which matches one of the tree pruning filter types.
-     */
-    public MetadataSet(MetadataSet original, int condition) {
-	this(original); 
-	// Now based on condition, we may have to remove some nodes from
-	// this model.
-	switch(condition) {
-	case ALL_VALUES:
-	    // Do nothing.
-	    break;
-	case SUBJECTS_ONLY:
-	    // For each element retrieve its AssignedValues element.
-	    for(Enumeration keys = value_trees.keys(); keys.hasMoreElements(); ) {
-		ElementWrapper value_element = (ElementWrapper)keys.nextElement();
-		GValueModel value_tree = (GValueModel)value_trees.get(value_element);
-		Document value_tree_document = value_tree.getDocument();
-		Element value_tree_root_element = value_tree_document.getDocumentElement();
-		// Traverse tree and remove leaf nodes. 
-		MSMUtils.traverseTree(value_tree_root_element, MSMUtils.NONE, true);
-	    }
-	    break;
-	case NO_VALUES:
-	    // Remove assigned values trees.
-	    value_trees.clear();
-	    break;
-	}
-    }
+
 
     public void setCollection(String coll) {
@@ -213,61 +168,4 @@
     }
 
-   
-    /** Method to add a new metadata element to this metadata set, if and only if the element is not already present. 
-     * @param others_element An <strong>Element</strong> we wish to add to this metadata set, that currently belongs to some other set.
-     * @param model A <strong>GValueModel</strong> value tree 
-     * @return <i>null</i> if the add is successful, otherwise a <strong>String</strong> containing an error message (phrase key).
-     */
-    public String addElement(Element others_element, GValueModel model) {
-	if(!containsElement(others_element.getAttribute("name"))) {
-	    // First get ownership of the new element, then add it.
-	    Element our_element = (Element)document.importNode(others_element, true);
-	    // add the value tree
-	    root.appendChild(our_element);
-	    if (model != null) {
-		addValueTree(new ElementWrapper(our_element), model);	
-	    }    
-	    return null;
-	}
-	else {
-	    return "MSMPrompt.Name_Exists";
-	}
-    }
-
-    /** Method to add a new metadata element with the specified new name to this metadata set, if and only if the name is not already in use. 
-     * @param others_element An <strong>Element</strong> we wish to add to this metadata set, that currently belongs to some other set.
-     * @param new_name The new name to be given this element, as a <strong>String</strong>.
-     * @param model A <strong>GValueModel</strong> value tree 
-     * @return <i>null</i> if the add is successful, otherwise a <strong>String</strong> containing an error message (phrase key).
-     */
-    public String addElement(Element others_element, String new_name, GValueModel model) {
-	if(!containsElement(new_name)) {
-	    // First get ownership of the new element, then add it.
-	    Element our_element = 
-		(Element) document.importNode(others_element, true);
-	    // Change name
-	    our_element.setAttribute("name", new_name);
-	    // we also want to change the english identifier of this element
-	    MSMUtils.setIdentifier(our_element, new_name);
-	    // Add it to teh set
-	    root.appendChild(our_element);
-	    // add the value tree
-	    if (model != null) {
-		addValueTree(new ElementWrapper(our_element), model);
-	    }
-	    return null;
-	}
-	else {
-	    return "MSMPrompt.Name_Exists";
-	}
-    }
-    /** Add a value tree to a given metadata element.
-     * @param element The <strong>ElementWrapper</strong> containing the element you wish to add a value tree for.
-     * @param model A <strong>GValueModel</strong> value tree 
-     */
-    public void addValueTree(ElementWrapper element, GValueModel model) {
-	///ystem.err.println("Adding value tree for " + element.toString());
-	value_trees.put(element, model);
-    }
 
     public int compare(Element e1, Element e2) {
@@ -466,25 +364,5 @@
 	return root;
     }
-    /** Retrieve the value tree from this set that matches the given element.
-     * @param element The target <strong>ElementWrapper</strong>.
-     * @return A <strong>GValueModel</strong> value tree, or <i>null</i> if no such element or value tree.
-     */
-    public GValueModel getValueTree(ElementWrapper element) {
-	GValueModel value_tree = null;
-	// Stinking hashtable get doesn't use the overridden equals. So I'll do a loop, which should be pretty small ie O(n) for n metadata elements.
-	for(Enumeration keys = value_trees.keys(); keys.hasMoreElements(); ) {
-	    ElementWrapper sibling = (ElementWrapper) keys.nextElement();
-	    if(sibling.equals(element)) {
-		value_tree = (GValueModel) value_trees.get(sibling);
-		break;
-	    }
-	}
-	// If we've found no value tree, create a new one.
-	if(value_tree == null) {
-	    value_tree = new GValueModel(element);
-	    value_trees.put(element, value_tree);
-	}
-	return value_tree;
-    }
+
     /** Remove a mds level attribute.
      * @param name The name of the attribute to remove.
@@ -501,5 +379,4 @@
 	try {
 	    ElementWrapper element_wrapped = new ElementWrapper(element);
-	    removeValueTree(element_wrapped);
 
 	    if(parent == null)
@@ -531,21 +408,4 @@
 	
 
-    /** Used to remove the value tree for a specific element.
-     * @param element The <strong>ElementWrapper</strong> whose tree you wish to remove.
-     * @return The <strong>GValueModel</strong> we just removed
-     */
-    public GValueModel removeValueTree(ElementWrapper element) {
-	for(Enumeration keys = value_trees.keys(); keys.hasMoreElements(); )
-	    {
-		ElementWrapper sibling = (ElementWrapper) keys.nextElement();
-		if(sibling.equals(element))
-		    {
-			GValueModel value_tree = (GValueModel) value_trees.get(sibling);
-			value_trees.remove(sibling);
-			return value_tree;
-		    }
-	    }
-	return null;
-    }
     /** Set one of the mds level attributes.
      * @param name The attribute to change.
@@ -683,25 +543,4 @@
 	    this.root = document.getDocumentElement();
 	    this.elements = XMLTools.getChildElementsByTagName(root, "Element");
-	    // Now for each element read in its value tree if present.
-	    for(int i = elements.size() - 1; i >= 0; i--) {
-		ElementWrapper value_element = new ElementWrapper((Element)elements.get(i));
-		File value_file = new File(file.getParentFile(), value_element.getName() + ".mdv");
-		///ystem.err.println("Searching for " + value_file.getAbsolutePath());
-		if(value_file.exists()) {
-		    Document value_document;
-		    if (use_classloader) {
-			value_document = Utility.parse(value_file.toString(), true);
-		    }
-		    else {
-			value_document = XMLTools.parseXMLFile(value_file);
-		    }
-		    if(value_document != null) {
-			value_trees.put(value_element, new GValueModel(value_element, value_document));
-		    }
-		    else {
-			DebugStream.println("Error! Missing mdv file: " + value_file.getAbsolutePath());
-		    }
-		}
-	    }
 	}
 	else {
Index: /trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java	(revision 9169)
+++ /trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java	(revision 9170)
@@ -120,17 +120,4 @@
 		System.err.println("Error: no such set \'" + current_set + "\'");
 	    }
-    }
-
-
-    /** Add a value tree to a given metadata element represented as a GValueModel
-     * @param model The <strong>GValueTree</strong> model
-     */
-    public void addValueTree(GValueModel model) {
-	ElementWrapper element = model.getElement();
-	String namespace = element.getNamespace();
-	MetadataSet mds = (MetadataSet) mds_hashtable.get(namespace);
-	if(mds != null) {
-	    mds.addValueTree(element, model);
-	}
     }
 
@@ -314,23 +301,4 @@
   
 
-    /** Get the value tree that matches the given element.
-     * @param element The ElementWrapper representing the element.
-     * @return The GValueModel representing the value tree or null.
-     */
-    public GValueModel getValueTree(ElementWrapper element) {
-	GValueModel value_tree = null;
-	if(element != null) {
-	    String namespace = element.getNamespace();
-	    if(namespace.length() > 0) {
-		MetadataSet mds = (MetadataSet) mds_hashtable.get(namespace);
-		if(mds != null) {
-		    value_tree = mds.getValueTree(element);
-		}
-	    }
-	}
-	return value_tree;
-    }
-
-
     public MetadataSet loadMetadataSet(File metadata_set_file)
     {
@@ -430,37 +398,4 @@
 
 
-    /*Following write() and write() and save() were taken from msm/metadatasetmanager.java and converted to 
-     *the gems standard
-     */
-     private void write(ElementWrapper element, GValueModel model, String etc_dir) {
-	try {
-	    File out_file = new File(etc_dir + element.getName() + ".txt");
-	    FileOutputStream fos = new FileOutputStream(out_file);
-	    OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
-	    BufferedWriter bw = new BufferedWriter(osw, Utility.BUFFER_SIZE);
-	    Vector all_values = model.traverseTree();
-	    for(int i = 0; i < all_values.size(); i++) {
-		GValueNode node = (GValueNode)all_values.get(i);
-		String full_value = node.getFullPath(false);
- 		String index = model.getHIndex(full_value);
-
-		write(bw, "\"" + full_value + "\"\t" + index + "\t\"" + node.toString(GValueNode.GREENSTONE) + "\"");
-	    }
-	    // Very important we do this, or else buffer may not be flushed
-	    bw.flush();
-	    bw.close();
-	}
-	catch(Exception error) {
-	    error.printStackTrace();
-	}
-    }
-
-    private void write(Writer w, String text)
-	throws Exception {
-	text = text + "\r\n";
-	char buffer[] = text.toCharArray();
-	w.write(buffer, 0, buffer.length);
-    }
-
     public void save() {
 	File file = new File(Utility.METADATA_DIR);
Index: /trunk/gli/src/org/greenstone/gatherer/gems/TransformCharacterTextField.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gems/TransformCharacterTextField.java	(revision 9169)
+++ /trunk/gli/src/org/greenstone/gatherer/gems/TransformCharacterTextField.java	(revision 9170)
@@ -27,11 +27,9 @@
 package org.greenstone.gatherer.gems;
 
-/**************************************************************************************
- * Written:     04/07/03
- * Revised:     
- **************************************************************************************/
 import java.util.*;
 import javax.swing.*;
 import javax.swing.text.*;
+
+
 /** A JTextField that doesn't allow certain characters, either blocking or replacing them
  * @author John Thompson, Greenstone Digital Library, University of Waikato
@@ -64,15 +62,7 @@
     }
 
-//      public void blockCharacter(char x) {
-//  	mappings.put(new Character(x), null);
-//      }
-
     public void replaceCharacter(char x, char y) {
 	mappings.put(new Character(x), new Character(y));
     }
-
-//      public void restoreCharacter(char x) {
-//  	mappings.remove(new Character(x));
-//      }
 
     public void setBlockAllExceptMappings(boolean block_all_except_mappings) {
