PageRenderTime 180ms CodeModel.GetById 170ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/SideKick/sidekick/util/Range.java

#
Java | 55 lines | 21 code | 4 blank | 30 comment | 0 complexity | 829329c7990ed28832d2e6efb9397894 MD5 | raw file
 1/*
 2Copyright (c) 2005, Dale Anson
 3All rights reserved.
 4
 5Redistribution and use in source and binary forms, with or without modification, 
 6are permitted provided that the following conditions are met:
 7
 8    * Redistributions of source code must retain the above copyright notice, 
 9    this list of conditions and the following disclaimer.
10    * Redistributions in binary form must reproduce the above copyright notice, 
11    this list of conditions and the following disclaimer in the documentation 
12    and/or other materials provided with the distribution.
13    * Neither the name of the <ORGANIZATION> nor the names of its contributors 
14    may be used to endorse or promote products derived from this software without 
15    specific prior written permission.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
24ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28package sidekick.util;
29
30/**
31 * Class to represent a range given by 2 Locations in a source file.
32 */
33public class Range {
34    public int startLine = 0;
35    public int startColumn = 0;
36    public int endLine = 0;
37    public int endColumn = 0;
38    
39    public Range(){
40        this(new Location(0, 0), new Location(0, 0));
41    }
42    
43    public Range(Location start, Location end) {
44        Location first = start.compareTo(end) <= 0 ? start : end;
45        Location second = first.equals(start) ? end : start;
46        startLine = first.line;
47        startColumn = first.column;
48        endLine = second.line;
49        endColumn = second.column;
50    }
51    
52    public String toString() {
53        return "Range:[startLine=" + startLine + ",startColumn=" + startColumn + ",endLine=" + endLine + ",endColumn=" + endColumn + "]";   
54    }
55}