41
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
* Base class for TraceLocationList and PersistentLocationList
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
package com.nokia.tracecompiler.engine;
|
|
20 |
|
|
21 |
import java.util.ArrayList;
|
|
22 |
import java.util.Iterator;
|
|
23 |
|
|
24 |
import com.nokia.tracecompiler.model.TraceModelExtension;
|
|
25 |
import com.nokia.tracecompiler.model.TraceObject;
|
|
26 |
|
|
27 |
/**
|
|
28 |
* Base class for TraceLocationList and PersistentLocationList
|
|
29 |
*
|
|
30 |
*/
|
|
31 |
public class LocationListBase implements TraceModelExtension,
|
|
32 |
Iterable<LocationProperties> {
|
|
33 |
|
|
34 |
/**
|
|
35 |
* List of locations
|
|
36 |
*/
|
|
37 |
private ArrayList<LocationProperties> locations = new ArrayList<LocationProperties>();
|
|
38 |
|
|
39 |
/**
|
|
40 |
* Owning trace object
|
|
41 |
*/
|
|
42 |
private TraceObject owner;
|
|
43 |
|
|
44 |
/*
|
|
45 |
* (non-Javadoc)
|
|
46 |
*
|
|
47 |
* @see com.nokia.tracecompiler.model.TraceModelExtension#getOwner()
|
|
48 |
*/
|
|
49 |
public TraceObject getOwner() {
|
|
50 |
return owner;
|
|
51 |
}
|
|
52 |
|
|
53 |
/*
|
|
54 |
* (non-Javadoc)
|
|
55 |
*
|
|
56 |
* @see com.nokia.tracecompiler.model.TraceModelExtension#setOwner(com.nokia.tracecompiler.model.TraceObject)
|
|
57 |
*/
|
|
58 |
public void setOwner(TraceObject owner) {
|
|
59 |
this.owner = owner;
|
|
60 |
}
|
|
61 |
|
|
62 |
/*
|
|
63 |
* (non-Javadoc)
|
|
64 |
*
|
|
65 |
* @see java.lang.Iterable#iterator()
|
|
66 |
*/
|
|
67 |
public Iterator<LocationProperties> iterator() {
|
|
68 |
return locations.iterator();
|
|
69 |
}
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Gets the location count of this list
|
|
73 |
*
|
|
74 |
* @return the count
|
|
75 |
*/
|
|
76 |
public final int getLocationCount() {
|
|
77 |
return locations.size();
|
|
78 |
}
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Checks if there are locations in this list
|
|
82 |
*
|
|
83 |
* @return true if list has locations
|
|
84 |
*/
|
|
85 |
public final boolean hasLocations() {
|
|
86 |
return !locations.isEmpty();
|
|
87 |
}
|
|
88 |
|
|
89 |
/**
|
|
90 |
* Adds a location to this list
|
|
91 |
*
|
|
92 |
* @param location
|
|
93 |
* the location to be added
|
|
94 |
*/
|
|
95 |
void add(LocationProperties location) {
|
|
96 |
locations.add(location);
|
|
97 |
}
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Removes a location from this list
|
|
101 |
*
|
|
102 |
* @param location
|
|
103 |
* the location to be removed
|
|
104 |
* @return true if removed
|
|
105 |
*/
|
|
106 |
boolean remove(LocationProperties location) {
|
|
107 |
return locations.remove(location);
|
|
108 |
}
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Checks if location exists
|
|
112 |
*
|
|
113 |
* @param location
|
|
114 |
* the location
|
|
115 |
* @return true if exists
|
|
116 |
*/
|
|
117 |
boolean contains(LocationProperties location) {
|
|
118 |
return locations.contains(location);
|
|
119 |
}
|
|
120 |
|
|
121 |
}
|