gov.nih.nlm.umls.meta.impl
Class StringContextImpl

java.lang.Object
  extended bygov.nih.nlm.umls.meta.impl.StringContextImpl
All Implemented Interfaces:
AtomElement, Comparable, SourceElement, StringContext

public class StringContextImpl
extends Object
implements StringContext

Default implementation of the StringContext interface.

Author:
Brian Carlsen, Deborah Shapiro

Nested Class Summary
 
Nested classes inherited from class gov.nih.nlm.umls.meta.AtomElement
AtomElement.ByLanguageRestrictor, AtomElement.BySourceRestrictor
 
Nested classes inherited from class gov.nih.nlm.umls.meta.SourceElement
SourceElement.BySourceComparator, SourceElement.BySourceRestrictor
 
Constructor Summary
StringContextImpl()
          Instantiates an empty StringContext.
StringContextImpl(StringContext sc)
          Instantiates a StringContext from the specified StringContext.
 
Method Summary
 void addSourceContext(SourceContext sc)
          Adds the specified SourceContext.
 void clearSourceContexts()
          Removes all SourceContexts.
 int compareTo(Object o)
          Compares this StringContext to another one.
 boolean equals(Object o)
          Returns true if the specified object is equal to this object.
 Atom getAtom()
          Returns the Atom for this StringContext.
 ContextGroup getContextGroup()
          Returns the ContextGroup that holds this StringContext.
 String getKeyFields()
          Returns a String key which can be used by equals, compareTo, and hashCode methods.
 Source getSource()
          Returns the source for this StringContext.
 SourceContext[] getSourceContexts()
          Returns all SourceContexts.
 List getSourceContextsAsList()
          Returns all SourceContexts as a List.
 int hashCode()
          Return a hash code based on key fields.
 void removeSourceContext(SourceContext sc)
          Removes the specified SourceContext.
 void setAtom(Atom atom)
          Sets the source for this StringContext.
 void setContextGroup(ContextGroup cg)
          Sets the ContextGroup that holds this StringContext.
 void setSource(Source source)
          Sets the source for this StringContext.
 void setSourceContexts(List scs)
          Replace the SourceContexts with the ones in the specified List.
 void setSourceContexts(SourceContext[] scs)
          Replace the SourceContexts with the ones in the specified array.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringContextImpl

public StringContextImpl()
Instantiates an empty StringContext.


StringContextImpl

public StringContextImpl(StringContext sc)
Instantiates a StringContext from the specified StringContext.

Parameters:
sc - StringContext to be copied
Method Detail

getContextGroup

public ContextGroup getContextGroup()
Returns the ContextGroup that holds this StringContext.

Specified by:
getContextGroup in interface StringContext
Returns:
the ContextGroup that holds this StringContext

setContextGroup

public void setContextGroup(ContextGroup cg)
Sets the ContextGroup that holds this StringContext.

Specified by:
setContextGroup in interface StringContext
Parameters:
cg - the ContextGroup that holds this StringContext

getSourceContexts

public SourceContext[] getSourceContexts()
Returns all SourceContexts.

Specified by:
getSourceContexts in interface StringContext
Returns:
an array of SourceContexts

getSourceContextsAsList

public List getSourceContextsAsList()
Returns all SourceContexts as a List.

Specified by:
getSourceContextsAsList in interface StringContext
Returns:
a List of SourceContexts

addSourceContext

public void addSourceContext(SourceContext sc)
Adds the specified SourceContext.

Specified by:
addSourceContext in interface StringContext
Parameters:
sc - the SourceContext to be added

removeSourceContext

public void removeSourceContext(SourceContext sc)
Removes the specified SourceContext.

Specified by:
removeSourceContext in interface StringContext
Parameters:
sc - the SourceContext to be removed

clearSourceContexts

public void clearSourceContexts()
Removes all SourceContexts.

Specified by:
clearSourceContexts in interface StringContext

setSourceContexts

public void setSourceContexts(SourceContext[] scs)
Replace the SourceContexts with the ones in the specified array.

Specified by:
setSourceContexts in interface StringContext
Parameters:
scs - a SourceContext[]

setSourceContexts

public void setSourceContexts(List scs)
Replace the SourceContexts with the ones in the specified List.

Specified by:
setSourceContexts in interface StringContext
Parameters:
scs - a List of SourceContexts

getAtom

public Atom getAtom()
Returns the Atom for this StringContext.

Specified by:
getAtom in interface AtomElement
Returns:
Atom

setAtom

public void setAtom(Atom atom)
Sets the source for this StringContext.

Specified by:
setAtom in interface AtomElement
Parameters:
atom - Source

getSource

public Source getSource()
Returns the source for this StringContext.

Specified by:
getSource in interface SourceElement
Returns:
Source

setSource

public void setSource(Source source)
Sets the source for this StringContext.

Specified by:
setSource in interface SourceElement
Parameters:
source - Source

getKeyFields

public String getKeyFields()
Returns a String key which can be used by equals, compareTo, and hashCode methods.

Specified by:
getKeyFields in interface StringContext
Returns:
a String composed from the cui, aui, sui, versioned source, tty, and code.

hashCode

public int hashCode()
Return a hash code based on key fields.

Returns:
a hash code based on key fields

equals

public boolean equals(Object o)
Returns true if the specified object is equal to this object. The specified object must be an StringContext with matching key fields.

Parameters:
o - an Object to compare against
Returns:
boolean true if Object o is equal false otherwise

compareTo

public int compareTo(Object o)
Compares this StringContext to another one. Results are indeterminate if the specified parameter is not of the same class.

Specified by:
compareTo in interface Comparable
Parameters:
o - the Object to compare to
Returns:
int representing the relative ordering of this and the compare-to object


Copyright ©2005