Source Code Cross Referenced for AnalysisModuleSet.java in  » Test-Coverage » GroboUtils » net » sourceforge » groboutils » codecoverage » v2 » datastore » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » GroboUtils » net.sourceforge.groboutils.codecoverage.v2.datastore 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)AnalysisModuleSet.java
003:         *
004:         * Copyright (C) 2002-2003 Matt Albrecht
005:         * groboclown@users.sourceforge.net
006:         * http://groboutils.sourceforge.net
007:         *
008:         *  Permission is hereby granted, free of charge, to any person obtaining a
009:         *  copy of this software and associated documentation files (the "Software"),
010:         *  to deal in the Software without restriction, including without limitation
011:         *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
012:         *  and/or sell copies of the Software, and to permit persons to whom the 
013:         *  Software is furnished to do so, subject to the following conditions:
014:         *
015:         *  The above copyright notice and this permission notice shall be included in 
016:         *  all copies or substantial portions of the Software. 
017:         *
018:         *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
019:         *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
020:         *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL 
021:         *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
022:         *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
023:         *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
024:         *  DEALINGS IN THE SOFTWARE.
025:         */
026:
027:        package net.sourceforge.groboutils.codecoverage.v2.datastore;
028:
029:        import java.util.Hashtable;
030:        import java.util.Vector;
031:
032:        import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModule;
033:
034:        /**
035:         * Contains data associated with each analysis module.
036:         *
037:         * @author    Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
038:         * @version   $Date: 2004/04/15 05:48:26 $
039:         * @since     December 15, 2002
040:         */
041:        public class AnalysisModuleSet {
042:            private Hashtable moduleNameToIndex = new Hashtable();
043:            private Vector moduleList = new Vector();
044:
045:            /**
046:             * Default constructor
047:             */
048:            public AnalysisModuleSet() {
049:                // do nothing
050:            }
051:
052:            /**
053:             * Create an instance using the given array of modules as the default
054:             * set.
055:             *
056:             * @param modules collection of modules to initialize the set with.
057:             * @exception IllegalArgumentException if <tt>modules</tt> is
058:             *      <tt>null</tt>.
059:             */
060:            public AnalysisModuleSet(IAnalysisModule[] modules) {
061:                if (modules == null) {
062:                    throw new IllegalArgumentException("No null args.");
063:                }
064:
065:                addAnalysisModules(modules);
066:            }
067:
068:            /**
069:             * Copy <tt>ams</tt>'s modules into this new set.
070:             *
071:             * @param ams the set to copy from
072:             * @exception IllegalArgumentException if <tt>ams</tt> is <tt>null</tt>.
073:             */
074:            public AnalysisModuleSet(AnalysisModuleSet ams) {
075:                if (ams == null) {
076:                    throw new IllegalArgumentException("No null args.");
077:                }
078:
079:                joinAnalysisModuleSet(ams);
080:            }
081:
082:            /**
083:             * Add an array of modules to this set.
084:             *
085:             * @param modules the array of modules to add to the set
086:             * @exception IllegalArgumentException if <tt>modules</tt> is
087:             *      <tt>null</tt>, or if any element in the array is <tt>null</tt>.
088:             */
089:            public void addAnalysisModules(IAnalysisModule[] modules) {
090:                if (modules == null) {
091:                    throw new IllegalArgumentException("No null args.");
092:                }
093:
094:                for (int i = 0; i < modules.length; ++i) {
095:                    addAnalysisModule(modules[i]);
096:                }
097:            }
098:
099:            /**
100:             * Add a module to the set.
101:             *
102:             * @param module the module to add.
103:             * @exception IllegalArgumentException if <tt>module</tt> is <tt>null</tt>.
104:             * @exception IllegalStateException if <tt>module</tt> has a measure name
105:             *      that is the same as a previously added module.
106:             */
107:            public void addAnalysisModule(IAnalysisModule module) {
108:                if (module == null) {
109:                    throw new IllegalArgumentException("No null args.");
110:                }
111:
112:                String name = module.getMeasureName();
113:
114:                synchronized (this .moduleNameToIndex) {
115:                    if (this .moduleNameToIndex.containsKey(name)) {
116:                        throw new IllegalStateException(
117:                                "Already have module with " + "measure '"
118:                                        + name + "'.");
119:                    }
120:
121:                    int nextIndex = this .moduleList.size();
122:                    if (nextIndex >= Short.MAX_VALUE) {
123:                        throw new IllegalStateException(
124:                                "Too many modules.  There is a maximum of "
125:                                        + Short.MAX_VALUE + " modules allowed.");
126:                    }
127:                    this .moduleNameToIndex.put(name, new Short(
128:                            (short) nextIndex));
129:                    this .moduleList.addElement(module);
130:                }
131:            }
132:
133:            /**
134:             * Join a module set to this set.  It will not add to this set any
135:             * repeated measure names that are in the given set.
136:             *
137:             * @param set the module set to add.
138:             * @exception IllegalArgumentException if <tt>set</tt> is <tt>null</tt>.
139:             */
140:            public void joinAnalysisModuleSet( AnalysisModuleSet set )
141:    {
142:        if (set == null)
143:        {
144:            throw new IllegalArgumentException( "No null args." );
145:        }
146:        
147:        java.util.Enumeration enum = set.moduleList.elements();
148:        while (enum.hasMoreElements())
149:        {
150:            IAnalysisModule module = (IAnalysisModule)enum.nextElement();
151:            String name = module.getMeasureName();
152:            if (!this .moduleNameToIndex.containsKey( name ))
153:            {
154:                addAnalysisModule( module );
155:            }
156:        }
157:    }
158:
159:            /**
160:             * Return a complete list of modules in order.
161:             *
162:             * @return the ordered array of stored modules.
163:             */
164:            public IAnalysisModule[] getAnalysisModules() {
165:                synchronized (this .moduleNameToIndex) {
166:                    int len = this .moduleList.size();
167:                    IAnalysisModule[] am = new IAnalysisModule[len];
168:                    this .moduleList.copyInto(am);
169:                    return am;
170:                }
171:            }
172:
173:            /**
174:             * Retrieves the index associated with the module with the given
175:             * measure name.
176:             *
177:             * @param measureName the measure name of the module.
178:             * @return the index of the module, or -1 if there is no such module
179:             *      with the given measure name.
180:             * @exception IllegalArgumentException if <tt>measureName</tt> is
181:             *      <tt>null</tt>.
182:             * @see #getAnalysisModuleIndex( IAnalysisModule )
183:             */
184:            public short getMeasureIndex(String measureName) {
185:                if (measureName == null) {
186:                    throw new IllegalArgumentException("No null args.");
187:                }
188:                Short i = (Short) this .moduleNameToIndex.get(measureName);
189:                if (i == null) {
190:                    return -1;
191:                }
192:                return i.shortValue();
193:            }
194:
195:            /**
196:             * Returns the module <tt>am</tt>'s index.
197:             *
198:             * @param am the module.
199:             * @return the index of <tt>am</tt>, or -1 if it is not stored in this
200:             *      set.
201:             * @exception IllegalArgumentException if <tt>am</tt> is <tt>null</tt>.
202:             * @see #getMeasureIndex( Stirng )
203:             */
204:            public short getAnalysisModuleIndex(IAnalysisModule am) {
205:                if (am == null) {
206:                    throw new IllegalArgumentException("No null args.");
207:                }
208:                return getMeasureIndex(am.getMeasureName());
209:            }
210:
211:            /**
212:             * Retrieve the number of modules stored in this set.
213:             *
214:             * @return the number of modules in the set.
215:             */
216:            public int getAnalysisModuleCount() {
217:                return this .moduleList.size();
218:            }
219:
220:            /**
221:             * Returns the module stored at the given index <tt>index</tt>.
222:             *
223:             * @return the module at index <tt>index</tt>.
224:             * @exception IllegalArgumentException if <tt>index</tt> is less than 0
225:             *      or greater than or equal to the returned value of
226:             *      <tt>getAnalysisModuleCount()</tt>.
227:             */
228:            public IAnalysisModule getAnalysisModuleAt(short index) {
229:                int iindex = (int) index;
230:                if (iindex < 0 || iindex >= this .moduleList.size()) {
231:                    throw new IllegalArgumentException(
232:                            "index out of range [0.."
233:                                    + (this .moduleList.size() - 1) + "]");
234:                }
235:                return (IAnalysisModule) this.moduleList.elementAt(iindex);
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.