inpro.incremental.unit
Class IU

java.lang.Object
  extended by inpro.incremental.unit.IU
All Implemented Interfaces:
java.lang.Comparable<IU>
Direct Known Subclasses:
ActionIU, CandidateAnalysisIU, ContribIU, DialogueActIU, FormulaIU, InstallmentIU, PhraseIU, SegmentIU, SemIU, SyllableIU, TagIU, WordIU

public abstract class IU
extends java.lang.Object
implements java.lang.Comparable<IU>


Nested Class Summary
static interface IU.IUUpdateListener
           
static class IU.Progress
          types of temporal progress states the IU may be in
 
Field Summary
private  boolean committed
           
protected  long creationTime
           
static IU FIRST_IU
           
protected  java.util.List<IU> groundedIn
           
protected  java.util.List<IU> grounds
           
private  int id
           
private static int IU_idCounter
           
protected  IUList<IU> nextSameLevelLinks
           
protected  IU previousSameLevelLink
           
private  boolean revoked
           
(package private)  java.util.List<IU.IUUpdateListener> updateListeners
           
 
Constructor Summary
IU()
          this constructor must be called in order to acquire an IU with a valid ID.
IU(IU sll)
          call this, if you want to provide a sameLevelLink
IU(IU sll, java.util.List<? extends IU> groundedIn)
          call this, if you want to provide both a sameLevelLink and a groundedIn list
IU(IU sll, java.util.List<? extends IU> groundedIn, boolean deepSLL)
          call this, if you want to provide a sameLevelLink and a groundedIn list and you want groundedIn to be deeply SLLed to the sameLevelLink's groundedIn-IUs
IU(java.util.List<? extends IU> groundedIn)
           
 
Method Summary
 void addNextSameLevelLink(IU iu)
           
 void addUpdateListener(IU.IUUpdateListener listener)
          this has no effect if listener is already in the list of updatelisteners
 void commit()
          COMMITs this IU.
 int compareTo(IU other)
          the natural ordering of IUs is based on the IU's ids: IUs with lower ids come first
 void connectSLL(IU link)
           
 java.lang.String deepToString()
           
 double duration()
           
 double endTime()
          return the end of the timespan this IU covers
 boolean equals(java.lang.Object iu)
          two IUs are equal if their IDs are the same
 long getAge()
           
 IU getAmongNextSameLevelLinks(java.lang.String bestFollowerPayload)
          get the IU among the nextSLLs with the given payload
 long getCreationTime()
           
 int getID()
          get the ID assigned to this IU
private static int getNewID()
          called to acquire a new ID
 IU getNextSameLevelLink()
           
 java.util.List<IU> getNextSameLevelLinks()
          return the (possibly empty) list of next SLLs
 IU getOngoingGroundedIU()
          return the IU that is ongoing among the groundedIn links
 IU.Progress getProgress()
          by default, an IU - is complete if the last grounding unit is complete, - is upcoming if the first grounding unit is upcoming, - is ongoing if inbetween those two states - is null if there are no grounding units.
 IU getSameLevelLink()
           
 void ground(IU iu)
           
 java.util.List<? extends IU> groundedIn()
           
 void groundIn(IU iu)
           
 void groundIn(java.util.List<IU> ius)
           
 java.util.List<? extends IU> grounds()
           
 int hashCode()
          IDs make for ideal hash codes
 boolean isCommitted()
           
 boolean isCompleted()
           
 boolean isOngoing()
           
 boolean isRevoked()
           
 boolean isUpcoming()
           
private  void newGroundingNextSameLevelLinksOrder(java.util.List<IU> aboveNextSameLevelLinks)
          this is needed to (recursively) correct nextSameLevelLinks in groundedIn IUs
 void notifyListeners()
           
 boolean payloadEquals(IU iu)
          compares IUs based on their payload (i.e., ignoring differing IDs) equals() implies payloadEquals(), but not the other way around
 void removeAllNextSameLevelLinks()
          recursively remove (in grounded IUs) all nextsamelevellinks
 void removeGrin(IU iu)
           
 void removeGrin(java.util.List<IU> ius)
           
 void reorderNextSameLevelLink(java.util.Comparator<IU> order)
           
 void revoke()
          COMMITs this IU.
 void setAsTopNextSameLevelLink(java.lang.String bestFollowerPayload)
           
 void setSameLevelLink(IU link)
           
 double startTime()
          return the start of the timespan this IU covers
 java.lang.String toLabelLine()
           
abstract  java.lang.String toPayLoad()
           
 java.lang.String toString()
           
 java.lang.String toTEDviewXML()
           
 void updateOnGrinUpdates()
          registers an update listener with all groundedIn-IUs that call our own update listeners
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FIRST_IU

public static final IU FIRST_IU

IU_idCounter

private static int IU_idCounter

id

private final int id

previousSameLevelLink

protected IU previousSameLevelLink

nextSameLevelLinks

protected IUList<IU> nextSameLevelLinks

groundedIn

protected java.util.List<IU> groundedIn

grounds

protected java.util.List<IU> grounds

creationTime

protected long creationTime

committed

private boolean committed

revoked

private boolean revoked

updateListeners

java.util.List<IU.IUUpdateListener> updateListeners
Constructor Detail

IU

public IU(IU sll,
          java.util.List<? extends IU> groundedIn,
          boolean deepSLL)
call this, if you want to provide a sameLevelLink and a groundedIn list and you want groundedIn to be deeply SLLed to the sameLevelLink's groundedIn-IUs


IU

public IU(IU sll,
          java.util.List<? extends IU> groundedIn)
call this, if you want to provide both a sameLevelLink and a groundedIn list


IU

public IU(java.util.List<? extends IU> groundedIn)

IU

public IU(IU sll)
call this, if you want to provide a sameLevelLink


IU

public IU()
this constructor must be called in order to acquire an IU with a valid ID.

Method Detail

getNewID

private static int getNewID()
called to acquire a new ID

Returns:
a process-unique ID.

getID

public final int getID()
get the ID assigned to this IU

Returns:
the IU's ID

setSameLevelLink

public void setSameLevelLink(IU link)

addNextSameLevelLink

public void addNextSameLevelLink(IU iu)

getSameLevelLink

public IU getSameLevelLink()

getNextSameLevelLinks

public java.util.List<IU> getNextSameLevelLinks()
return the (possibly empty) list of next SLLs


removeAllNextSameLevelLinks

public void removeAllNextSameLevelLinks()
recursively remove (in grounded IUs) all nextsamelevellinks


getNextSameLevelLink

public IU getNextSameLevelLink()

setAsTopNextSameLevelLink

public void setAsTopNextSameLevelLink(java.lang.String bestFollowerPayload)

getAmongNextSameLevelLinks

public IU getAmongNextSameLevelLinks(java.lang.String bestFollowerPayload)
get the IU among the nextSLLs with the given payload


reorderNextSameLevelLink

public void reorderNextSameLevelLink(java.util.Comparator<IU> order)

newGroundingNextSameLevelLinksOrder

private void newGroundingNextSameLevelLinksOrder(java.util.List<IU> aboveNextSameLevelLinks)
this is needed to (recursively) correct nextSameLevelLinks in groundedIn IUs


connectSLL

public void connectSLL(IU link)

startTime

public double startTime()
return the start of the timespan this IU covers

Returns:
NaN if time is unavailable, a time (in seconds) otherwise

endTime

public double endTime()
return the end of the timespan this IU covers

Returns:
NaN if time is unavailable, a time (in seconds) otherwise

duration

public double duration()
Returns:
the duration of the IU in seconds, that is, endTime() - startTime()

groundedIn

public java.util.List<? extends IU> groundedIn()

grounds

public java.util.List<? extends IU> grounds()

equals

public boolean equals(java.lang.Object iu)
two IUs are equal if their IDs are the same

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
IDs make for ideal hash codes

Overrides:
hashCode in class java.lang.Object

payloadEquals

public boolean payloadEquals(IU iu)
compares IUs based on their payload (i.e., ignoring differing IDs) equals() implies payloadEquals(), but not the other way around


isCommitted

public boolean isCommitted()
Returns:
true if this IU has been committed

commit

public void commit()
COMMITs this IU.


isRevoked

public boolean isRevoked()
Returns:
true if this IU has been revoked

revoke

public void revoke()
COMMITs this IU.


ground

public void ground(IU iu)

removeGrin

public void removeGrin(java.util.List<IU> ius)

removeGrin

public void removeGrin(IU iu)

groundIn

public void groundIn(java.util.List<IU> ius)

groundIn

public void groundIn(IU iu)

isUpcoming

public boolean isUpcoming()

isOngoing

public boolean isOngoing()

isCompleted

public boolean isCompleted()

getProgress

public IU.Progress getProgress()
by default, an IU - is complete if the last grounding unit is complete, - is upcoming if the first grounding unit is upcoming, - is ongoing if inbetween those two states - is null if there are no grounding units.


getOngoingGroundedIU

public IU getOngoingGroundedIU()
return the IU that is ongoing among the groundedIn links

Returns:
the first ongoing grounding IU (or null if none is ongoing)

toPayLoad

public abstract java.lang.String toPayLoad()

toLabelLine

public java.lang.String toLabelLine()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

deepToString

public java.lang.String deepToString()

toTEDviewXML

public java.lang.String toTEDviewXML()

getCreationTime

public long getCreationTime()

getAge

public long getAge()

compareTo

public int compareTo(IU other)
the natural ordering of IUs is based on the IU's ids: IUs with lower ids come first

Specified by:
compareTo in interface java.lang.Comparable<IU>

addUpdateListener

public void addUpdateListener(IU.IUUpdateListener listener)
this has no effect if listener is already in the list of updatelisteners


notifyListeners

public void notifyListeners()

updateOnGrinUpdates

public void updateOnGrinUpdates()
registers an update listener with all groundedIn-IUs that call our own update listeners