Source Code Cross Referenced for ArgumentBuilder.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » actions » iface » tools » support » 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 » Web Services » soapui 1.7.5 » com.eviware.soapui.impl.wsdl.actions.iface.tools.support 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  soapUI, copyright (C) 2004-2007 eviware.com 
003:         *
004:         *  soapUI is free software; you can redistribute it and/or modify it under the 
005:         *  terms of version 2.1 of the GNU Lesser General Public License as published by 
006:         *  the Free Software Foundation.
007:         *
008:         *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
009:         *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
010:         *  See the GNU Lesser General Public License for more details at gnu.org.
011:         */
012:
013:        package com.eviware.soapui.impl.wsdl.actions.iface.tools.support;
014:
015:        import java.io.File;
016:        import java.util.ArrayList;
017:        import java.util.List;
018:
019:        import com.eviware.soapui.support.UISupport;
020:        import com.eviware.soapui.support.types.StringToStringMap;
021:
022:        /**
023:         * Utility for build commandline arguments from dialog input
024:         * 
025:         * @author ole.matzura
026:         */
027:
028:        public class ArgumentBuilder {
029:            private final StringToStringMap values;
030:            private List<String> args = new ArrayList<String>();
031:            private boolean isUnix;
032:
033:            public ArgumentBuilder(StringToStringMap values) {
034:                this .values = values;
035:            }
036:
037:            public List<String> getArgs() {
038:                if (isUnix) {
039:                    // sh -c requires all args in one string.. 
040:                    StringBuffer buf = new StringBuffer();
041:                    for (int c = 2; c < args.size(); c++) {
042:                        if (c > 2)
043:                            buf.append(' ');
044:                        buf.append(escapeUnixArg(args.get(c)));
045:                    }
046:
047:                    ArrayList<String> result = new ArrayList<String>();
048:                    result.add(args.get(0));
049:                    result.add(args.get(1));
050:                    result.add(buf.toString());
051:
052:                    return result;
053:                } else {
054:                    return new ArrayList<String>(args);
055:                }
056:            }
057:
058:            private String escapeUnixArg(String str) {
059:                StringBuffer buf = new StringBuffer();
060:                int spaceIndex = str.indexOf(' ');
061:                if (spaceIndex >= 0) {
062:                    buf.append("\\'");
063:                }
064:
065:                for (int c = 0; c < str.length(); c++) {
066:                    char ch = str.charAt(c);
067:                    switch (ch) {
068:                    case '\'':
069:                        buf.append("\\'");
070:                        break;
071:                    case '\\':
072:                        buf.append("\\\\");
073:                        break;
074:                    default:
075:                        buf.append(ch);
076:                    }
077:                }
078:
079:                if (spaceIndex >= 0) {
080:                    buf.append("\\'");
081:                }
082:
083:                return buf.toString();
084:            }
085:
086:            public boolean addString(String name, String arg) {
087:                if (!values.containsKey(name))
088:                    return false;
089:
090:                String value = values.get(name).toString();
091:                if (value == null || value.length() == 0)
092:                    return false;
093:
094:                if (arg != null)
095:                    args.add(arg);
096:
097:                args.add(value);
098:
099:                return true;
100:            }
101:
102:            public ArgumentBuilder addArgs(String... args) {
103:                for (int c = 0; c < args.length; c++)
104:                    this .args.add(args[c]);
105:
106:                return this ;
107:            }
108:
109:            public boolean addBoolean(String name, String arg) {
110:                if (values.containsKey(name)
111:                        && Boolean.valueOf(values.get(name).toString())) {
112:                    args.add(arg);
113:                    return true;
114:                }
115:
116:                return false;
117:            }
118:
119:            public String toString() {
120:                StringBuffer buf = new StringBuffer();
121:                for (int c = 0; c < args.size(); c++) {
122:                    if (c > 0)
123:                        buf.append(' ');
124:
125:                    buf.append(args.get(c));
126:                }
127:
128:                return buf.toString();
129:            }
130:
131:            public ArgumentBuilder startScript(String script) {
132:                return startScript(script, ".bat", ".sh");
133:            }
134:
135:            public boolean addString(String name, String arg, String separator) {
136:                if (!values.containsKey(name))
137:                    return false;
138:
139:                String value = values.get(name).toString();
140:                if (value == null || value.length() == 0)
141:                    return false;
142:
143:                args.add(arg + separator + value);
144:
145:                return true;
146:            }
147:
148:            public boolean addBoolean(String name, String arg,
149:                    String trueValue, String falseValue) {
150:                if (!values.containsKey(name))
151:                    return false;
152:
153:                args.add(arg);
154:
155:                if (Boolean.valueOf(values.get(name).toString())) {
156:                    args.add(trueValue);
157:                    return true;
158:                } else {
159:                    args.add(falseValue);
160:                    return false;
161:                }
162:            }
163:
164:            public ArgumentBuilder startScript(String script,
165:                    String windowsExt, String unixExt) {
166:                if (UISupport.isWindows() && windowsExt != null) {
167:                    addArgs("cmd.exe", "/C", script + windowsExt);
168:                } else {
169:                    isUnix = true;
170:
171:                    if (!script.startsWith(".")
172:                            && !script.startsWith(File.separator))
173:                        script = "./" + script;
174:
175:                    addArgs("sh", "-c", script + unixExt);
176:                }
177:
178:                return this ;
179:            }
180:
181:            public String[] getStringArgs() {
182:                return args.toArray(new String[args.size()]);
183:            }
184:        }
w___w_w.__j___a_v___a___2s__.__co__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.