Source Code Cross Referenced for CvsVersion.java in  » Build » ANT » org » apache » tools » ant » taskdefs » cvslib » 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 » Build » ANT » org.apache.tools.ant.taskdefs.cvslib 
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:        package org.apache.tools.ant.taskdefs.cvslib;
019:
020:        import org.apache.tools.ant.taskdefs.AbstractCvsTask;
021:
022:        import java.io.ByteArrayOutputStream;
023:        import java.util.StringTokenizer;
024:
025:        /**
026:         * this task allows to find out the client and the server version of a
027:         * CVS installation
028:         *
029:         * example usage :
030:         * <cvsversion
031:         * cvsRoot=":pserver:anoncvs@cvs.apache.org:/home/cvspublic"
032:         * passfile="c:/programme/cygwin/home/antoine/.cvspass"
033:         * clientversionproperty="apacheclient"
034:         * serverversionproperty="apacheserver"   />
035:         *
036:         * the task can be used also in the API by calling its execute method,
037:         * then calling getServerVersion and/or getClientVersion
038:         *
039:         * @ant.task category="scm"
040:         * @since ant 1.6.1
041:         */
042:        public class CvsVersion extends AbstractCvsTask {
043:            static final long VERSION_1_11_2 = 11102;
044:            static final long MULTIPLY = 100;
045:            private String clientVersion;
046:            private String serverVersion;
047:            private String clientVersionProperty;
048:            private String serverVersionProperty;
049:
050:            /**
051:             * Get the CVS client version
052:             * @return CVS client version
053:             */
054:            public String getClientVersion() {
055:                return clientVersion;
056:            }
057:
058:            /**
059:             * Get the CVS server version
060:             * @return CVS server version
061:             */
062:            public String getServerVersion() {
063:                return serverVersion;
064:            }
065:
066:            /**
067:             * Set a property where to store the CVS client version
068:             * @param clientVersionProperty  property for CVS client version
069:             */
070:            public void setClientVersionProperty(String clientVersionProperty) {
071:                this .clientVersionProperty = clientVersionProperty;
072:            }
073:
074:            /**
075:             * Set a property where to store the CVS server version
076:             * @param serverVersionProperty  property for CVS server version
077:             */
078:            public void setServerVersionProperty(String serverVersionProperty) {
079:                this .serverVersionProperty = serverVersionProperty;
080:            }
081:
082:            /**
083:             * Find out if the server version supports log with S option
084:             * @return  boolean indicating if the server version supports log with S option
085:             */
086:            public boolean supportsCvsLogWithSOption() {
087:                if (serverVersion == null) {
088:                    return false;
089:                }
090:                StringTokenizer tokenizer = new StringTokenizer(serverVersion,
091:                        ".");
092:                long counter = MULTIPLY * MULTIPLY;
093:                long version = 0;
094:                while (tokenizer.hasMoreTokens()) {
095:                    String s = tokenizer.nextToken();
096:                    int i = 0;
097:                    for (i = 0; i < s.length(); i++) {
098:                        if (!Character.isDigit(s.charAt(i))) {
099:                            break;
100:                        }
101:                    }
102:                    String s2 = s.substring(0, i);
103:                    version = version + counter * Long.parseLong(s2);
104:                    if (counter == 1) {
105:                        break;
106:                    }
107:                    counter = counter / MULTIPLY;
108:                }
109:                return (version >= VERSION_1_11_2);
110:            }
111:
112:            /**
113:             * the execute method running CvsVersion
114:             */
115:            public void execute() {
116:                ByteArrayOutputStream bos = new ByteArrayOutputStream();
117:                this .setOutputStream(bos);
118:                ByteArrayOutputStream berr = new ByteArrayOutputStream();
119:                this .setErrorStream(berr);
120:                setCommand("version");
121:                super .execute();
122:                String output = bos.toString();
123:                StringTokenizer st = new StringTokenizer(output);
124:                boolean client = false;
125:                boolean server = false;
126:                boolean cvs = false;
127:                while (st.hasMoreTokens()) {
128:                    String currentToken = st.nextToken();
129:                    if (currentToken.equals("Client:")) {
130:                        client = true;
131:                    } else if (currentToken.equals("Server:")) {
132:                        server = true;
133:                    } else if (currentToken.equals("(CVS)")) {
134:                        cvs = true;
135:                    }
136:                    if (client && cvs) {
137:                        if (st.hasMoreTokens()) {
138:                            clientVersion = st.nextToken();
139:                        }
140:                        client = false;
141:                        cvs = false;
142:                    } else if (server && cvs) {
143:                        if (st.hasMoreTokens()) {
144:                            serverVersion = st.nextToken();
145:                        }
146:                        server = false;
147:                        cvs = false;
148:                    }
149:
150:                }
151:                if (clientVersionProperty != null) {
152:                    getProject().setNewProperty(clientVersionProperty,
153:                            clientVersion);
154:                }
155:                if (serverVersionProperty != null) {
156:                    getProject().setNewProperty(serverVersionProperty,
157:                            serverVersion);
158:                }
159:            }
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.