/*
** Module   : ExclusionRegion.java
** Abstract : represent a portion of a stream or line that is to be excluded
**            from comparisons
**
** Copyright (c) 2009, Golden Code Development Corporation.
**
** -#- -I- --Date-- -----------------------Description------------------------
** 001 GES 20090218 Represent a portion of a stream or line that is to be
**                  excluded from comparisons.
*/

/*
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Affero General Public License as
** published by the Free Software Foundation, either version 3 of the
** License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License
** along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package com.goldencode.harness.test;

/**
 * Represent a portion of a stream or line that is to be excluded from
 * comparisons.
 */
public class ExclusionRegion
{
   /** Starting index. */
   protected long start = -1;
   
   /** Ending index. */
   protected long end = -1;
   
   /**
    * Create an instance given explicit starting and ending indexes.
    *
    * @param    start
    *           Starting index.
    * @param    end
    *           Ending index.
    */
   public ExclusionRegion(long start, long end)
   {
      this.start = start;
      this.end   = end;
   }
   
   /**
    * Get the starting index.
    *
    * @return   The index.
    */
   public long getStart()
   {
      return start;
   }
   
   /**
    * Get the ending index.
    *
    * @return   The index.
    */
   public long getEnd()
   {
      return end;
   }
   
   /**
    * Report if the given index is contained in the exclusion region, with the
    * specific starting and ending indices considered on an inclusive basis.
    * This means that if the given index is equal to either the starting or
    * ending index, it is considered contained.
    * 
    * @param    num
    *           Zero-based index to check.
    *
    * @return   <code>true</code> if the given index is between the starting
    *           and ending indices or is equal to either index.
    */
   public boolean contains(long num)
   {
      return (start <= num && end >= num);
   }
   
   /**
    * Obtain a descriptive string representation of this instance.
    *
    * @return   The details of this instance.
    */
   public String toString()
   {
      return String.format("(bytes %d - %d)", start, end);
   }
}
