praktikumHolonsAdapter.java 1.3 KB

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