1 /* Copyright (c) 2011 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
18 package compbio.data.sequence;
\r
20 public class Range implements Comparable<Range> {
\r
22 public final int from;
\r
23 public final int to;
\r
26 // JAXB default constructor should not be used
\r
31 public Range(int from, int to) {
\r
36 public Range(String[] twoElementAr) {
\r
37 if (twoElementAr == null || twoElementAr.length != 2) {
\r
38 throw new IllegalArgumentException();
\r
40 this.from = Integer.parseInt(twoElementAr[0].trim());
\r
41 this.to = Integer.parseInt(twoElementAr[1].trim());
\r
45 public String toString() {
\r
46 return from + "-" + to;
\r
50 public int hashCode() {
\r
51 final int prime = 31;
\r
53 result = prime * result + from;
\r
54 result = prime * result + to;
\r
58 public boolean equals(Object obj) {
\r
63 if (getClass() != obj.getClass())
\r
65 Range other = (Range) obj;
\r
66 if (from != other.from)
\r
74 public int compareTo(Range o) {
\r
77 return new Integer(this.from).compareTo(new Integer(o.from));
\r