Source Code Cross Referenced for TargetInput.java in  » Installer » AntInstaller » org » tp23 » antinstaller » input » 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 » Installer » AntInstaller » org.tp23.antinstaller.input 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright 2005 Paul Hinds
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.tp23.antinstaller.input;
017:
018:        import org.tp23.antinstaller.InstallerContext;
019:        import org.tp23.antinstaller.ValidationException;
020:
021:        /**
022:         *
023:         * <p>Input type to select targets to install </p>
024:         * If the osSpecific flag is set the OS of the current system will
025:         * be appended to the name of the target actually by ant run so that different
026:         * Targets can be run according to the target platform.
027:         * This feature goes against the principles of
028:         * building cross platform installers, but is provided so that common installer
029:         * tasks such as creating icons and shortcuts can be run on Windows for
030:         * all those useless users who can't run a command script ;)
031:         * <br>
032:         * Currently there are two modes strict and not strict (lax).</p>
033:         * <p>Strict target will return the target name plus the exact String in the
034:         * System Property "os.name" this means you will have to provide targets for
035:         * every possible OS version. See
036:         * <a href="http://lopica.sourceforge.net/os.html">this page</a> for a list of possible values
037:         * There are a great many but you may not want to consider some of the options.</p>
038:         * <p>Lax target will return one of the following strings only
039:         * <ul>
040:         * <li>"[target-name]-linux" - Linux </li>
041:         * <li>"[target-name]-mac" - Mac OS and Mac OS X</li>
042:         * <li>"[target-name]-sun" - SunOS and Solaris</li>
043:         * <li>"[target-name]-win" - Windows *</li>
044:         * <li>"[target-name]-other" - any thing else</li>
045:         * </ul></p> so you only have to create 5 ant targets to support all the cases.
046:         * <p>Copyright: Copyright (c) 2004</p>
047:         * <p>Company: tp23</p>
048:         * @author Paul Hinds
049:         * @version $Id: TargetInput.java,v 1.3 2006/12/07 02:42:22 teknopaul Exp $
050:         */
051:        public class TargetInput extends InputField implements  Target {
052:
053:            private String target;
054:            private String force;
055:            private String osSpecific;
056:            private String strict;
057:            //targets are ordered
058:            private int idx;
059:
060:            private static int globalIdx = 1;
061:
062:            public TargetInput() {
063:                idx = getGlobalIdx();
064:            }
065:
066:            public String getTarget() {
067:                if (isTrue(osSpecific)) {
068:                    return getOSSpecificTarget();
069:                } else {
070:                    return target;
071:                }
072:            }
073:
074:            /**
075:             * Used to fetch the target value that was set in the config file
076:             * @return
077:             */
078:            public String getTargetName() {
079:                return target;
080:            }
081:
082:            public void setTarget(String target) {
083:                this .target = target;
084:                setProperty(target);
085:            }
086:
087:            public String getForce() {
088:                return force;
089:            }
090:
091:            public void setForce(String force) {
092:                this .force = force;
093:            }
094:
095:            public String getStrict() {
096:                return strict;
097:            }
098:
099:            public void setStrict(String strict) {
100:                this .strict = strict;
101:            }
102:
103:            public String getOsSpecific() {
104:                return osSpecific;
105:            }
106:
107:            public void setOsSpecific(String osSpecific) {
108:                this .osSpecific = osSpecific;
109:            }
110:
111:            /**
112:             * Called to validate the user input
113:             */
114:            public boolean validate(InstallerContext cxt)
115:                    throws ValidationException {
116:                //setInputResult(target);
117:                return true;
118:            }
119:
120:            /**
121:             * Used by checkConfig to validate the configuration file.
122:             * Not used at runtime.
123:             * @return boolean
124:             */
125:            public boolean validateObject() {
126:                if (getDisplayText() == null) {
127:                    System.out.println("Target:displayText must be set");
128:                    return false;
129:                }
130:                if (getTarget() == null) {
131:                    System.out.println("Target:target must be set");
132:                    return false;
133:                }
134:                //		if(getTarget().equals("default")){
135:                //			System.out.println("Target:target can not be \"default\"");
136:                //			return false;
137:                //		}
138:                if (!InputField.optionalBoolean(getForce())) {
139:                    System.out
140:                            .println("Target:force must be true or false or null");
141:                    return false;
142:                }
143:                if (!InputField.optionalBoolean(getStrict())) {
144:                    System.out
145:                            .println("Target:strict must be true or false or null");
146:                    return false;
147:                }
148:                if (!InputField.optionalBoolean(getOsSpecific())) {
149:                    System.out
150:                            .println("Target:osSpecific must be true or false or null");
151:                    return false;
152:                }
153:                if (!InputField.requiredBoolean(getDefaultValue())) {
154:                    System.out
155:                            .println("Target:defaultValue must be true or false");
156:                    return false;
157:                }
158:                return true;
159:            }
160:
161:            public int getIdx() {
162:                return idx;
163:            }
164:
165:            public static int getGlobalIdx() {
166:                return globalIdx++;
167:            }
168:
169:            public String getOSSpecificTarget() {
170:                if (isTrue(strict)) {
171:                    return getStrictTarget();
172:                } else
173:                    return getLaxTarget();
174:            }
175:
176:            private String getStrictTarget() {
177:                return target + getOsSpecificSuffix();
178:            }
179:
180:            private String getLaxTarget() {
181:                return target + getLaxOsSpecificSuffix();
182:            }
183:
184:            /**
185:             * N.B.  should have added a "-" but to late to change now and not important
186:             * @return
187:             */
188:            public static String getOsSpecificSuffix() {
189:                return System.getProperty("os.name");
190:            }
191:
192:            public static String getLaxOsSpecificSuffix() {
193:                String osName = System.getProperty("os.name").toLowerCase();
194:                if (osName.indexOf("linux") != -1) {
195:                    return "-linux";
196:                }
197:                if (osName.indexOf("mac") != -1) {
198:                    return "-mac";
199:                }
200:                if (osName.indexOf("windows") != -1) {
201:                    return "-win";
202:                }
203:                if (osName.indexOf("solaris") != -1
204:                        || osName.indexOf("sunos") != -1) {
205:                    return "-sun";
206:                }
207:                return "-other";
208:
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.