Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 53a19daf91b74f25e7671938d7e297edf3724630 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*******************************************************************************
 * Copyright (c) 2000, 2005 QNX Software Systems and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     QNX Software Systems - Initial API and implementation
 *******************************************************************************/

package org.eclipse.cdt.debug.mi.core.cdi;

import java.math.BigInteger;

import org.eclipse.cdt.debug.core.cdi.ICDILocator;

public class Locator extends Location implements ICDILocator {

	public Locator(String file, String function, int line, BigInteger address) {
		super(file, function, line, address);
	}

	boolean equalFile(String oFile) {
		return equalString(oFile, getFile());
	}

	boolean equalFunction(String oFunction) {
		return equalString(oFunction, getFunction());
	}

	boolean equalLine(int oLine) {
		return oLine == getLineNumber();
	}

	boolean equalAddress(BigInteger oAddress) {
		if (oAddress == null && getAddress() == null) {
			return true;
		}
		if (oAddress != null && oAddress.equals(getAddress())) {
			return true;
		}
		return false;
	}

	public static boolean equalString(String f1, String f2) {
		if (f1 != null && f1.length() > 0 && f2 != null && f2.length() > 0) {
			return f1.equals(f2);
		} else if ((f1 == null || f1.length() == 0) && (f2 == null || f2.length() == 0)) {
			return true;
		}
		return false;		
	}

	public boolean equals(ICDILocator locator) {

		if (locator == this) {
			return true;
		}
		String oFile = locator.getFile();
		String oFunction = locator.getFunction();
		int oLine = locator.getLineNumber();
		BigInteger oAddress = locator.getAddress();

		if (equalFile(oFile) && equalFunction(oFunction) &&
				equalLine(oLine) && equalAddress(oAddress)) {
			return true;
		}
		return false;
	}
}

Back to the top