edu.uchsc.ccp.knowtator.textsource
Class DefaultTextSource

java.lang.Object
  extended by edu.uchsc.ccp.knowtator.textsource.DefaultTextSource
All Implemented Interfaces:
TextSource
Direct Known Subclasses:
FileLineTextSource, FileTextSource

public class DefaultTextSource
extends Object
implements TextSource


Field Summary
static String CLS_NAME
           
protected  String name
           
protected  String protegeClsName
           
protected  String text
           
 
Constructor Summary
DefaultTextSource()
          Creates a new instance of TextSource
DefaultTextSource(String name, String text)
           
DefaultTextSource(String name, String text, String protegeClsName)
           
 
Method Summary
 Instance createTextSourceInstance(KnowledgeBase knowledgeBase)
          This is the generic method for creating a "knowtator text source" instance from a TextSource object.
 boolean equals(Object object)
           
 String getName()
           
 String getProtegeClsName()
          Every implementation of TextSource corresponds to a subclass of "knowtator text source" which is a class defined knowtator.pprj (which is the project that must be included in order to run Knowtator.)
 String getText()
          It might be prudent for extensions of this class to override this method such that the member variable text is not used - esp.
 String getText(List<Span> annotationSpans)
          Returns the text corresponding to the spans passed in.
static String getText(List<Span> annotationSpans, String text)
           
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLS_NAME

public static final String CLS_NAME
See Also:
Constant Field Values

text

protected String text

name

protected String name

protegeClsName

protected String protegeClsName
Constructor Detail

DefaultTextSource

public DefaultTextSource()
Creates a new instance of TextSource


DefaultTextSource

public DefaultTextSource(String name,
                         String text)

DefaultTextSource

public DefaultTextSource(String name,
                         String text,
                         String protegeClsName)
Method Detail

getText

public String getText()
               throws TextSourceAccessException
It might be prudent for extensions of this class to override this method such that the member variable text is not used - esp. if the texts are large and there are many of them.

Specified by:
getText in interface TextSource
Returns:
the text associated with the TextSource. The text returned will be shown in the Knowtator text viewer.
Throws:
TextSourceAccessException

getName

public String getName()
Specified by:
getName in interface TextSource
Returns:
the name associated with the TextSource. This should be thought of as an identifier for the TextSource. Implementations of TextSourceCollection should make sure that name collisions do not occur.

getProtegeClsName

public String getProtegeClsName()
Description copied from interface: TextSource
Every implementation of TextSource corresponds to a subclass of "knowtator text source" which is a class defined knowtator.pprj (which is the project that must be included in order to run Knowtator.)

Specified by:
getProtegeClsName in interface TextSource

createTextSourceInstance

public Instance createTextSourceInstance(KnowledgeBase knowledgeBase)
Description copied from interface: TextSource
This is the generic method for creating a "knowtator text source" instance from a TextSource object. All instances of "knowtator text source" can be created in a very simplistic way from a TextSource object. An instance of the class specified by the name returned by getProtegeClsName() is created with the name returned by getName()

Specified by:
createTextSourceInstance in interface TextSource
Returns:
may return null if textSource.getProtegeClsName() is not a known cls name. Otherwise the new Protege instance that has been created.

hashCode

public int hashCode()
Specified by:
hashCode in interface TextSource
Overrides:
hashCode in class Object

equals

public boolean equals(Object object)
Specified by:
equals in interface TextSource
Overrides:
equals in class Object

toString

public String toString()
Specified by:
toString in interface TextSource
Overrides:
toString in class Object

getText

public String getText(List<Span> annotationSpans)
               throws TextSourceAccessException
Description copied from interface: TextSource
Returns the text corresponding to the spans passed in. Typically, a single span will be passed in and the text corresponding to that text will be returned. If there are multiple spans, some extra decisions need to be made such as what the delimiter between spans will be and whether the spans should be sorted first.

Specified by:
getText in interface TextSource
Throws:
TextSourceAccessException

getText

public static String getText(List<Span> annotationSpans,
                             String text)
                      throws TextSourceAccessException
Throws:
TextSourceAccessException