~ubuntu-branches/ubuntu/natty/cobertura/natty

« back to all changes in this revision

Viewing changes to src/net/sourceforge/cobertura/coveragedata/PackageData.java

  • Committer: Bazaar Package Importer
  • Author(s): Miguel Landaeta
  • Date: 2010-05-11 19:21:46 UTC
  • mfrom: (0.1.4 sid) (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100511192146-j742v5jsl89ztndu
Tags: 1.9.4.1+dfsg-2
* Now Build-Depends on libservlet2.5-java and add a missing Depends
  on the same package. (Closes: #580842). 
* Simplify list of JRE dependences for cobertura and drop JRE dependences for
  libcobertura-java as Java libraries are no longer required to depend on a
  JVM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    
49
49
        public void addClassData(ClassData classData)
50
50
        {
51
 
                if (children.containsKey(classData.getBaseName()))
52
 
                        throw new IllegalArgumentException("Package " + this.name
53
 
                                        + " already contains a class with the name "
54
 
                                        + classData.getBaseName());
55
 
 
56
 
                // Each key is a class basename, stored as an String object.
57
 
                // Each value is information about the class, stored as a ClassData object.
58
 
                children.put(classData.getBaseName(), classData);
 
51
                lock.lock();
 
52
                try
 
53
                {
 
54
                        if (children.containsKey(classData.getBaseName()))
 
55
                                throw new IllegalArgumentException("Package " + this.name
 
56
                                                + " already contains a class with the name "
 
57
                                                + classData.getBaseName());
 
58
        
 
59
                        // Each key is a class basename, stored as an String object.
 
60
                        // Each value is information about the class, stored as a ClassData object.
 
61
                        children.put(classData.getBaseName(), classData);
 
62
                }
 
63
                finally
 
64
                {
 
65
                        lock.unlock();
 
66
                }
59
67
        }
60
68
 
61
69
        /**
70
78
 
71
79
        public boolean contains(String name)
72
80
        {
73
 
                return this.children.containsKey(name);
 
81
                lock.lock();
 
82
                try
 
83
                {
 
84
                        return this.children.containsKey(name);
 
85
                }
 
86
                finally
 
87
                {
 
88
                        lock.unlock();
 
89
                }
74
90
        }
75
91
 
76
92
        /**
86
102
                        return false;
87
103
 
88
104
                PackageData packageData = (PackageData)obj;
89
 
                return super.equals(obj) && this.name.equals(packageData.name);
 
105
                getBothLocks(packageData);
 
106
                try
 
107
                {
 
108
                        return super.equals(obj) && this.name.equals(packageData.name);
 
109
                }
 
110
                finally
 
111
                {
 
112
                        lock.unlock();
 
113
                        packageData.lock.unlock();
 
114
                }
90
115
        }
91
116
 
92
117
        public SortedSet getClasses()
93
118
        {
94
 
                return new TreeSet(this.children.values());
 
119
                lock.lock();
 
120
                try
 
121
                {
 
122
                        return new TreeSet(this.children.values());
 
123
                }
 
124
                finally
 
125
                {
 
126
                        lock.unlock();
 
127
                }
95
128
        }
96
129
 
97
130
        public String getName()
107
140
        public Collection getSourceFiles()
108
141
        {
109
142
                SortedMap sourceFileDatas = new TreeMap();
110
 
                Iterator iter = this.children.values().iterator();
111
 
                while (iter.hasNext()) {
112
 
                        ClassData classData = (ClassData)iter.next();
113
 
                        String sourceFileName = classData.getSourceFileName();
114
 
                        SourceFileData sourceFileData = (SourceFileData)sourceFileDatas.get(sourceFileName);
115
 
                        if (sourceFileData == null)
116
 
                        {
117
 
                                sourceFileData = new SourceFileData(sourceFileName);
118
 
                                sourceFileDatas.put(sourceFileName, sourceFileData);
 
143
                
 
144
                lock.lock();
 
145
                try
 
146
                {
 
147
                        Iterator iter = this.children.values().iterator();
 
148
                        while (iter.hasNext()) {
 
149
                                ClassData classData = (ClassData)iter.next();
 
150
                                String sourceFileName = classData.getSourceFileName();
 
151
                                SourceFileData sourceFileData = (SourceFileData)sourceFileDatas.get(sourceFileName);
 
152
                                if (sourceFileData == null)
 
153
                                {
 
154
                                        sourceFileData = new SourceFileData(sourceFileName);
 
155
                                        sourceFileDatas.put(sourceFileName, sourceFileData);
 
156
                                }
 
157
                                sourceFileData.addClassData(classData);
119
158
                        }
120
 
                        sourceFileData.addClassData(classData);
 
159
                }
 
160
                finally
 
161
                {
 
162
                        lock.unlock();
121
163
                }
122
164
                return sourceFileDatas.values();
123
165
        }