PraktikumHolonsAdapter.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package tests;
  2. import java.util.ArrayList;
  3. import static java.lang.Math.*;
  4. import classes.Category;
  5. import classes.AbstractCpsObject;
  6. import classes.HolonElement;
  7. import classes.HolonObject;
  8. /**
  9. * This Class Generates Stuff for the Tests.
  10. *
  11. * @author Gruppe14
  12. */
  13. public class PraktikumHolonsAdapter {
  14. /**
  15. * Generate Sequence of Categories from A - ZZZ.
  16. * @param arr ArrayList of Categories
  17. */
  18. public void generateCategories(ArrayList<Category> arr) {
  19. for (int i = 1; i < 18279; i++) {
  20. arr.add(new Category(generate(i)));
  21. }
  22. }
  23. /**
  24. * Generate Sequence of Objects from A - ZZZ.
  25. * @param arr ArrayList of Categories
  26. */
  27. public void generateObjects(ArrayList<AbstractCpsObject> arr) {
  28. for (int i = 1; i < 18279; i++) {
  29. arr.add(new HolonObject(generate(i)));
  30. }
  31. }
  32. /**
  33. * Generate Sequence of Elements from A - ZZZ.
  34. * @param arr ArrayList of Categories
  35. */
  36. public void generateElements(ArrayList<HolonElement> arr) {
  37. for (int i = 1; i < 18279; i++) {
  38. arr.add(new HolonElement(generate(i), 1, 10));
  39. }
  40. }
  41. /**
  42. * Generate Alphabetical Sequences.
  43. * @param n Generator
  44. * @return A generated Alphabetical Sequence
  45. */
  46. public String generate(int n) {
  47. char[] buf = new char[(int) floor(log(25 * (n + 1)) / log(26))];
  48. for (int i = buf.length - 1; i >= 0; i--) {
  49. n--;
  50. buf[i] = (char) ('A' + n % 26);
  51. n /= 26;
  52. }
  53. return new String(buf);
  54. }
  55. }