Category.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package classes;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. /**
  5. * Class "Category" performs the functionality of listing elements into groups.
  6. * Each Category contains an ArrayList of CpsObjects, a name and a HashMap of
  7. * ObjIdx.
  8. *
  9. * @author Gruppe14
  10. *
  11. */
  12. public class Category {
  13. // objects: is a ArrayList of all Objects that belongs to the Category
  14. private ArrayList<AbstractCpsObject> objects;
  15. // name: is a String chosen by the User
  16. private String name;
  17. // ObjIdx: Index of each Category that corresponds to the order in the tree
  18. private HashMap<String, Integer> objIdx;
  19. /**
  20. * Category Constructor.
  21. *
  22. * @param name name of the Category
  23. */
  24. public Category(String name) {
  25. setObjects(new ArrayList<AbstractCpsObject>());
  26. setName(name);
  27. setObjIdx(new HashMap<String, Integer>());
  28. }
  29. /**
  30. * Getter for all CpsObjects.
  31. *
  32. * @return the objects
  33. */
  34. public ArrayList<AbstractCpsObject> getObjects() {
  35. return objects;
  36. }
  37. /**
  38. * Set a new ArrayList of CpsObjects.
  39. *
  40. * @param objects
  41. * the objects to set
  42. */
  43. public void setObjects(ArrayList<AbstractCpsObject> objects) {
  44. this.objects = objects;
  45. }
  46. /**
  47. * Getter the name of the Category.
  48. *
  49. * @return the name
  50. */
  51. public String getName() {
  52. return name;
  53. }
  54. /**
  55. * Set the name of the Category to a new one.
  56. *
  57. * @param name
  58. * the name to set
  59. */
  60. public void setName(String name) {
  61. this.name = name;
  62. }
  63. /**
  64. * Getter of the Objects in the Tree with their respective order.
  65. *
  66. * @return the objIdx
  67. */
  68. public HashMap<String, Integer> getObjIdx() {
  69. return objIdx;
  70. }
  71. /**
  72. * Set a new sequence of Objects in the tree.
  73. *
  74. * @param objIdx
  75. * the objIdx to set
  76. */
  77. public void setObjIdx(HashMap<String, Integer> objIdx) {
  78. this.objIdx = objIdx;
  79. }
  80. }