01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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:
20: import org.apache.tools.ant.BuildException;
21: import org.apache.tools.ant.Project;
22: import org.apache.oro.text.perl.Perl5Util;
23:
24: import java.util.ArrayList;
25:
26: /**
27: * FStatP4OutputHandler - spezialied Perforce output handler
28: * able to sort files recognized as managed by Perforce and files not
29: * managed by Perforce in the output
30: *
31: */
32: class FStatP4OutputHandler extends P4HandlerAdapter {
33: private P4Fstat parent;
34: private ArrayList existing = new ArrayList();
35: private ArrayList nonExisting = new ArrayList();
36: private static Perl5Util util = new Perl5Util();
37:
38: public FStatP4OutputHandler(P4Fstat parent) {
39: this .parent = parent;
40: }
41:
42: public void process(String line) throws BuildException {
43: if (util.match("/^... clientFile (.+)$/", line)) {
44: String f = util.group(1);
45: existing.add(f);
46: } else if (util.match("/^(.+) - no such file/", line)) {
47: String f = util.group(1);
48: nonExisting.add(f);
49: }
50: parent.log(parent.util.substitute("s/^.*: //", line),
51: Project.MSG_VERBOSE);
52: }
53:
54: public ArrayList getExisting() {
55: return existing;
56: }
57:
58: public ArrayList getNonExisting() {
59: return nonExisting;
60: }
61: }
|