Diff.java 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. package com.up.smfmc;
  2. /**
  3. *
  4. * @author Ricky
  5. */
  6. public class Diff {
  7. public String file;
  8. public String line;
  9. public String content;
  10. public Method method;
  11. public static enum Method {
  12. after, before, replace, end;
  13. }
  14. public Diff(String file, String line, String content, Method method) {
  15. this.file = file.replace("./Sources", "$sourcedir").replace("./Themes/default", "$themedir").replace("./Themes/core", "$themedir");
  16. if (this.file.indexOf("./", 2) == -1 && this.file.contains("./")) this.file = this.file.replace("./", "$boarddir/");
  17. this.line = line;
  18. this.content = content;
  19. this.method = method;
  20. }
  21. @Override
  22. public String toString() {
  23. return " <file name=\"" + file + "\">\n" +
  24. " <operation>\n" +
  25. " <search position=\"" + method.name() + "\"" + (method == Method.end ? " />" : "><![CDATA[" + line + "]]></search>") + "\n" +
  26. " <add><![CDATA[" + content + "]]></add>\n" +
  27. " </operation>\n" +
  28. " </file>";
  29. }
  30. }