您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TestOutputLocationManager.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 (bug 148190)
  10. *******************************************************************/
  11. package org.aspectj.ajde.ui.utils;
  12. import java.io.File;
  13. import java.util.ArrayList;
  14. import java.util.List;
  15. import org.aspectj.ajde.core.IOutputLocationManager;
  16. /**
  17. * Test implementation of IOutputLocationManager. By default returns the
  18. * same location for both resources and classes, however, setter methods
  19. * enable the user to specify different location for these. Note that the
  20. * user is unable to specify different output location for different class
  21. * files.
  22. */
  23. public class TestOutputLocationManager implements IOutputLocationManager {
  24. private String testProjectOutputPath;
  25. private File classOutputLoc;
  26. private File resourceOutputLoc;
  27. private List allOutputLocations;
  28. public TestOutputLocationManager(String testProjectPath) {
  29. this.testProjectOutputPath = testProjectPath + File.separator + "bin";
  30. }
  31. public String getUniqueIdentifier() {
  32. return testProjectOutputPath;
  33. }
  34. public File getOutputLocationForClass(File compilationUnit) {
  35. initLocations();
  36. return classOutputLoc;
  37. }
  38. public File getOutputLocationForResource(File resource) {
  39. initLocations();
  40. return resourceOutputLoc;
  41. }
  42. // -------------- setter methods useful for testing -------------
  43. public void setOutputLocForClass(File f) {
  44. classOutputLoc = f;
  45. }
  46. public void setOutputLocForResource(File f) {
  47. resourceOutputLoc = f;
  48. }
  49. public List getAllOutputLocations() {
  50. if(allOutputLocations == null) {
  51. allOutputLocations = new ArrayList();
  52. initLocations();
  53. allOutputLocations.add(classOutputLoc);
  54. if (!classOutputLoc.equals(resourceOutputLoc)) {
  55. allOutputLocations.add(resourceOutputLoc);
  56. }
  57. }
  58. return allOutputLocations;
  59. }
  60. public File getDefaultOutputLocation() {
  61. return classOutputLoc;
  62. }
  63. private void initLocations() {
  64. if (classOutputLoc == null) {
  65. classOutputLoc = new File(testProjectOutputPath);
  66. }
  67. if (resourceOutputLoc == null) {
  68. resourceOutputLoc = new File(testProjectOutputPath);
  69. }
  70. }
  71. }