01: package com.icesoft.faces.webapp.command;
02:
03: import com.icesoft.faces.util.DOMUtils;
04:
05: import java.io.IOException;
06: import java.io.Writer;
07: import java.net.URI;
08:
09: public class Redirect implements Command {
10: private URI uri;
11:
12: public Redirect(URI uri) {
13: this .uri = uri;
14: }
15:
16: public Redirect(String uri) {
17: this .uri = URI.create(uri);
18: }
19:
20: public Command coalesceWith(Command command) {
21: return command.coalesceWith(this );
22: }
23:
24: public Command coalesceWith(Macro macro) {
25: return this ;
26: }
27:
28: public Command coalesceWith(UpdateElements updateElements) {
29: return this ;
30: }
31:
32: public Command coalesceWith(Redirect redirect) {
33: return this ;
34: }
35:
36: public Command coalesceWith(SessionExpired sessionExpired) {
37: return sessionExpired;
38: }
39:
40: public Command coalesceWith(SetCookie setCookie) {
41: return new Macro(setCookie, this );
42: }
43:
44: public Command coalesceWith(Pong pong) {
45: return new Macro(pong, this );
46: }
47:
48: public Command coalesceWith(NOOP noop) {
49: return this ;
50: }
51:
52: public void serializeTo(Writer writer) throws IOException {
53: writer.write("<redirect url=\""
54: + DOMUtils.escapeAnsi(uri.toString()) + "\"/>");
55: }
56: }
|