KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > build > Build


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM 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
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.core.build;
12
13 import java.io.PrintWriter JavaDoc;
14 import java.util.ArrayList JavaDoc;
15
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.pde.core.IModelChangedEvent;
18 import org.eclipse.pde.core.ModelChangedEvent;
19 import org.eclipse.pde.core.build.IBuild;
20 import org.eclipse.pde.core.build.IBuildEntry;
21
22 public class Build extends BuildObject implements IBuild {
23     protected ArrayList JavaDoc fEntries = new ArrayList JavaDoc();
24
25     public void add(IBuildEntry entry) throws CoreException {
26         ensureModelEditable();
27         fEntries.add(entry);
28         ((BuildEntry) entry).setInTheModel(true);
29         getModel().fireModelChanged(
30                 new ModelChangedEvent(getModel(), IModelChangedEvent.INSERT,
31                         new Object JavaDoc[] { entry }, null));
32     }
33
34     public IBuildEntry[] getBuildEntries() {
35         return (IBuildEntry[])fEntries.toArray(new IBuildEntry[fEntries.size()]);
36     }
37
38     public IBuildEntry getEntry(String JavaDoc name) {
39         for (int i = 0; i < fEntries.size(); i++) {
40             IBuildEntry entry = (IBuildEntry) fEntries.get(i);
41             if (entry.getName().equals(name))
42                 return entry;
43         }
44         return null;
45     }
46
47     public void processEntry(String JavaDoc name, String JavaDoc value) {
48         BuildEntry entry = (BuildEntry) getModel().getFactory().createEntry(
49                 name);
50         fEntries.add(entry);
51         entry.processEntry(value);
52     }
53
54     public void remove(IBuildEntry entry) throws CoreException {
55         ensureModelEditable();
56         fEntries.remove(entry);
57         getModel().fireModelChanged(
58                 new ModelChangedEvent(getModel(), IModelChangedEvent.REMOVE,
59                         new Object JavaDoc[] { entry }, null));
60     }
61
62     public void reset() {
63         fEntries.clear();
64     }
65
66     public void write(String JavaDoc indent, PrintWriter JavaDoc writer) {
67         for (int i = 0; i < fEntries.size(); i++) {
68             IBuildEntry entry = (IBuildEntry) fEntries.get(i);
69             entry.write("", writer); //$NON-NLS-1$
70
}
71     }
72 }
73
Popular Tags