/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package middlewares; /** * * @author EUGENIO CARVALHO */ public class Interval { // Define a primeira ocorrencia do intervalo public int Start; // Define a primeira ocorrencia do intervalo public int End; // Define a ultima ocorrencia registrada no intervalo protected Integer LastOcorrence; // Define o registrador do intervalo public String Register = ""; protected boolean persist; public Interval(Integer start, Integer end, Integer last) { Start = start; End = end; LastOcorrence = last; persist = false; } public int getStart() { return Start; } public void setStart(int Start) { this.Start = Start; } public int getEnd() { return End; } public void setEnd(int End) { this.End = End; } public String getRegister() { return Register; } public void setRegister(String Register) { this.Register = Register; } boolean Alive(int position) { return position <= End; } void Close(int position) { // System.out.println("Close with position " + position); End = position; } void Close() { // System.out.println("Close with last"); End = LastOcorrence; } @Override public String toString() { return "[S: " + Start + ", L: " + LastOcorrence + ", E: " + End + ", R:" + Register + "]"; } public boolean Inside(int i) { // return Start <= i && i <= ((End < this.LastOcorrence) ? this.LastOcorrence : End); return Start <= i && i <= End; } public boolean RegisterDefined() { return !Register.equals(""); } public boolean Perisist() { return this.persist; } public boolean Perisist(boolean p) { return this.persist = p; } public Integer getLastOcorrence() { return LastOcorrence; } public void setLastOcorrence(Integer LastOcorrence) { this.LastOcorrence = LastOcorrence; } public boolean isPersist() { return persist; } public void setPersist(boolean persist) { this.persist = persist; } }