001    /*
002     * The contents of this file are subject to the Mozilla Public
003     * License Version 1.1 (the "License"); you may not use this file
004     * except in compliance with the License. You may obtain a copy of
005     * the License at http://www.mozilla.org/MPL/
006     *
007     * Software distributed under the License is distributed on an "AS
008     * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
009     * implied. See the License for the specific language governing
010     * rights and limitations under the License.
011     *
012     * The Original Code is Knowtator.
013     *
014     * The Initial Developer of the Original Code is University of Colorado.  
015     * Copyright (C) 2005 - 2008.  All Rights Reserved.
016     *
017     * Knowtator was developed by the Center for Computational Pharmacology
018     * (http://compbio.uchcs.edu) at the University of Colorado Health 
019     *  Sciences Center School of Medicine with support from the National 
020     *  Library of Medicine.  
021     *
022     * Current information about Knowtator can be obtained at 
023     * http://knowtator.sourceforge.net/
024     *
025     * Contributor(s):
026     *   Philip V. Ogren <philip@ogren.info> (Original Author)
027     */
028    
029    package edu.uchsc.ccp.knowtator.textsource;
030    
031    import java.util.List;
032    
033    import edu.stanford.smi.protege.model.Instance;
034    import edu.stanford.smi.protege.model.KnowledgeBase;
035    import edu.uchsc.ccp.knowtator.Span;
036    
037    /**
038     * We recommend that instead of implementing this interface that you extend
039     * DefaultTextSource. If you decide to implement this interface directly we
040     * encourage you to look at the code for DefaultTextSource to help you.
041     */
042    
043    public interface TextSource {
044            /**
045             * @return the text associated with the TextSource. The text returned will
046             *         be shown in the Knowtator text viewer.
047             */
048            public String getText() throws TextSourceAccessException;
049    
050            /**
051             * @return the name associated with the TextSource. This should be thought
052             *         of as an identifier for the TextSource. Implementations of
053             *         TextSourceCollection should make sure that name collisions do not
054             *         occur.
055             */
056    
057            public String getName();
058    
059            /**
060             * Every implementation of TextSource corresponds to a subclass of
061             * "knowtator text source" which is a class defined knowtator.pprj (which is
062             * the project that must be included in order to run Knowtator.)
063             */
064    
065            public String getProtegeClsName();
066    
067            /**
068             * This is the generic method for creating a "knowtator text source"
069             * instance from a TextSource object. All instances of
070             * "knowtator text source" can be created in a very simplistic way from a
071             * TextSource object. An instance of the class specified by the name
072             * returned by getProtegeClsName() is created with the name returned by
073             * getName()
074             * 
075             * @return may return null if textSource.getProtegeClsName() is not a known
076             *         cls name. Otherwise the new Protege instance that has been
077             *         created.
078             */
079            public Instance createTextSourceInstance(KnowledgeBase knowledgeBase);
080    
081            public int hashCode();
082    
083            public boolean equals(Object object);
084    
085            public String toString();
086    
087            /**
088             * Returns the text corresponding to the spans passed in. Typically, a
089             * single span will be passed in and the text corresponding to that text
090             * will be returned. If there are multiple spans, some extra decisions need
091             * to be made such as what the delimiter between spans will be and whether
092             * the spans should be sorted first.
093             */
094            public String getText(List<Span> spans) throws TextSourceAccessException;
095    
096    }