Паттерн: Мост (Bridge)
Исходник: AddFileCommand.java, язык: java [code #448, hits: 8554]
автор: this [добавлен: 07.07.2007]
  1. package bridge;
  2.  
  3. import java.io.FileOutputStream;
  4. import java.io.IOException;
  5. import java.io.ObjectOutputStream;
  6. import java.util.Collections;
  7. import java.util.List;
  8.  
  9. public class AddFileCommand extends FileCommand {
  10.  
  11. public AddFileCommand(String filename) {
  12. super(filename);
  13. }
  14.  
  15. public boolean Exec() {
  16. super.Exec();
  17. try {
  18. oout.writeObject("");
  19. oout.close();
  20. } catch (IOException e) {
  21. this.errMess = e.getMessage();
  22. return false;
  23. }
  24. return true;
  25. }
  26.  
  27. public List GetGeneratedKeys() {
  28. return Collections.singletonList(file.getName());
  29. }
  30.  
  31. }
Сущность ConcreteImplementator

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

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