CSSSelector.java 988 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package de.tu_darmstadt.informatik.tk.scopviz.ui.css;
  2. import java.util.HashSet;
  3. import java.util.Iterator;
  4. class CSSSelector {
  5. //TODO comment
  6. String type;
  7. //TODO comment
  8. HashSet<String> classes;
  9. //TODO comment
  10. int value;
  11. //TODO comment
  12. CSSSelector(String type, HashSet<String> classes) {
  13. this.type = type;
  14. this.classes = classes;
  15. value = (type != null ? 1 : 0) + classes.size() << 1;
  16. }
  17. //TODO comment
  18. boolean ConditionsMetBy(CSSable suspect) {
  19. if (type != null && !type.equals(suspect.getType()))
  20. return false;
  21. Iterator<String> i = classes.iterator();
  22. while (i.hasNext()) {
  23. if (!suspect.getClasses().contains(i.next()))
  24. return false;
  25. }
  26. return true;
  27. }
  28. //TODO comment
  29. int getValue() {
  30. return value;
  31. }
  32. @Override
  33. public String toString() {
  34. String ret = "";
  35. for (String c : classes) {
  36. ret = ret.concat(".").concat(c);
  37. }
  38. if (type == null)
  39. return ret;
  40. return type.concat(ret);
  41. }
  42. }