KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cpmake > BuildAction


1 /*
2  * Copyright (c) 2004, Brian Hawkins
3  * brianhks@activeclickweb.com
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the Free
7  * Software Foundation; either version 2 of the License, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13  * for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the
17  * Free Software Foundation, Inc.,
18  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */

20  
21
22
23 package cpmake;
24
25 import java.util.*;
26
27 class BuildAction extends Observable
28         implements Observer
29     {
30     private String JavaDoc m_target;
31     private Rule m_targetRule;
32     private int m_dependencyCount;
33     
34     public BuildAction(String JavaDoc target, Rule targetRule)
35         {
36         m_target = target;
37         m_targetRule = targetRule;
38         m_dependencyCount = 0;
39         }
40         
41     public String JavaDoc getTarget()
42         {
43         return (m_target);
44         }
45         
46     public Rule getTargetRule()
47         {
48         return (m_targetRule);
49         }
50         
51     public boolean equals(Object JavaDoc o)
52         {
53         boolean ret = false;
54         
55         if (o instanceof BuildAction)
56             {
57             ret = ((BuildAction)o).getTarget().equals(m_target);
58             }
59         return (ret);
60         }
61         
62     public void update(Observable o, Object JavaDoc arg)
63         {
64         synchronized(this)
65             {
66             m_dependencyCount--;
67             }
68         }
69         
70     public int getDependencyCount()
71         {
72         return (m_dependencyCount);
73         }
74         
75     public void addDependencies(BuildAction[] ba)
76         {
77         //this is done in a single thread, no need to synchronize
78
if (ba.length > 0)
79             {
80             for (int I = 0; I < ba.length; I++)
81                 {
82                 m_dependencyCount++;
83                 ba[I].addObserver(this);
84                 }
85             }
86         }
87         
88     //Marks this BuildAction complete and notifies all dependents
89
public void complete()
90         {
91         setChanged();
92         notifyObservers();
93         clearChanged();
94         }
95         
96     }
97
Popular Tags