001    /*
002     * LAPIS lightweight structured text processing system
003     *
004     * Copyright (C) 1998-2002 Carnegie Mellon University,
005     * Copyright (C) 2003 Massachusetts Institute of Technology.
006     * All rights reserved.
007     *
008     * This library is free software; you can redistribute it
009     * and/or modify it under the terms of the GNU General
010     * Public License as published by the Free Software
011     * Foundation, version 2.
012     *
013     * LAPIS homepage: http://graphics.lcs.mit.edu/lapis/
014     */
015    
016    package lapis;
017    
018    import java.util.*;
019    
020    /**
021     * Versions is a set of document versions from which a region set is derived.  Contains
022     * at most one version per document (i.e., if v1!=v2 are in the set, then v1.doc != v2.doc).
023     * Versions is immutable.
024     */
025    public interface Versions {
026        /**
027         * @return an iterator over the set of document versions
028         */
029        public Iterator versions();
030        
031        /**
032         * @return an iterator over the set of documents
033         */
034        public Iterator documents();
035        
036        /**
037         * @return the number of versions (or equivalently, the number of documents) that Versions contains
038         */
039        public int getSize();
040        
041        /**
042         * @param ver a document version
043         * @return true if ver is in Versions, false otherwise.
044         */
045        public boolean contains (DocumentVersion ver);
046        
047        /**
048         * @param doc a document
049         * @return true if doc is in Versions, false otherwise.
050         */
051        public boolean contains (Document doc);
052        
053        /**
054         * get doc's version, which is stored in Versions
055         * @param doc a document
056         * @return doc's version, which is stored in Versions, if doc is in Versions. null otherwise.
057         */
058        public DocumentVersion getVersion (Document doc);
059        
060        /**
061         * @return true if obj is an instance of Versions and obj contains the same set of DocumentVersion as this.
062         * false otherwise.
063         */
064        public boolean equals (Object obj);
065        
066        /**
067         * Test whether two Versions are compatible -- i.e., whether two region sets with those Versions can be
068         * safely combined without coordinate conversion. 
069         * @param vs a Versions
070         * @return true if and only if for every document doc shared by this and vs,  this.getVersion(doc) == vs.getVersion(doc).
071         */
072        public boolean compatible (Versions vs);
073    }