KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > pagestack > Page


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.pagestack;
14
15 import com.tonbeller.wcf.token.RequestToken;
16
17 /**
18  * @author av
19  */

20 public class Page {
21   String JavaDoc pageId;
22   String JavaDoc page;
23   String JavaDoc relUri;
24   String JavaDoc title;
25
26   RequestToken requestToken;
27   
28   public Page(String JavaDoc page, String JavaDoc title) {
29     this(page, page, page, title);
30   }
31
32   /**
33    * creates a Page instance that may be added to the PageStack.
34    *
35    * @param pageId identifies the page. If a page is added with a pageId that already exists in the
36    * stack, the existing page and all pages above will be popped.
37    *
38    * @param page the uri that will be rendered in href including the context name, e.g. /myapp/test.jsp
39    *
40    * @param relUri the uri relative to the context name, e.g. /test.jsp
41    *
42    * @param title the title to display
43    */

44   public Page(String JavaDoc pageId, String JavaDoc page, String JavaDoc relUri, String JavaDoc title) {
45     if (pageId == null)
46       pageId = page;
47     if (relUri == null)
48       relUri = page;
49
50     this.pageId = pageId;
51     this.page = page;
52     this.relUri = relUri;
53     this.title = title;
54   }
55
56   public String JavaDoc getTitle() {
57     return title;
58   }
59
60   public void setTitle(String JavaDoc title) {
61     this.title = title;
62   }
63
64   public String JavaDoc getPageHref() {
65     if (requestToken == null)
66       return page;
67     return requestToken.appendHttpParameter(page);
68   }
69   
70   public String JavaDoc getPage() {
71     return page;
72   }
73
74   public void setPage(String JavaDoc page) {
75     this.page = page;
76   }
77
78   public int hashCode() {
79     return pageId.hashCode();
80   }
81
82   public boolean equals(Object JavaDoc o) {
83     if (!(o instanceof Page))
84       return false;
85     Page p = (Page) o;
86     return pageId.equals(p.pageId);
87   }
88
89   void setRequestToken(RequestToken requestToken) {
90     this.requestToken = requestToken;
91   }
92
93   public String JavaDoc getRelUri() {
94     return relUri;
95   }
96
97   public void setRelUri(String JavaDoc relUri) {
98     this.relUri = relUri;
99   }
100
101 }
102
Popular Tags