You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestOutputLocationManager.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /********************************************************************
  2. * Copyright (c) 2007 Contributors. All rights reserved.
  3. * This program and the accompanying materials are made available
  4. * under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution and is available at
  6. * http://eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: IBM Corporation - initial API and implementation
  9. * Helen Hawkins - initial version
  10. *******************************************************************/
  11. package org.aspectj.ajde.core;
  12. import java.io.File;
  13. import java.util.ArrayList;
  14. import java.util.List;
  15. /**
  16. * Test implementation of IOutputLocationManager. By default returns the
  17. * same location for both resources and classes, however, setter methods
  18. * enable the user to specify different location for these. Note that the
  19. * user is unable to specify different output location for different class
  20. * files.
  21. */
  22. public class TestOutputLocationManager implements IOutputLocationManager {
  23. private String testProjectOutputPath;
  24. private File classOutputLoc;
  25. private File resourceOutputLoc;
  26. private List allOutputLocations;
  27. public TestOutputLocationManager(String testProjectPath) {
  28. this.testProjectOutputPath = testProjectPath + File.separator + "bin";
  29. }
  30. public File getOutputLocationForClass(File compilationUnit) {
  31. initLocations();
  32. return classOutputLoc;
  33. }
  34. public File getOutputLocationForResource(File resource) {
  35. initLocations();
  36. return resourceOutputLoc;
  37. }
  38. // -------------- setter methods useful for testing -------------
  39. public void setOutputLocForClass(File f) {
  40. classOutputLoc = f;
  41. }
  42. public void setOutputLocForResource(File f) {
  43. resourceOutputLoc = f;
  44. }
  45. public List getAllOutputLocations() {
  46. if(allOutputLocations == null) {
  47. allOutputLocations = new ArrayList();
  48. initLocations();
  49. allOutputLocations.add(classOutputLoc);
  50. if (!classOutputLoc.equals(resourceOutputLoc)) {
  51. allOutputLocations.add(resourceOutputLoc);
  52. }
  53. }
  54. return allOutputLocations;
  55. }
  56. public File getDefaultOutputLocation() {
  57. initLocations();
  58. return classOutputLoc;
  59. }
  60. private void initLocations() {
  61. if (classOutputLoc == null) {
  62. classOutputLoc = new File(testProjectOutputPath);
  63. }
  64. if (resourceOutputLoc == null) {
  65. resourceOutputLoc = new File(testProjectOutputPath);
  66. }
  67. }
  68. }