001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021
022package org.biojava.bio.symbol;
023
024import java.io.Serializable;
025
026/**
027 * A location representing a single point.  This can be considered as
028 * the singleton set of one integer.
029 * <p>
030 * min and max are always equal for this implementation
031 * </p>
032 *
033 * @author Matthew Pocock
034 */
035public class PointLocation
036extends AbstractRangeLocation
037implements Location, Serializable {
038  /**
039   * The actual index contained.
040   */
041  private int point;
042
043  public int getMin()   { return point; }
044  public int getMax()   { return point; }
045  public boolean contains(int p)        { return this.point == p; }
046  
047  public Location translate(int dist) {
048      if (dist == 0)
049          return this;
050      return new PointLocation(this.point + dist);
051  }
052  
053  public PointLocation(int point) {
054    this.point = point;
055  }
056  
057  public String toString() {
058    return String.valueOf(point);
059  }
060}