1 2 3 package org.quilt.cover.seg; 4 5 import java.util.Iterator ; 6 import java.util.List ; 7 8 13 14 public class Segment { 15 16 17 private int index = -1; 18 19 private int visits = 0; 20 21 private int from = -1; 22 private int to = -1; 23 24 25 public Segment() { 26 } 27 32 33 public Segment (int n) { 34 index = n; 35 } 36 38 public int getFrom() { 39 return from; 40 } 41 42 public void setFrom (int n) { 43 from = n; 44 } 45 46 47 public int getIndex() { 48 return index; 49 } 50 51 public void setIndex (int n) { 52 index = n; 53 } 54 55 56 public int getTo() { 57 return to; 58 } 59 60 public void setTo (int n) { 61 to = n; 62 } 63 64 65 public int getVisits() { 66 return visits; 67 } 68 69 public void reset() { 70 visits = 0; 71 } 72 73 public void setVisits(int n) { 74 visits = n; 75 } 76 82 protected Segment add( final Segment seg ) { 83 visits += seg.getVisits(); 84 return this; 85 } 86 87 public void visit () { 88 visits++; 89 } 90 95 public String toXML(final String type) { 96 return "<" + type + " index=\"" + index 97 + "\" from=\"" + from 98 + "\" to=\"" + to + "\">\n" 99 100 + " <visits>" + visits + "</visits>\n" 101 102 + "</" + type + ">\n"; 103 } 104 105 public String toString () { 106 return "segment " + index + ": " + from + " --> " + to 107 + " : " + visits + " visits"; 108 } 109 } 110 | Popular Tags |