Source Code Cross Referenced for ValidateJavaType.java in  » Test-Coverage » GroboUtils » net » sourceforge » groboutils » mbtf » v1 » ant » 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.mbtf.v1.ant 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  @(#)ValidateJavaType.java
003:         *
004:         * Copyright (C) 2002-2003 Matt Albrecht
005:         * groboclown@users.sourceforge.net
006:         * http://groboutils.sourceforge.net
007:         *
008:         *  Part of the GroboUtils package at:
009:         *  http://groboutils.sourceforge.net
010:         *
011:         *  Permission is hereby granted, free of charge, to any person obtaining a
012:         *  copy of this software and associated documentation files (the "Software"),
013:         *  to deal in the Software without restriction, including without limitation
014:         *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
015:         *  and/or sell copies of the Software, and to permit persons to whom the 
016:         *  Software is furnished to do so, subject to the following conditions:
017:         *
018:         *  The above copyright notice and this permission notice shall be included in 
019:         *  all copies or substantial portions of the Software. 
020:         *
021:         *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
022:         *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
023:         *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL 
024:         *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
025:         *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
026:         *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
027:         *  DEALINGS IN THE SOFTWARE.
028:         */
029:        package net.sourceforge.groboutils.mbtf.v1.ant;
030:
031:        import org.apache.tools.ant.Project;
032:        import org.apache.tools.ant.BuildException;
033:        import org.apache.tools.ant.taskdefs.Definer;
034:        import org.apache.tools.ant.taskdefs.Property;
035:        import org.apache.tools.ant.types.Reference;
036:
037:        import java.util.Vector;
038:        import java.util.Enumeration;
039:        import java.io.File;
040:
041:        import net.sourceforge.groboutils.mbtf.v1.IValidate;
042:        import net.sourceforge.groboutils.mbtf.v1.IAction;
043:        import net.sourceforge.groboutils.mbtf.v1.IErrors;
044:        import net.sourceforge.groboutils.mbtf.v1.ISystem;
045:
046:        import org.apache.log4j.Logger;
047:
048:        /**
049:         * A specific IValidate instance, which is Ant compatible, that instantiates
050:         * a set of Classes using the default constructor, and iterates through them
051:         * as though they each were IValidate instances.
052:         *
053:         * @author     Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
054:         * @version    $Date: 2003/02/10 22:52:25 $
055:         * @since      June 13, 2002
056:         */
057:        public class ValidateJavaType extends Definer implements  IValidate,
058:                IAction {
059:            private static final Logger LOG = Logger
060:                    .getLogger(ValidateJavaType.class);
061:
062:            // intended to be an imbedded task, but can be defined outside
063:            // the state iterator.
064:            public static final String DEFAULT_ANT_NAME = "mbtf.validatejava";
065:
066:            private Vector validators = new Vector();
067:            private Vector properties = new Vector();
068:
069:            public void execute() throws BuildException {
070:                if (project == null) {
071:                    throw new BuildException("ValidateJavaType project is null");
072:                }
073:
074:                // clean out the old classes, if any remain
075:                this .validators = new Vector();
076:                try {
077:                    super .execute();
078:                } catch (BuildException e) {
079:                    // allow for the name to be empty
080:                    setName("ignore");
081:                    super .execute();
082:                }
083:            }
084:
085:            protected void addDefinition(String name, Class c)
086:                    throws BuildException {
087:                LOG.debug("added " + c);
088:                addClass(c);
089:            }
090:
091:            public void addClass(Class c) throws BuildException {
092:                try {
093:                    Object o = c.newInstance();
094:                    this .validators.addElement(o);
095:                } catch (Exception e) {
096:                    throw new BuildException("Could not instantiate "
097:                            + c.getName(), e, location);
098:                }
099:            }
100:
101:            public void addParam(Property prop) {
102:                if (prop != null) {
103:                    this .properties.addElement(prop);
104:                }
105:            }
106:
107:            public void validate( ISystem system, IErrors errors )
108:    {
109:        LOG.debug(this +": Entering validate()");
110:        try
111:        {
112:            execute();
113:        }
114:        catch (BuildException e)
115:        {
116:            LOG.info("execute() caused exception", e);
117:            errors.addError("Failed to correctly process Ant structure.", e );
118:            LOG.debug(this +": Leaving validate() due to build exception");
119:            return;
120:        }
121:        
122:        Enumeration enum = this .validators.elements();
123:        int count = 0;
124:        while (enum.hasMoreElements())
125:        {
126:            Object o = enum.nextElement();
127:            if (o instanceof  IValidate)
128:            {
129:                ++count;
130:                setupObject( o );
131:                LOG.debug(this +": Start Validate "+o);
132:                ((IValidate)o).validate( system, errors );
133:                LOG.debug(this +": End Validate "+o);
134:            }
135:        }
136:        LOG.debug(this +": Leaving validate() ["+count+" validators]");
137:    }
138:
139:            public void performAction( ISystem system, IErrors errors )
140:    {
141:        LOG.debug( this +": Entering performAction()" );
142:        try
143:        {
144:            execute();
145:        }
146:        catch (BuildException e)
147:        {
148:            LOG.info("execute() caused exception", e);
149:            errors.addError("Failed to correctly process Ant structure.", e );
150:            LOG.debug(this +": Leaving performAction() due to build exception");
151:            return;
152:        }
153:        
154:        Enumeration enum = this .validators.elements();
155:        int count = 0;
156:        while (enum.hasMoreElements())
157:        {
158:            Object o = enum.nextElement();
159:            if (o instanceof  IAction)
160:            {
161:                ++count;
162:                setupObject( o );
163:                LOG.debug(this +": Start Perform action on "+o);
164:                ((IAction)o).performAction( system, errors );
165:                LOG.debug(this +": End perform action on "+o);
166:            }
167:        }
168:        LOG.debug(this +": Leaving performAction() ["+count+" actions]");
169:    }
170:
171:            protected void setupObject( Object o )
172:    {
173:        if (o != null && o instanceof IUsesProperties)
174:        {
175:            IUsesProperties iup = (IUsesProperties)o;
176:            iup.setProject( project );
177:            
178:            Enumeration enum = this.properties.elements();
179:            while (enum.hasMoreElements())
180:            {
181:                Property p = (Property)enum.nextElement();
182:                String name = p.getName();
183:                String value = p.getValue();
184:                File file = p.getFile();
185:                Reference refid = p.getRefid();
186:                String resource = p.getResource();
187:                String env = p.getEnvironment();
188:                
189:                if (value != null)
190:                {
191:                    iup.addProperty( name, value );
192:                }
193:                if (file != null)
194:                {
195:                    iup.addFile( name, file );
196:                }
197:                if (refid != null)
198:                {
199:                    LOG.debug("Adding reference '"+name+"' to '"+refid+"'");
200:                    iup.addReference( name, refid );
201:                }
202:                if (resource != null)
203:                {
204:                    iup.addResource( name, resource );
205:                }
206:                if (env != null)
207:                {
208:                    iup.addEnvironment(name, env );
209:                }
210:            }
211:        }
212:    }
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.