// Path: src/bibtex/Assertions.java
// public class Assertions {
// 
//     public static final boolean ENABLE_EXPENSIVE_ASSERTIONS = true;
//     
// }


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import bibtex.Assertions;
/*
 * Created on Jul 14, 2004
 *
 * @author henkel@cs.colorado.edu
 * 
 */
package bibtex.dom;



/**
 * Some bibtex files have multiple values per field - this is a container that
 * contains these values. For example, the following BibtexEntry has multiple
 * values for the url field:
 * 
 * <pre>
 *   &#064;inproceedings{diwan98typebased,
 *      year=1998,
 *      pages={106-117},
 *      title={Type-Based Alias Analysis},
 *      url={citeseer.nj.nec.com/diwan98typebased.html},
 *      booktitle={SIGPLAN Conference on Programming Language Design and Implementation},
 *      author={Amer Diwan and Kathryn S. McKinley and J. Eliot B. Moss},
 *      url={http://www-plan.cs.colorado.edu/diwan/},
 *   }
 * </pre>
 * 
 * Note that the bibtex parser in this package will discard duplicate values
 * unless you set the appropriate policy
 * with BibtexParser.setMultipleFieldValuesPolicy(int).
 * 
 * @see bibtex.parser.BibtexParser#setMultipleFieldValuesPolicy(int)
 * @see bibtex.parser.BibtexMultipleFieldValuesPolicy#KEEP_ALL
 * 
 * @author henkel
 */
public final class BibtexMultipleValues extends BibtexAbstractValue {

    private final ArrayList values = new ArrayList(3);

    /**
     * @param bibtexFile
     */
    BibtexMultipleValues(BibtexFile bibtexFile) {
        super(bibtexFile);
    }

    /**
     * This will add the value object to this BibtexMultipleValues object. Do
     * not try to add the same object multiple times.
     * 
     * @param value
     *            is the value you want to add to this instance. Note that this
     *            may be anything but another BibtexAbstractValue instance - we
     *            don't want to have nested BibtexMultipleValue instances.
     */
    public void addValue(BibtexAbstractValue value) {

        assert value != null : "value parameter may not be null.";
        assert !(value instanceof BibtexMultipleValues) : "You cannot add a BibtexMultipleValues instance to a BibtexMultipleValues instance.";
// Path: src/bibtex/Assertions.java
// public class Assertions {
// 
//     public static final boolean ENABLE_EXPENSIVE_ASSERTIONS = true;
//     
// }


// Path: src/bibtex/dom/BibtexMultipleValues.java
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import bibtex.Assertions;

/*
 * Created on Jul 14, 2004
 *
 * @author henkel@cs.colorado.edu
 * 
 */
package bibtex.dom;



/**
 * Some bibtex files have multiple values per field - this is a container that
 * contains these values. For example, the following BibtexEntry has multiple
 * values for the url field:
 * 
 * <pre>
 *   &#064;inproceedings{diwan98typebased,
 *      year=1998,
 *      pages={106-117},
 *      title={Type-Based Alias Analysis},
 *      url={citeseer.nj.nec.com/diwan98typebased.html},
 *      booktitle={SIGPLAN Conference on Programming Language Design and Implementation},
 *      author={Amer Diwan and Kathryn S. McKinley and J. Eliot B. Moss},
 *      url={http://www-plan.cs.colorado.edu/diwan/},
 *   }
 * </pre>
 * 
 * Note that the bibtex parser in this package will discard duplicate values
 * unless you set the appropriate policy
 * with BibtexParser.setMultipleFieldValuesPolicy(int).
 * 
 * @see bibtex.parser.BibtexParser#setMultipleFieldValuesPolicy(int)
 * @see bibtex.parser.BibtexMultipleFieldValuesPolicy#KEEP_ALL
 * 
 * @author henkel
 */
public final class BibtexMultipleValues extends BibtexAbstractValue {

    private final ArrayList values = new ArrayList(3);

    /**
     * @param bibtexFile
     */
    BibtexMultipleValues(BibtexFile bibtexFile) {
        super(bibtexFile);
    }

    /**
     * This will add the value object to this BibtexMultipleValues object. Do
     * not try to add the same object multiple times.
     * 
     * @param value
     *            is the value you want to add to this instance. Note that this
     *            may be anything but another BibtexAbstractValue instance - we
     *            don't want to have nested BibtexMultipleValue instances.
     */
    public void addValue(BibtexAbstractValue value) {

        assert value != null : "value parameter may not be null.";
        assert !(value instanceof BibtexMultipleValues) : "You cannot add a BibtexMultipleValues instance to a BibtexMultipleValues instance.";
        assert !Assertions.ENABLE_EXPENSIVE_ASSERTIONS || !values.contains(value) : "value is already contained in this BibtexMultipleValues object.";