Class SimplePosition

  • All Implemented Interfaces:
    Position

    public class SimplePosition
    extends java.lang.Object
    implements Position
    A simple implementation of the Position interface.
    Since:
    1.5
    Author:
    Richard Holland
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected SimplePosition()  
        SimplePosition​(boolean fs, boolean fe, int p)
      Constructs a point position, with optionally fuzzy start and end.
        SimplePosition​(boolean fs, boolean fe, int s, int e, java.lang.String t)
      Constructs a range position, with optionally fuzzy start and end.
        SimplePosition​(int p)
      Constructs a point position, with no fuzzy start or end.
        SimplePosition​(int s, int e)
      Constructs a range position, with no fuzzy start or end.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      Two positions are equal if they share all parameters in common, eg.
      int getEnd()
      Returns the end of the range of bases this base could lie in.
      boolean getFuzzyEnd()
      Returns true if the position has a fuzzy end.
      boolean getFuzzyStart()
      Returns true if the position has a fuzzy start.
      java.lang.Integer getId()
      Gets the Hibernate ID.
      int getStart()
      Returns the beginning of the range of bases this base could lie in.
      java.lang.String getType()
      Returns the type of this position if it is not a point/single position.
      void setId​(java.lang.Integer id)
      Sets the Hibernate ID.
      java.lang.String toString()
      Position translate​(int distance)
      Takes this position and returns a copy translated by 'distance' bases.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SimplePosition

        public SimplePosition​(int p)
        Constructs a point position, with no fuzzy start or end. (eg. 1, 2, or 3).
        Parameters:
        p - the point position
      • SimplePosition

        public SimplePosition​(int s,
                              int e)
        Constructs a range position, with no fuzzy start or end. (eg. 1..2, 2..5, or 3..8).
        Parameters:
        s - the start position
        e - the end position
      • SimplePosition

        public SimplePosition​(boolean fs,
                              boolean fe,
                              int p)
        Constructs a point position, with optionally fuzzy start and end. (eg. <1 or 3> or 2 or even <5>).
        Parameters:
        fs - fuzzy start?
        fe - fuzzy end?
        p - the point position
      • SimplePosition

        public SimplePosition​(boolean fs,
                              boolean fe,
                              int s,
                              int e,
                              java.lang.String t)
        Constructs a range position, with optionally fuzzy start and end. (eg. <1.2 or 1^3> or 2.2 or even <5^6>). The type of the range is given, it should normally be one of the two defined in the Position interface, but its up to you.
        Parameters:
        fs - fuzzy start?
        fe - fuzzy end?
        s - the start of the position
        e - the end of the position
        t - the type of the position
      • SimplePosition

        protected SimplePosition()
    • Method Detail

      • getFuzzyStart

        public boolean getFuzzyStart()
        Returns true if the position has a fuzzy start.
        Specified by:
        getFuzzyStart in interface Position
        Returns:
        the fuzziness of the start.
      • getFuzzyEnd

        public boolean getFuzzyEnd()
        Returns true if the position has a fuzzy end.
        Specified by:
        getFuzzyEnd in interface Position
        Returns:
        the fuzziness of the end.
      • getStart

        public int getStart()
        Returns the beginning of the range of bases this base could lie in. If this position is a single position, then start=end.
        Specified by:
        getStart in interface Position
        Returns:
        the start of this position.
      • getEnd

        public int getEnd()
        Returns the end of the range of bases this base could lie in. If this position is a single position, then start=end.
        Specified by:
        getEnd in interface Position
        Returns:
        the end of this position.
      • getType

        public java.lang.String getType()
        Returns the type of this position if it is not a point/single position. Types are usually BETWEEN_BASES or IN_RANGE but could be any string value.
        Specified by:
        getType in interface Position
        Returns:
        the type of this position.
      • translate

        public Position translate​(int distance)
        Takes this position and returns a copy translated by 'distance' bases.
        Specified by:
        translate in interface Position
        Parameters:
        distance - the distance to translate it.
        Returns:
        the translated position.
      • equals

        public boolean equals​(java.lang.Object o)
        Two positions are equal if they share all parameters in common, eg. fuzzy start+end, start, end, type.
        Overrides:
        equals in class java.lang.Object
      • toString

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

        public java.lang.Integer getId()
        Gets the Hibernate ID. Should be used with caution.
        Returns:
        the Hibernate ID, if using Hibernate.
      • setId

        public void setId​(java.lang.Integer id)
        Sets the Hibernate ID. Should be used with caution.
        Parameters:
        id - the Hibernate ID, if using Hibernate.