KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > perforce > FStatP4OutputHandler


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18 package org.apache.tools.ant.taskdefs.optional.perforce;
19 import org.apache.tools.ant.BuildException;
20 import org.apache.tools.ant.Project;
21 import org.apache.oro.text.perl.Perl5Util;
22
23 import java.util.ArrayList JavaDoc;
24
25 /**
26  * FStatP4OutputHandler - spezialied Perforce output handler
27  * able to sort files recognized as managed by Perforce and files not
28  * managed by Perforce in the output
29  *
30  */

31 class FStatP4OutputHandler extends P4HandlerAdapter {
32     private P4Fstat parent;
33     private ArrayList JavaDoc existing = new ArrayList JavaDoc();
34     private ArrayList JavaDoc nonExisting = new ArrayList JavaDoc();
35     private static Perl5Util util = new Perl5Util();
36
37     public FStatP4OutputHandler(P4Fstat parent) {
38         this.parent = parent;
39     }
40
41     public void process(String JavaDoc line) throws BuildException {
42         if (util.match("/^... clientFile (.+)$/", line)) {
43             String JavaDoc f = util.group(1);
44             existing.add(f);
45         } else if (util.match("/^(.+) - no such file/", line)) {
46             String JavaDoc f = util.group(1);
47             nonExisting.add(f);
48         }
49         parent.log(parent.util.substitute("s/^.*: //", line),
50                    Project.MSG_VERBOSE);
51     }
52
53     public ArrayList JavaDoc getExisting() {
54         return existing;
55     }
56
57     public ArrayList JavaDoc getNonExisting() {
58         return nonExisting;
59     }
60 }
61
Popular Tags