Source Code Cross Referenced for P4Fstat.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » perforce » 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.optional.perforce 
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:         * Portions of this software are based upon public domain software
020:         * originally written at the National Center for Supercomputing Applications,
021:         * University of Illinois, Urbana-Champaign.
022:         */
023:
024:        package org.apache.tools.ant.taskdefs.optional.perforce;
025:
026:        import java.io.File;
027:        import java.util.Vector;
028:        import java.util.ArrayList;
029:
030:        import org.apache.tools.ant.Project;
031:        import org.apache.tools.ant.BuildException;
032:        import org.apache.tools.ant.DirectoryScanner;
033:        import org.apache.tools.ant.types.FileSet;
034:
035:        /**
036:         * P4Fstat--find out which files are under Perforce control and which are not.
037:         *
038:         * <br><b>Example Usage:</b><br>
039:         * <pre>
040:         * &lt;project name=&quot;p4fstat&quot; default=&quot;p4fstat&quot;
041:         * basedir=&quot;C:\dev\gnu&quot;&gt;
042:         *     &lt;target name=&quot;p4fstat&quot; &gt;
043:         *         &lt;p4fstat showfilter=&quot;all&quot;&gt;
044:         *             &lt;fileset dir=&quot;depot&quot; includes=&quot;**\/*&quot;/&gt;
045:         *         &lt;/p4fstat&gt;
046:         *     &lt;/target&gt;
047:         * &lt;/project&gt;
048:         * </pre>
049:         *
050:         * @ant.task category="scm"
051:         */
052:        public class P4Fstat extends P4Base {
053:
054:            private int changelist;
055:            private String addCmd = "";
056:            private Vector filesets = new Vector();
057:            private static final int DEFAULT_CMD_LENGTH = 300;
058:            private int cmdLength = DEFAULT_CMD_LENGTH;
059:            private static final int SHOW_ALL = 0;
060:            private static final int SHOW_EXISTING = 1;
061:            private static final int SHOW_NON_EXISTING = 2;
062:            private int show = SHOW_NON_EXISTING;
063:            private FStatP4OutputHandler handler;
064:            private StringBuffer filelist;
065:            private int fileNum = 0;
066:            private int doneFileNum = 0;
067:            private boolean debug = false;
068:
069:            private static final String EXISTING_HEADER = "Following files exist in perforce";
070:            private static final String NONEXISTING_HEADER = "Following files do not exist in perforce";
071:
072:            /**
073:             * Sets the filter that one wants applied.
074:             * <table>
075:             * <tr><th>Option</th><th>Meaning</th></tr>
076:             * <tr><td>all</td><td>all files under Perforce control or not</td></tr>
077:             * <tr><td>existing</td><td>only files under Perforce control</td></tr>
078:             * <tr><td>non-existing</td><td>only files not under Perforce control or not</td></tr>
079:             * </table>
080:             * @param filter should be one of all|existing|non-existing.
081:             */
082:            public void setShowFilter(String filter) {
083:                if (filter.equalsIgnoreCase("all")) {
084:                    show = SHOW_ALL;
085:                } else if (filter.equalsIgnoreCase("existing")) {
086:                    show = SHOW_EXISTING;
087:                } else if (filter.equalsIgnoreCase("non-existing")) {
088:                    show = SHOW_NON_EXISTING;
089:                } else {
090:                    throw new BuildException(
091:                            "P4Fstat: ShowFilter should be one of: "
092:                                    + "all, existing, non-existing");
093:                }
094:            }
095:
096:            /**
097:             * Sets optionally a change list number.
098:             * @param changelist change list that one wants information about.
099:             * @throws BuildException if the change list number is negative.
100:             */
101:            public void setChangelist(int changelist) throws BuildException {
102:                if (changelist <= 0) {
103:                    throw new BuildException(
104:                            "P4FStat: Changelist# should be a "
105:                                    + "positive number");
106:                }
107:                this .changelist = changelist;
108:            }
109:
110:            /**
111:             * Adds a fileset to be examined by p4fstat.
112:             * @param set the fileset to add.
113:             */
114:            public void addFileset(FileSet set) {
115:                filesets.addElement(set);
116:            }
117:
118:            /**
119:             * Executes the p4fstat task.
120:             * @throws BuildException if no files are specified.
121:             */
122:            public void execute() throws BuildException {
123:                handler = new FStatP4OutputHandler(this );
124:                if (P4View != null) {
125:                    addCmd = P4View;
126:                }
127:                P4CmdOpts = (changelist > 0) ? ("-c " + changelist) : "";
128:
129:                filelist = new StringBuffer();
130:
131:                for (int i = 0; i < filesets.size(); i++) {
132:                    FileSet fs = (FileSet) filesets.elementAt(i);
133:                    DirectoryScanner ds = fs.getDirectoryScanner(getProject());
134:
135:                    String[] srcFiles = ds.getIncludedFiles();
136:                    fileNum = srcFiles.length;
137:
138:                    if (srcFiles != null) {
139:                        for (int j = 0; j < srcFiles.length; j++) {
140:                            File f = new File(ds.getBasedir(), srcFiles[j]);
141:                            filelist.append(" ").append('"').append(
142:                                    f.getAbsolutePath()).append('"');
143:                            doneFileNum++;
144:                            if (filelist.length() > cmdLength) {
145:
146:                                execP4Fstat(filelist);
147:                                filelist = new StringBuffer();
148:                            }
149:                        }
150:                        if (filelist.length() > 0) {
151:                            execP4Fstat(filelist);
152:                        }
153:                    } else {
154:                        log("No files specified to query status on!",
155:                                Project.MSG_WARN);
156:                    }
157:                }
158:                if (show == SHOW_ALL || show == SHOW_EXISTING) {
159:                    printRes(handler.getExisting(), EXISTING_HEADER);
160:                }
161:                if (show == SHOW_ALL || show == SHOW_NON_EXISTING) {
162:                    printRes(handler.getNonExisting(), NONEXISTING_HEADER);
163:                }
164:            }
165:
166:            /**
167:             * Return the number of files seen.
168:             * @return the number of files seen.
169:             */
170:            public int getLengthOfTask() {
171:                return fileNum;
172:            }
173:
174:            /**
175:             * Return the number of passes to make.
176:             * IS THIS BEING USED?
177:             * @return number of passes (how many filesets).
178:             */
179:            int getPasses() {
180:                return filesets.size();
181:            }
182:
183:            private void printRes(ArrayList ar, String header) {
184:                log(header, Project.MSG_INFO);
185:                for (int i = 0; i < ar.size(); i++) {
186:                    log((String) ar.get(i), Project.MSG_INFO);
187:                }
188:            }
189:
190:            private void execP4Fstat(StringBuffer list) {
191:                String l = list.substring(0);
192:                if (debug) {
193:                    log("Executing fstat " + P4CmdOpts + " " + addCmd + l
194:                            + "\n", Project.MSG_INFO);
195:                }
196:                execP4Command("fstat " + P4CmdOpts + " " + addCmd + l, handler);
197:            }
198:
199:        }
w__ww__.___j__a__v___a___2___s.__c__o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.