/************************************************************************
 *
 *  The Contents of this file are made available subject to the terms of
 *
 *         - GNU Lesser General Public License Version 2.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library 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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
 
// This version is adapted for Writer2LaTeX
// Change: The first document added will become the "master document" 2006/10/05
// Version 0.5 (2006-07-24)

package writer2latex.xmerge;

import java.util.Vector;
import java.util.Enumeration;

import writer2latex.api.ConverterResult;
import writer2latex.api.OutputFile;

/**
 *  <p><code>ConvertData</code> is used as a container for passing
 *  <code>OutputFile</code> objects in and out of the <code>Convert</code>
 *  class.  The <code>ConvertData</code> contains a <code>String</code>
 *  name and a <code>Vector</code> of <code>OutputFile</code> objects.</p>
 *
 *  @author  Martin Maher 
 */
public class ConvertData implements ConverterResult {

    /**
     *  Vector of <code>OutputFile</code> objects.
     */
	private Vector v = new Vector();
	
    /** Master doc */
    private OutputFile masterDoc = null;

    /**
     *  Name of the <code>ConvertData</code> object.
     */
	private String name;
	

    /**
     *  Resets ConvertData.  This empties all <code>OutputFile</code>
     *  objects from this class.  This allows reuse of a
     *  <code>ConvertData</code>.
     */
    public void reset() {
		name = null;
                v.removeAllElements();
	}
        
    /**
     *  Returns the <code>OutputFile</code> name.
     *
     *  @return  The <code>OutputFile</code> name.
     */
    public String getName() {
		return name;
	}


    /**
     *  Sets the <code>OutputFile</code> name.
     *
     *  @param  docName  The name of the <code>OutputFile</code>.
     */
    public void setName(String docName) {
		name = docName;
	}

    /**
     *  Adds a <code>OutputFile</code> to the vector.
     *
     *  @param  doc  The <code>OutputFile</code> to add.
     */
    public void addDocument(OutputFile doc) {
        if (v.size()==0) { masterDoc = doc; }
        v.add(doc);
	}
	
    /** Get the master document
     *  @return <code>OutputFile</code> the master document
     */
    public OutputFile getMasterDocument() {
        return masterDoc;
    }
	
    /** Check if a given document is the master document
     *  @param doc  The <code>OutputFile</code> to check
     *  @return true if this is the master document
     */
    public boolean isMasterDocument(OutputFile doc) {
        return doc == masterDoc;
    }

	
    /**
     *  Gets an <code>Enumeration</code> to access the <code>Vector</code>
     *  of <code>OutputFile</code> objects
     *
     *  @return  The <code>Enumeration</code> to access the
     *           <code>Vector</code> of <code>OutputFile</code> objects.
     */
    public Enumeration getDocumentEnumeration() {
        Enumeration enumer = v.elements();
		return (enumer);
	}


    /**
     *  Gets the number of <code>OutputFile</code> objects currently stored 
     *
     *  @return  The number of <code>OutputFile</code> objects currently
     *           stored.
     */
    public int getNumDocuments() {
		return (v.size());
	}
}

