Source Code Cross Referenced for ObjectCreateRule.java in  » Library » Apache-commons-digester-1.8-src » org » apache » commons » digester » 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 » Library » Apache commons digester 1.8 src » org.apache.commons.digester 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* $Id: ObjectCreateRule.java 471661 2006-11-06 08:09:25Z skitching $
002:         *
003:         * Licensed to the Apache Software Foundation (ASF) under one or more
004:         * contributor license agreements.  See the NOTICE file distributed with
005:         * this work for additional information regarding copyright ownership.
006:         * The ASF licenses this file to You under the Apache License, Version 2.0
007:         * (the "License"); you may not use this file except in compliance with
008:         * the License.  You may obtain a copy of the License at
009:         * 
010:         *      http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         */
018:
019:        package org.apache.commons.digester;
020:
021:        import org.xml.sax.Attributes;
022:
023:        /**
024:         * Rule implementation that creates a new object and pushes it
025:         * onto the object stack.  When the element is complete, the
026:         * object will be popped
027:         */
028:
029:        public class ObjectCreateRule extends Rule {
030:
031:            // ----------------------------------------------------------- Constructors
032:
033:            /**
034:             * Construct an object create rule with the specified class name.
035:             *
036:             * @param digester The associated Digester
037:             * @param className Java class name of the object to be created
038:             *
039:             * @deprecated The digester instance is now set in the {@link Digester#addRule} method. 
040:             * Use {@link #ObjectCreateRule(String className)} instead.
041:             */
042:            public ObjectCreateRule(Digester digester, String className) {
043:
044:                this (className);
045:
046:            }
047:
048:            /**
049:             * Construct an object create rule with the specified class.
050:             *
051:             * @param digester The associated Digester
052:             * @param clazz Java class name of the object to be created
053:             *
054:             * @deprecated The digester instance is now set in the {@link Digester#addRule} method. 
055:             * Use {@link #ObjectCreateRule(Class clazz)} instead.
056:             */
057:            public ObjectCreateRule(Digester digester, Class clazz) {
058:
059:                this (clazz);
060:
061:            }
062:
063:            /**
064:             * Construct an object create rule with the specified class name and an
065:             * optional attribute name containing an override.
066:             *
067:             * @param digester The associated Digester
068:             * @param className Java class name of the object to be created
069:             * @param attributeName Attribute name which, if present, contains an
070:             *  override of the class name to create
071:             *
072:             * @deprecated The digester instance is now set in the {@link Digester#addRule} method. 
073:             * Use {@link #ObjectCreateRule(String className, String attributeName)} instead.
074:             */
075:            public ObjectCreateRule(Digester digester, String className,
076:                    String attributeName) {
077:
078:                this (className, attributeName);
079:
080:            }
081:
082:            /**
083:             * Construct an object create rule with the specified class and an
084:             * optional attribute name containing an override.
085:             *
086:             * @param digester The associated Digester
087:             * @param attributeName Attribute name which, if present, contains an
088:             * @param clazz Java class name of the object to be created
089:             *  override of the class name to create
090:             *
091:             * @deprecated The digester instance is now set in the {@link Digester#addRule} method. 
092:             * Use {@link #ObjectCreateRule(String attributeName, Class clazz)} instead.
093:             */
094:            public ObjectCreateRule(Digester digester, String attributeName,
095:                    Class clazz) {
096:
097:                this (attributeName, clazz);
098:
099:            }
100:
101:            /**
102:             * Construct an object create rule with the specified class name.
103:             *
104:             * @param className Java class name of the object to be created
105:             */
106:            public ObjectCreateRule(String className) {
107:
108:                this (className, (String) null);
109:
110:            }
111:
112:            /**
113:             * Construct an object create rule with the specified class.
114:             *
115:             * @param clazz Java class name of the object to be created
116:             */
117:            public ObjectCreateRule(Class clazz) {
118:
119:                this (clazz.getName(), (String) null);
120:
121:            }
122:
123:            /**
124:             * Construct an object create rule with the specified class name and an
125:             * optional attribute name containing an override.
126:             *
127:             * @param className Java class name of the object to be created
128:             * @param attributeName Attribute name which, if present, contains an
129:             *  override of the class name to create
130:             */
131:            public ObjectCreateRule(String className, String attributeName) {
132:
133:                this .className = className;
134:                this .attributeName = attributeName;
135:
136:            }
137:
138:            /**
139:             * Construct an object create rule with the specified class and an
140:             * optional attribute name containing an override.
141:             *
142:             * @param attributeName Attribute name which, if present, contains an
143:             * @param clazz Java class name of the object to be created
144:             *  override of the class name to create
145:             */
146:            public ObjectCreateRule(String attributeName, Class clazz) {
147:
148:                this (clazz.getName(), attributeName);
149:
150:            }
151:
152:            // ----------------------------------------------------- Instance Variables
153:
154:            /**
155:             * The attribute containing an override class name if it is present.
156:             */
157:            protected String attributeName = null;
158:
159:            /**
160:             * The Java class name of the object to be created.
161:             */
162:            protected String className = null;
163:
164:            // --------------------------------------------------------- Public Methods
165:
166:            /**
167:             * Process the beginning of this element.
168:             *
169:             * @param attributes The attribute list of this element
170:             */
171:            public void begin(Attributes attributes) throws Exception {
172:
173:                // Identify the name of the class to instantiate
174:                String realClassName = className;
175:                if (attributeName != null) {
176:                    String value = attributes.getValue(attributeName);
177:                    if (value != null) {
178:                        realClassName = value;
179:                    }
180:                }
181:                if (digester.log.isDebugEnabled()) {
182:                    digester.log.debug("[ObjectCreateRule]{" + digester.match
183:                            + "}New " + realClassName);
184:                }
185:
186:                // Instantiate the new object and push it on the context stack
187:                Class clazz = digester.getClassLoader()
188:                        .loadClass(realClassName);
189:                Object instance = clazz.newInstance();
190:                digester.push(instance);
191:
192:            }
193:
194:            /**
195:             * Process the end of this element.
196:             */
197:            public void end() throws Exception {
198:
199:                Object top = digester.pop();
200:                if (digester.log.isDebugEnabled()) {
201:                    digester.log.debug("[ObjectCreateRule]{" + digester.match
202:                            + "} Pop " + top.getClass().getName());
203:                }
204:
205:            }
206:
207:            /**
208:             * Render a printable version of this Rule.
209:             */
210:            public String toString() {
211:
212:                StringBuffer sb = new StringBuffer("ObjectCreateRule[");
213:                sb.append("className=");
214:                sb.append(className);
215:                sb.append(", attributeName=");
216:                sb.append(attributeName);
217:                sb.append("]");
218:                return (sb.toString());
219:
220:            }
221:
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.