001/*-------------------------------------------------------------------------+ 002| | 003| Copyright (c) 2005-2017 The ConQAT Project | 004| | 005| Licensed under the Apache License, Version 2.0 (the "License"); | 006| you may not use this file except in compliance with the License. | 007| You may obtain a copy of the License at | 008| | 009| http://www.apache.org/licenses/LICENSE-2.0 | 010| | 011| Unless required by applicable law or agreed to in writing, software | 012| distributed under the License is distributed on an "AS IS" BASIS, | 013| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 014| See the License for the specific language governing permissions and | 015| limitations under the License. | 016| | 017+-------------------------------------------------------------------------*/ 018package org.conqat.lib.commons.region; 019 020/** 021 * FuzzyRegions represent intervals with variable size and start index. A fuzzy 022 * region has a start index somewhere between A and B and an end index somewhere 023 * between C and D. FuzzyRegions can, for example, represent the expected 024 * location of a finding after a file-content change. 025 * <p> 026 * The intervals for the start and end indices are represented as 027 * {@link Region}s. 028 * <p> 029 * A {@link FuzzyRegion} is empty if the maximum index in its 030 * {@link FuzzyRegion#endIndexRegion} is smaller than the minimal index in its 031 * {@link FuzzyRegion#startIndexRegion}. 032 * <p> 033 * This class is immutable. 034 */ 035public class FuzzyRegion { 036 /** Region for the startIndex */ 037 private Region startIndexRegion; 038 039 /** Region for the endIndex */ 040 private Region endIndexRegion; 041 042 /** Constructor. */ 043 public FuzzyRegion(Region startIndexRegion, Region endIndexRegion) { 044 this.startIndexRegion = startIndexRegion; 045 this.endIndexRegion = endIndexRegion; 046 } 047 048 /** Constructor. */ 049 public FuzzyRegion(int minNewStartIndex, int maxNewStartIndex, int minNewEndIndex, int maxNewEndIndex) { 050 this(new Region(minNewStartIndex, maxNewStartIndex), new Region(minNewEndIndex, maxNewEndIndex)); 051 } 052 053 /** @see #startIndexRegion */ 054 public Region getStartIndexRegion() { 055 return startIndexRegion; 056 } 057 058 /** @see #endIndexRegion */ 059 public Region getEndIndexRegion() { 060 return endIndexRegion; 061 } 062}