Class Timex

java.lang.Object
edu.fiu.jtlex.data.Timex
All Implemented Interfaces:
INode, ITimex

public class Timex extends Object implements ITimex
Default implementation of ITimex.
Since:
Revision 35
Author:
ceber003
  • Constructor Details

    • Timex

      public Timex(int tID, ITimex.TimexType type, String value, ITimex.TimexMod mod, boolean temporalFunction, int anchorID, ITimex.FunctionInDocument documentFunction, int beginPoint, int endPoint, String quant, String freq, String phrase)
      Creates a new Timex with the specified information.
      Parameters:
      tID - id of the timex; may not be negative
      type - the type of the timex may not be null
      value - the value attribute of the timex
      mod - the mod of the value, is optional
      temporalFunction - true or false
      anchorID - the id of another timex anchored to the current timex, optional
      documentFunction - the function a timex is providing within the document, is 'NONE' when not specified.
      beginPoint - beginpoint is used if the timex is anchored to another, can be null
      endPoint - end is used if timex is anchored to another timex, can be null
      quant - used only if timex type is 'SET' is the literal describing the timex rate of occurrence
      freq - used only if timex type is 'SET' is the frequency the timex occurs
      phrase - the phase associated with this this timex.
      Throws:
      NullPointerException - if type or value is null
      IllegalArgumentException - if tID, anchorId, beginPoint, or endPoint is negative
  • Method Details

    • getValueDigits

      public boolean getValueDigits(String value)
      Returns true if the the value is at least 4 digits. Also checks if value equals PXY, PAST_REF, PRESENT_REF or FUTURE_REF to return true. Will return false if null.
      Parameters:
      value - a String that contains a numeric value
      Returns:
      true if the value has at least 4 digits
      Since:
      Revision 642
    • getId

      public int getId()
      Returns the tID of the timex. Will never be null as it is required for the constructor.
      Specified by:
      getId in interface INode
      Specified by:
      getId in interface ITimex
      Returns:
      the tID of the timex.
      Since:
      Revision 35
    • getIdStr

      public String getIdStr()
      Grabs the tID, adds a t to the front for String format and returns. Will never be null since the tID was required in the constructor.
      Specified by:
      getIdStr in interface INode
      Specified by:
      getIdStr in interface ITimex
      Returns:
      the tID of the timex in String format.
      Since:
      Revision 35
    • getType

      public ITimex.TimexType getType()
      Returns the type of the timex.
      Specified by:
      getType in interface INode
      Specified by:
      getType in interface ITimex
      Returns:
      the type of the timex.
      Since:
      Revision 35
    • getValue

      public String getValue()
      Returns the string representation of the value. The value of the the timex tag determines what the actual amount of time for the date, time, duration, and set types. Will never be null as it is required in the constructor.
      Specified by:
      getValue in interface ITimex
      Returns:
      the string representation of the value.
      Since:
      Revision 35
    • getMod

      public ITimex.TimexMod getMod()
      Returns the mod to which the object belongs. This value is optional and can be null.
      Specified by:
      getMod in interface ITimex
      Returns:
      the mod to which the object belongs.
      Since:
      Revision 35
      See Also:
    • getTemporalFunction

      public boolean getTemporalFunction()
      Returns the inary attribute which expresses that the value of the temporal expression needs to be determined via evaluation of a temporal function. Cannot be null as is a required boolean.
      Specified by:
      getTemporalFunction in interface ITimex
      Returns:
      the inary attribute which expresses that the value of the temporal expression needs to be determined via evaluation of a temporal function.
      Since:
      Revision 90
    • getAnchorTimeId

      public int getAnchorTimeId()
      Returns the integer part of the anchortimeId. Each anchortime has to be identified by a unique ID number. This value is optional. If included, it must not be negative.
      Specified by:
      getAnchorTimeId in interface ITimex
      Returns:
      the integer part of the anchortimeId.
      Since:
      Revision 35
    • getAnchorTimeIdStr

      public String getAnchorTimeIdStr()
      Returns the string part of the anchortimeId. Each anchortime has to be identified by a unique ID number. This value is optional. If included, it must not be negative.
      Specified by:
      getAnchorTimeIdStr in interface ITimex
      Returns:
      the string part of the anchortimeId. May not be null.
      Since:
      Revision 35
    • getFunction

      public ITimex.FunctionInDocument getFunction()
      Returns the function to which the object belongs. Function in document can be one of seven values. If it is not specified then it will be set as 'NONE' by default. It can be set to null.
      Specified by:
      getFunction in interface ITimex
      Returns:
      the function to which the object belongs.
      Since:
      Revision 35
    • getBeginPoint

      public int getBeginPoint()
      Returns the integer part of the beginpointId. Beginpoint is only used if the expression is anchored to another timex expression. Each beginpoint has to be identified by a unique ID number. If only endpoint is provided may create an empty timex to fill in. It cannot be null, as it is required in constructor. It cannot be negative either.
      Specified by:
      getBeginPoint in interface ITimex
      Returns:
      the integer part of the beginpointId. May not be negative
      Since:
      Revision 35
    • getBeginPointStr

      public String getBeginPointStr()
      Returns the string part of the beginpointId. Beginpoint is only used if the expression is anchored to another timex expression. Each beginpoint has to be identified by a unique ID number. If only endpoint is provided may create an empty timex to fill in. It cannot be null as it is required in constructor. It cannot be negative either.
      Specified by:
      getBeginPointStr in interface ITimex
      Returns:
      the string part of the beginpointId.
      Since:
      Revision 35
    • getEndPoint

      public int getEndPoint()
      Returns the integer part of the endpointId. Endpoint is only used if the expression is anchored to another timex expression. Each endpoint has to be identified by a unique ID number. If only beginpoint is provided may create an empty timex to fill in. It cannot be null as it is required in constructor. It cannot be negative either.
      Specified by:
      getEndPoint in interface ITimex
      Returns:
      the integer part of the endpointId.
      Since:
      Revision 35
    • getEndPointStr

      public String getEndPointStr()
      Returns the string part of the endpointId. Endpoint is only used if the expression is anchored to another timex expression. Each endpoint has to be identified by a unique ID number. If only beginpoint is provided may create an empty timex to fill in. It cannot be null as it is required in constructor. It cannot be negative either.
      Specified by:
      getEndPointStr in interface ITimex
      Returns:
      the string part of the endpointId.
      Since:
      Revision 35
    • getQuant

      public String getQuant()
      Returns the quantity to which the object belongs. The quant value is only used if the timex type is 'SET'. It can be set to null.
      Specified by:
      getQuant in interface ITimex
      Returns:
      the quantity to which the object belongs.
      Since:
      Revision 35
    • getFreq

      public String getFreq()
      Returns frequency String portion. The frequency value is only used if the timex type is 'SET'. The integer value determines the number of time the frequency takes. i.e: 2 Weeks, 3 Months, 1 Day, etc. It can be set to null.
      Specified by:
      getFreq in interface ITimex
      Returns:
      frequency String portion.
      Since:
      Revision 35
    • getPhrase

      public String getPhrase()
      Returns the phrase from the text annotated as timex. It can be set to null.
      Specified by:
      getPhrase in interface ITimex
      Returns:
      the phrase from the text annotated as timex.
      Since:
      Revision 90
    • addOutLink

      public void addOutLink(ILink link)
      Add a link to the set of OUT links from this node. It can be set to null.
      Specified by:
      addOutLink in interface INode
      Specified by:
      addOutLink in interface ITimex
      Parameters:
      link - : A new OUT link from this node.
      Since:
      Revision 151
    • addInLink

      public void addInLink(ILink link)
      Add a link to the set of IN links from this node. It can be set to null.
      Specified by:
      addInLink in interface INode
      Specified by:
      addInLink in interface ITimex
      Parameters:
      link - : A new IN link incoming to this node.
      Since:
      Revision 151
    • getOutLinks

      public Set<ILink> getOutLinks()
      Returns the set of TimeML links which come from this node. It can return null as is empty at first.
      Specified by:
      getOutLinks in interface INode
      Specified by:
      getOutLinks in interface ITimex
      Returns:
      the set of TimeML links which come from this node.
      Since:
      Revision 189
    • getInLinks

      public Set<ILink> getInLinks()
      Returns the set of TimeML links which come to this node. It can return null as is empty at first.
      Specified by:
      getInLinks in interface INode
      Specified by:
      getInLinks in interface ITimex
      Returns:
      the set of TimeML links which come to this node.
      Since:
      Revision 189
    • removeOutLink

      public void removeOutLink(ILink link)
      Removes a TimeML link from the set of links that start in this node. It can send in a null link but won't remove anything. Similarly if the link isn't in the list, it won't remove anything.
      Specified by:
      removeOutLink in interface INode
      Specified by:
      removeOutLink in interface ITimex
      Parameters:
      link - a new OUT link to remove from the set of outgoing links.
      Since:
      Revision 189
    • removeInLink

      public void removeInLink(ILink link)
      Removes a TimeML link from the set of links that end in this node. It can send in a null link but won't remove anything. Similarly if the link isn't in the list, it won't remove anything.
      Specified by:
      removeInLink in interface INode
      Specified by:
      removeInLink in interface ITimex
      Parameters:
      link - a new In link to remove from the set of incoming links.
      Since:
      Revision 189
    • toString

      public String toString()
      Returns the info of the Timex in String format. Will never return null.
      Specified by:
      toString in interface ITimex
      Overrides:
      toString in class Object
      Returns:
      the info of the Timex in String format.
      Since:
      Revision 386
    • toJSON

      public String toJSON()
      Converts the Timex and its info into JSON format. Will never return null.
      Specified by:
      toJSON in interface INode
      Specified by:
      toJSON in interface ITimex
      Returns:
      the JSON format of the Timex.
      Since:
      Revision 391
    • clone

      public Timex clone()
      Creates and returns a copy of the Timex. Will never return null.
      Specified by:
      clone in interface INode
      Specified by:
      clone in interface ITimex
      Returns:
      a copy of the Timex.
      Since:
      Revision 394