KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > faces > webapp > command > Redirect


1 package com.icesoft.faces.webapp.command;
2
3 import com.icesoft.faces.util.DOMUtils;
4
5 import java.io.IOException JavaDoc;
6 import java.io.Writer JavaDoc;
7 import java.net.URI JavaDoc;
8
9 public class Redirect implements Command {
10     private URI JavaDoc uri;
11
12     public Redirect(URI JavaDoc uri) {
13         this.uri = uri;
14     }
15
16     public Redirect(String JavaDoc 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 JavaDoc writer) throws IOException JavaDoc {
53         writer.write("<redirect url=\"" + DOMUtils.escapeAnsi(uri.toString() ) + "\"/>");
54     }
55 }
56
Popular Tags