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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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.Collections;
  15. import java.util.List;
  16. import java.util.Map;
  17. /**
  18. * Test implementation of IOutputLocationManager. By default returns the same location for both resources and classes, however,
  19. * setter methods enable the user to specify different location for these. Note that the user is unable to specify different output
  20. * location for different class files.
  21. */
  22. public class TestOutputLocationManager implements IOutputLocationManager {
  23. private String testProjectOutputPath;
  24. private File classOutputLoc;
  25. private File resourceOutputLoc;
  26. private List<File> allOutputLocations;
  27. private Map inpathMap = Collections.EMPTY_MAP;
  28. public TestOutputLocationManager(String testProjectPath) {
  29. this.testProjectOutputPath = testProjectPath + File.separator + "bin";
  30. }
  31. public TestOutputLocationManager(String string, Map inpathMap) {
  32. this(string);
  33. this.inpathMap = inpathMap;
  34. }
  35. public File getOutputLocationForClass(File compilationUnit) {
  36. initLocations();
  37. return classOutputLoc;
  38. }
  39. public File getOutputLocationForResource(File resource) {
  40. initLocations();
  41. return resourceOutputLoc;
  42. }
  43. public Map getInpathMap() {
  44. return inpathMap;
  45. }
  46. // -------------- setter methods useful for testing -------------
  47. public void setOutputLocForClass(File f) {
  48. classOutputLoc = f;
  49. }
  50. public void setOutputLocForResource(File f) {
  51. resourceOutputLoc = f;
  52. }
  53. public List<File> getAllOutputLocations() {
  54. if (allOutputLocations == null) {
  55. allOutputLocations = new ArrayList<File>();
  56. initLocations();
  57. allOutputLocations.add(classOutputLoc);
  58. if (!classOutputLoc.equals(resourceOutputLoc)) {
  59. allOutputLocations.add(resourceOutputLoc);
  60. }
  61. }
  62. return allOutputLocations;
  63. }
  64. public File getDefaultOutputLocation() {
  65. initLocations();
  66. return classOutputLoc;
  67. }
  68. private void initLocations() {
  69. if (classOutputLoc == null) {
  70. classOutputLoc = new File(testProjectOutputPath);
  71. }
  72. if (resourceOutputLoc == null) {
  73. resourceOutputLoc = new File(testProjectOutputPath);
  74. }
  75. }
  76. public String getSourceFolderForFile(File sourceFile) {
  77. return null;
  78. }
  79. public void reportFileWrite(String outputfile, int filetype) {
  80. }
  81. public void reportFileRemove(String outputfile, int filetype) {
  82. }
  83. public int discoverChangesSince(File dir, long buildtime) {
  84. // TODO Auto-generated method stub
  85. return 0;
  86. }
  87. }