Category.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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<CpsObject> 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. public Category(String name) {
  20. setObjects(new ArrayList<CpsObject>());
  21. setName(name);
  22. setObjIdx(new HashMap<String, Integer>());
  23. }
  24. /**
  25. * Getter for all CpsObjects
  26. *
  27. * @return the objects
  28. */
  29. public ArrayList<CpsObject> getObjects() {
  30. return objects;
  31. }
  32. /**
  33. * Set a new ArrayList of CpsObjects
  34. *
  35. * @param objects
  36. * the objects to set
  37. */
  38. public void setObjects(ArrayList<CpsObject> objects) {
  39. this.objects = objects;
  40. }
  41. /**
  42. * Getter the name of the Category
  43. *
  44. * @return the name
  45. */
  46. public String getName() {
  47. return name;
  48. }
  49. /**
  50. * Set the name of the Category to a new one
  51. *
  52. * @param name
  53. * the name to set
  54. */
  55. public void setName(String name) {
  56. this.name = name;
  57. }
  58. /**
  59. * Getter of the Objects in the Tree with their respective order
  60. *
  61. * @return the objIdx
  62. */
  63. public HashMap<String, Integer> getObjIdx() {
  64. return objIdx;
  65. }
  66. /**
  67. * Set a new sequence of Objects in the tree
  68. *
  69. * @param objIdx
  70. * the objIdx to set
  71. */
  72. public void setObjIdx(HashMap<String, Integer> objIdx) {
  73. this.objIdx = objIdx;
  74. }
  75. }