/** *######################################################################### * * 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.msm; /** * Title: The Gatherer
* Description: The Gatherer: a tool for gathering and enriching digital collections.
* Copyright: Copyright (c) 2001
* Company: The University of Waikato
* Written: /04/02
* @author John Thompson, Greenstone Digital Libraries * @version 2.1 */ import org.greenstone.gatherer.msm.Declarations; import org.greenstone.gatherer.msm.MetadataSetManager; /** This class provides all the information required to correctly perform metadata actions, with regard to the users previously indicated preferences in terms of importing and renaming. */ final public class MSMAction { private boolean hfile = false; /** The type of action required in subsequent actions involving the specified set and source element. */ private int action = Declarations.NO_ACTION; private String set = null; private String source = null; /** The fully qualified name of the target element (which must be currently in the loaded metadata sets, otherwise the set it belongs to cannot be determined. */ private String target = null; /** Constructor. Note that the standard action FORCE_MERGE is only named so for clarity and is translated into its actual action RENAME when this profile is created. * @param action An int representing what action needs to be taken in subsequent access of the given set and source element. * @param target A String representing the fully qualified name of the target element. */ public MSMAction(int action, String target) { this.target = target; switch(action) { case Declarations.DELETE: this.action = action; break; case Declarations.FORCE_MERGE: this.action = Declarations.RENAME; break; case Declarations.RENAME: this.action = action; break; case Declarations.SKIP: this.action = action; this.target = null; break; default: this.action = Declarations.NO_ACTION; } } /** Constructor. Note that the standard action FORCE_MERGE is only named so for clarity and is translated into its actual action RENAME when this profile is created. * @param action An int representing what action needs to be taken in subsequent access of the given set and source element. * @param target A String representing the fully qualified name of the target element. * @param hfile If this action was created from the hfile parsing stage, does the element require a replacement to change its alias value into a real one. Note that this profile item may be created for fully namespaced elements as well, to ensure aliases are always remapped. */ public MSMAction(int action, String target, boolean hfile) { this.hfile = hfile; this.target = target; switch(action) { case Declarations.FORCE_MERGE: this.action = Declarations.RENAME; break; case Declarations.RENAME: this.action = action; break; case Declarations.SKIP: this.action = action; this.target = null; break; default: this.action = Declarations.NO_ACTION; } } public MSMAction(String set, String source, int action, String target) { this(action, target); this.set = set; this.source = source; } /** Method for retrieving the appropriate action from this class. * @return An int specifying a particular action. */ public int getAction() { return action; } public String getSet() { return set; } public String getSource() { return source; } /** Method for retrieving the target element of this action. * @return A String stating the fully qualified name of the target element, within the namespace of one of the currently loaded metadata sets. */ /* private String getTarget() { return target; } */ /* private boolean isHFile() { return hfile; } */ }