Паттерн: Компоновщик (Composite)
Исходник: SitePage.java, язык: java [code #452, hits: 9375]
автор: this [добавлен: 08.07.2007]
  1. package composite;
  2.  
  3. import java.util.Collections;
  4. import java.util.Iterator;
  5. import java.util.List;
  6.  
  7. public class SitePage {
  8. protected String name;
  9. protected String descr;
  10. protected String keywords;
  11. protected List<SitePage> inners;
  12.  
  13. protected SitePage(String name, String descr, String keywords) {
  14. super();
  15. this.name = name;
  16. this.descr = descr;
  17. this.keywords = keywords;
  18. }
  19.  
  20. public String getDescr() {
  21. return descr;
  22. }
  23.  
  24. public String getKeywords() {
  25. return keywords;
  26. }
  27.  
  28. public String getName() {
  29. return name;
  30. }
  31.  
  32. public boolean Add(SitePage page) {
  33. return false;
  34. }
  35.  
  36. public boolean Remove(SitePage page) {
  37. return false;
  38. }
  39.  
  40. public Iterator<SitePage> GetInners() {
  41. return Collections.EMPTY_LIST.iterator();
  42. }
  43.  
  44. }
Сущность Component

Общий интерфейс страницы сайта.
Тестировалось на: java 1.5.0_04

+добавить реализацию