1. /*
  2. * Copyright 2003-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. package org.apache.tools.ant.taskdefs.optional.perforce;
  18. import org.apache.tools.ant.BuildException;
  19. import org.apache.tools.ant.Project;
  20. import org.apache.oro.text.perl.Perl5Util;
  21. import java.util.ArrayList;
  22. /**
  23. * FStatP4OutputHandler - spezialied Perforce output handler
  24. * able to sort files recognized as managed by Perforce and files not
  25. * managed by Perforce in the output
  26. *
  27. */
  28. class FStatP4OutputHandler extends P4HandlerAdapter {
  29. private P4Fstat parent;
  30. private ArrayList existing = new ArrayList();
  31. private ArrayList nonExisting = new ArrayList();
  32. private static Perl5Util util = new Perl5Util();
  33. public FStatP4OutputHandler(P4Fstat parent) {
  34. this.parent = parent;
  35. }
  36. public void process(String line) throws BuildException {
  37. if (util.match("/^... clientFile (.+)$/", line)) {
  38. String f = util.group(1);
  39. existing.add(f);
  40. } else if (util.match("/^(.+) - no such file/", line)) {
  41. String f = util.group(1);
  42. nonExisting.add(f);
  43. }
  44. parent.log(parent.util.substitute("s/^.*: //", line),
  45. Project.MSG_VERBOSE);
  46. }
  47. public ArrayList getExisting() {
  48. return existing;
  49. }
  50. public ArrayList getNonExisting() {
  51. return nonExisting;
  52. }
  53. }