Interval.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package middlewares;
  7. /**
  8. *
  9. * @author EUGENIO CARVALHO
  10. */
  11. public class Interval {
  12. // Define a primeira ocorrencia do intervalo
  13. public int Start;
  14. // Define a primeira ocorrencia do intervalo
  15. public int End;
  16. // Define a ultima ocorrencia registrada no intervalo
  17. protected Integer LastOcorrence;
  18. // Define o registrador do intervalo
  19. public String Register = "";
  20. protected boolean persist;
  21. public Interval(Integer start, Integer end, Integer last) {
  22. Start = start;
  23. End = end;
  24. LastOcorrence = last;
  25. persist = false;
  26. }
  27. public int getStart() {
  28. return Start;
  29. }
  30. public void setStart(int Start) {
  31. this.Start = Start;
  32. }
  33. public int getEnd() {
  34. return End;
  35. }
  36. public void setEnd(int End) {
  37. this.End = End;
  38. }
  39. public String getRegister() {
  40. return Register;
  41. }
  42. public void setRegister(String Register) {
  43. this.Register = Register;
  44. }
  45. boolean Alive(int position) {
  46. return position <= End;
  47. }
  48. void Close(int position) {
  49. // System.out.println("Close with position " + position);
  50. End = position;
  51. }
  52. void Close() {
  53. // System.out.println("Close with last");
  54. End = LastOcorrence;
  55. }
  56. @Override
  57. public String toString() {
  58. return "[S: " + Start + ", L: " + LastOcorrence + ", E: " + End + ", R:" + Register + "]";
  59. }
  60. public boolean Inside(int i) {
  61. // return Start <= i && i <= ((End < this.LastOcorrence) ? this.LastOcorrence : End);
  62. return Start <= i && i <= End;
  63. }
  64. public boolean RegisterDefined() {
  65. return !Register.equals("");
  66. }
  67. public boolean Perisist() {
  68. return this.persist;
  69. }
  70. public boolean Perisist(boolean p) {
  71. return this.persist = p;
  72. }
  73. public Integer getLastOcorrence() {
  74. return LastOcorrence;
  75. }
  76. public void setLastOcorrence(Integer LastOcorrence) {
  77. this.LastOcorrence = LastOcorrence;
  78. }
  79. public boolean isPersist() {
  80. return persist;
  81. }
  82. public void setPersist(boolean persist) {
  83. this.persist = persist;
  84. }
  85. }