TUM CCSM Commons

edu.tum.cs.commons.region
Class Region

java.lang.Object
  extended by edu.tum.cs.commons.region.Region
All Implemented Interfaces:
java.lang.Comparable<Region>

public final class Region
extends java.lang.Object
implements java.lang.Comparable<Region>

Regions represent intervals. Both the start and the end position are considered to be part of the region. Regions can i.e. be used to represent fragments of files.

This class is immutable.

Version:
$Revision: 26268 $
Author:
Elmar Juergens, $Author: juergens $
Rating:
GREEN Hash: 7B5A6EE152CFF787B1C23A03B25BD6AE

Field Summary
static java.lang.String UNKNOWN_ORIGIN
          Name that is used if region is created without name
 
Constructor Summary
Region(int start, int end)
          Creates a region with an unknown origin
Region(int start, int end, java.lang.String origin)
          Creates a region with an origin
 
Method Summary
 boolean adjacent(Region r)
          Checks if two regions are adjacent
 int compareTo(Region compareTo)
          Compares regions by their start position
 boolean containsPosition(int position)
          Checks if the region contains a position
 int getEnd()
          Gets the end position of the region
 int getLength()
          Gets the length of the region
 java.lang.String getOrigin()
          Get origin.
 int getStart()
          Gets the start position of the region
 boolean overlaps(Region r)
          Checks if two regions are overlapping
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN_ORIGIN

public static final java.lang.String UNKNOWN_ORIGIN
Name that is used if region is created without name

See Also:
Constant Field Values
Constructor Detail

Region

public Region(int start,
              int end,
              java.lang.String origin)
Creates a region with an origin

Parameters:
start - Start position of the region
end - End position of the region
origin - Region origin. (i.e. region producer)

Region

public Region(int start,
              int end)
Creates a region with an unknown origin

Parameters:
start - Start position of the region
end - End position of the region
Method Detail

containsPosition

public boolean containsPosition(int position)
Checks if the region contains a position


overlaps

public boolean overlaps(Region r)
Checks if two regions are overlapping


adjacent

public boolean adjacent(Region r)
Checks if two regions are adjacent


getOrigin

public java.lang.String getOrigin()
Get origin.


getEnd

public int getEnd()
Gets the end position of the region


getStart

public int getStart()
Gets the start position of the region


getLength

public int getLength()
Gets the length of the region


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(Region compareTo)
Compares regions by their start position

Specified by:
compareTo in interface java.lang.Comparable<Region>

TUM CCSM Commons

TUM CCSM Commons - 2.7