1
/*******************************************************************************
2
* Copyright (c) 2007 Intel Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Intel Corporation - Initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.managedbuilder.internal.tcmodification;
13
import java.util.Collection;
14
import java.util.HashSet;
15
import java.util.Iterator;
18
import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
19
import org.eclipse.cdt.managedbuilder.internal.tcmodification.extension.MatchObjectElement;
21
public class ObjectSet implements IObjectSet {
22
private int fObjectType;
23
private Set fObjectSet;
25
public ObjectSet(int objectType, Set objectSet){
26
fObjectType = objectType;
27
fObjectSet = objectSet;
30
public final int getObjectType() {
34
public IRealBuildObjectAssociation[] getRealBuildObjects() {
35
return (IRealBuildObjectAssociation[])fObjectSet.toArray(new IRealBuildObjectAssociation[fObjectSet.size()]);
38
public Collection getRealBuildObjects(Collection set) {
42
set.addAll(fObjectSet);
47
public boolean matchesObject(IRealBuildObjectAssociation obj) {
48
return fObjectSet.contains(obj.getRealBuildObject());
51
public boolean retainMatches(Collection collection) {
52
return collection.retainAll(fObjectSet);
55
public int getNumObjects() {
56
return fObjectSet.size();
59
public String toString(){
60
StringBuffer buf = new StringBuffer();
61
buf.append(MatchObjectElement.TypeToStringAssociation.getAssociation(fObjectType).getString());
62
buf.append("["); //$NON-NLS-1$
63
boolean isFirst = true;
64
for(Iterator iter = fObjectSet.iterator(); iter.hasNext(); ){
66
buf.append(", "); //$NON-NLS-1$
69
buf.append(((IRealBuildObjectAssociation)iter.next()).getId());
71
buf.append("]"); //$NON-NLS-1$
73
return buf.toString();