Source Code Cross Referenced for CollectionProperty.java in  » Testing » jakarta-jmeter » org » apache » jmeter » testelement » property » 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.testelement.property 
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.testelement.property;
020:
021:        import java.util.ArrayList;
022:        import java.util.Collection;
023:        import java.util.List;
024:
025:        import org.apache.jmeter.testelement.TestElement;
026:
027:        public class CollectionProperty extends MultiProperty {
028:
029:            private static final long serialVersionUID = 221L; // Remember to change this when the class changes ...
030:
031:            private Collection value;
032:
033:            transient private Collection savedValue;
034:
035:            public CollectionProperty(String name, Collection value) {
036:                super (name);
037:                this .value = normalizeList(value);
038:            }
039:
040:            public CollectionProperty() {
041:                super ();
042:                value = new ArrayList();
043:            }
044:
045:            public boolean equals(Object o) {
046:                if (o instanceof  CollectionProperty) {
047:                    if (value != null) {
048:                        return value.equals(((JMeterProperty) o)
049:                                .getObjectValue());
050:                    }
051:                }
052:                return false;
053:            }
054:
055:            public int hashCode() {
056:                return (value == null ? 0 : value.hashCode());
057:            }
058:
059:            public void remove(String prop) {
060:                PropertyIterator iter = iterator();
061:                while (iter.hasNext()) {
062:                    if (iter.next().getName().equals(prop)) {
063:                        iter.remove();
064:                    }
065:                }
066:            }
067:
068:            public void set(int index, String prop) {
069:                if (value instanceof  List) {
070:                    ((List) value).set(index, new StringProperty(prop, prop));
071:                }
072:            }
073:
074:            public void set(int index, JMeterProperty prop) {
075:                if (value instanceof  List) {
076:                    ((List) value).set(index, prop);
077:                }
078:            }
079:
080:            public JMeterProperty get(int row) {
081:                if (value instanceof  List) {
082:                    return (JMeterProperty) ((List) value).get(row);
083:                }
084:                return null;
085:            }
086:
087:            public void remove(int index) {
088:                if (value instanceof  List) {
089:                    ((List) value).remove(index);
090:                }
091:            }
092:
093:            public void setObjectValue(Object v) {
094:                if (v instanceof  Collection) {
095:                    setCollection((Collection) v);
096:                }
097:
098:            }
099:
100:            public PropertyIterator iterator() {
101:                return getIterator(value);
102:            }
103:
104:            /*
105:             * (non-Javadoc)
106:             * 
107:             * @see JMeterProperty#getStringValue()
108:             */
109:            public String getStringValue() {
110:                return value.toString();
111:            }
112:
113:            /*
114:             * (non-Javadoc)
115:             * 
116:             * @see JMeterProperty#getObjectValue()
117:             */
118:            public Object getObjectValue() {
119:                return value;
120:            }
121:
122:            public int size() {
123:                return value.size();
124:            }
125:
126:            /*
127:             * (non-Javadoc)
128:             * 
129:             * @see Object#clone()
130:             */
131:            public Object clone() {
132:                CollectionProperty prop = (CollectionProperty) super .clone();
133:                prop.value = cloneCollection();
134:                return prop;
135:            }
136:
137:            private Collection cloneCollection() {
138:                try {
139:                    Collection newCol = (Collection) value.getClass()
140:                            .newInstance();
141:                    PropertyIterator iter = iterator();
142:                    while (iter.hasNext()) {
143:                        newCol.add(iter.next().clone());
144:                    }
145:                    return newCol;
146:                } catch (Exception e) {
147:                    log.error("Couldn't clone collection", e);
148:                    return value;
149:                }
150:            }
151:
152:            public void setCollection(Collection coll) {
153:                value = normalizeList(coll);
154:            }
155:
156:            public void clear() {
157:                value.clear();
158:            }
159:
160:            /**
161:             * Easy way to add properties to the list.
162:             * 
163:             * @param prop
164:             */
165:            public void addProperty(JMeterProperty prop) {
166:                value.add(prop);
167:            }
168:
169:            public void addItem(Object item) {
170:                addProperty(convertObject(item));
171:            }
172:
173:            /**
174:             * Figures out what kind of properties this collection is holding and
175:             * returns the class type.
176:             * 
177:             * @see AbstractProperty#getPropertyType()
178:             */
179:            protected Class getPropertyType() {
180:                if (value.size() > 0) {
181:                    return value.iterator().next().getClass();
182:                }
183:                return NullProperty.class;
184:            }
185:
186:            /*
187:             * (non-Javadoc)
188:             * 
189:             * @see JMeterProperty#recoverRunningVersion(TestElement)
190:             */
191:            public void recoverRunningVersion(TestElement owner) {
192:                if (savedValue != null) {
193:                    value = savedValue;
194:                }
195:                recoverRunningVersionOfSubElements(owner);
196:            }
197:
198:            /*
199:             * (non-Javadoc)
200:             * 
201:             * @see JMeterProperty#setRunningVersion(boolean)
202:             */
203:            public void setRunningVersion(boolean running) {
204:                super.setRunningVersion(running);
205:                if (running) {
206:                    savedValue = value;
207:                } else {
208:                    savedValue = null;
209:                }
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.