Паттерн: Мост (Bridge)
Исходник: Command.java, язык: java [code #442, hits: 9285]
автор: this [добавлен: 07.07.2007]
  1. package bridge;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. public class Command {
  7. protected List<String> errors;
  8. protected CommandImpl impl;
  9.  
  10. public Command(CommandImpl impl) {
  11. super();
  12. this.impl = impl;
  13. this.errors = new ArrayList<String>();
  14. }
  15.  
  16. public boolean Execute() {
  17. boolean res = impl.Exec();
  18. if (impl.GetError() != null) {
  19. errors.add(impl.GetError());
  20. }
  21. return res;
  22. }
  23.  
  24. public String getErrors() {
  25. return errors.toString();
  26. }
  27. }
Сущность Abstraction

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

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