praktikumHolonsAdapter.java 1.3 KB

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