Source Code Cross Referenced for TestElementSaver.java in  » Testing » jakarta-jmeter » org » apache » jmeter » save » 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 » Testing » jakarta jmeter » org.apache.jmeter.save 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *   http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         * 
017:         */
018:
019:        package org.apache.jmeter.save;
020:
021:        import java.util.LinkedList;
022:        import java.util.NoSuchElementException;
023:
024:        import org.apache.avalon.framework.configuration.Configuration;
025:        import org.apache.avalon.framework.configuration.DefaultConfiguration;
026:        import org.apache.jmeter.testelement.TestElement;
027:        import org.apache.jmeter.testelement.TestElementTraverser;
028:        import org.apache.jmeter.testelement.property.CollectionProperty;
029:        import org.apache.jmeter.testelement.property.JMeterProperty;
030:        import org.apache.jmeter.testelement.property.MapProperty;
031:        import org.apache.jmeter.testelement.property.TestElementProperty;
032:
033:        /**
034:         * Helper class for OldSaveService
035:         */
036:        public class TestElementSaver implements  TestElementTraverser {
037:            private String name;
038:
039:            private LinkedList stack = new LinkedList();
040:
041:            private DefaultConfiguration rootConfig = null;
042:
043:            public TestElementSaver(String name) {
044:                this .name = name;
045:            }
046:
047:            public Configuration getConfiguration() {
048:                return rootConfig;
049:            }
050:
051:            /*
052:             * (non-Javadoc)
053:             * 
054:             * @see TestElementTraverser#startTestElement(TestElement)
055:             */
056:            public void startTestElement(TestElement el) {
057:                DefaultConfiguration config = new DefaultConfiguration(
058:                        "testelement", "testelement");
059:                config.setAttribute("class", el.getClass().getName());
060:                if (rootConfig == null) {
061:                    rootConfig = config;
062:                    if (name != null && name.length() > 0) {
063:                        rootConfig.setAttribute("name", name);
064:                    }
065:                } else {
066:                    setConfigName(config);
067:                }
068:                stack.add(config);
069:            }
070:
071:            public void setConfigName(DefaultConfiguration config) {
072:                if (!(stack.getLast() instanceof  Configuration)) {
073:                    Object key = stack.removeLast();
074:                    config.setAttribute("name", key.toString());
075:                }
076:            }
077:
078:            /*
079:             * (non-Javadoc)
080:             * 
081:             * @see TestElementTraverser#endTestElement(TestElement)
082:             */
083:            public void endTestElement(TestElement el) {
084:            }
085:
086:            /*
087:             * (non-Javadoc)
088:             * 
089:             * @see TestElementTraverser#simplePropertyValue(JMeterProperty)
090:             */
091:            public void simplePropertyValue(JMeterProperty value) {
092:                try {
093:                    Object parent = stack.getLast();
094:                    if (!(parent instanceof  Configuration)) {
095:                        DefaultConfiguration config = new DefaultConfiguration(
096:                                "property", "property");
097:                        config.setValue(value != null ? value.toString() : "");
098:                        config.setAttribute("name", parent.toString());
099:                        config.setAttribute(OldSaveService.XML_SPACE,
100:                                OldSaveService.PRESERVE);
101:                        stack.removeLast();
102:                        stack.add(config);
103:                    }
104:
105:                    if (parent instanceof  DefaultConfiguration
106:                            && value instanceof  Configuration) {
107:                        ((DefaultConfiguration) parent)
108:                                .addChild((Configuration) value);
109:                    } else if (parent instanceof  DefaultConfiguration
110:                            && !(value instanceof  Configuration)) {
111:                        DefaultConfiguration config = new DefaultConfiguration(
112:                                "string", "string");
113:                        config.setValue(value.toString());
114:                        config.setAttribute(OldSaveService.XML_SPACE,
115:                                OldSaveService.PRESERVE);
116:                        ((DefaultConfiguration) parent).addChild(config);
117:                    }
118:                } catch (NoSuchElementException e) {
119:                }
120:            }
121:
122:            /*
123:             * (non-Javadoc)
124:             * 
125:             * @see TestElementTraverser#startMap(MapProperty)
126:             */
127:            public void startMap(MapProperty map) {
128:                DefaultConfiguration config = new DefaultConfiguration("map",
129:                        "map");
130:                config.setAttribute("class", map.getObjectValue().getClass()
131:                        .getName());
132:                config.setAttribute("name", map.getName());
133:                config.setAttribute("propType", map.getClass().getName());
134:                stack.add(config);
135:            }
136:
137:            /*
138:             * It appears that this method is no longer used. jeremy_a@bigfoot.com 02
139:             * May 2003 public void endMap(MapProperty map) { finishConfig(); }
140:             */
141:
142:            /*
143:             * (non-Javadoc)
144:             * 
145:             * @see TestElementTraverser#startCollection(CollectionProperty)
146:             */
147:            public void startCollection(CollectionProperty col) {
148:                DefaultConfiguration config = new DefaultConfiguration(
149:                        "collection", "collection");
150:                config.setAttribute("class", col.getObjectValue().getClass()
151:                        .getName());
152:                config.setAttribute("name", col.getName());
153:                config.setAttribute("propType", col.getClass().getName());
154:                stack.add(config);
155:            }
156:
157:            /*
158:             * It appears that this method is no longer used. jeremy_a@bigfoot.com 02
159:             * May 2003 public void endCollection(CollectionProperty col) {
160:             * finishConfig(); }
161:             */
162:
163:            /*
164:             * (non-Javadoc)
165:             * 
166:             * @see TestElementTraverser#endProperty(JMeterProperty)
167:             */
168:            public void endProperty(JMeterProperty key) {
169:                finishConfig();
170:            }
171:
172:            private void finishConfig() {
173:                if (stack.size() > 1) {
174:                    Configuration config = (Configuration) stack.removeLast();
175:                    ((DefaultConfiguration) stack.getLast()).addChild(config);
176:                }
177:            }
178:
179:            /*
180:             * (non-Javadoc)
181:             * 
182:             * @see TestElementTraverser#startProperty(JMeterProperty)
183:             */
184:            public void startProperty(JMeterProperty key) {
185:                if (key instanceof  CollectionProperty) {
186:                    startCollection((CollectionProperty) key);
187:                } else if (key instanceof  MapProperty) {
188:                    startMap((MapProperty) key);
189:                } else if (key instanceof  TestElementProperty) {
190:                    stack.addLast(key.getName());
191:                } else {
192:                    DefaultConfiguration config = new DefaultConfiguration(
193:                            "property", "property");
194:                    config.setValue(key.getStringValue());
195:                    config.setAttribute("name", key.getName());
196:                    config.setAttribute("propType", key.getClass().getName());
197:                    config.setAttribute(OldSaveService.XML_SPACE,
198:                            OldSaveService.PRESERVE);
199:                    stack.addLast(config);
200:                }
201:
202:            }
203:
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.