KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > controller > actionflow > config > PresentationNode


1 /*
2  * Copyright (c) 2002, Inversoft Corporation, All Rights Reserved
3  */

4 package com.inversoft.verge.mvc.controller.actionflow.config;
5
6
7 import javax.servlet.http.HttpServletRequest JavaDoc;
8
9
10 /**
11  * This class is the implementation of the Node
12  * interface for presentation Nodes. This stores the
13  * additional information relevant to presentation nodes
14  * such as file name, path, etc.
15  *
16  * @author Brian Pontarelli
17  * @since 2.0
18  * @version 2.0
19  */

20 public class PresentationNode extends BaseNode implements Node, RenderableNode {
21
22     private String JavaDoc path;
23     private String JavaDoc fileName;
24
25
26     /**
27      * Constructs a new <code>PresentationNode</code> with the standard Node
28      * information from the {@link BaseNode.BaseValues BaseNode.BaseValues}
29      * given. The PresentationNode uses the name of the Node as the full path
30      * to the presentation resource. This construtor breaks the name into the
31      * path and fileName in case these are needed.
32      *
33      * @param values The BaseValues that contains the values for this Node
34      * @param namespace The Namespace this Node belongs to
35      * @asserts If values is null or namespace is null
36      */

37     public PresentationNode(BaseNode.BaseValues values, Namespace namespace) {
38         super(values, namespace);
39
40         int index = values.name.lastIndexOf("/");
41         if (index != -1) {
42             this.path = values.name.substring(0, index + 1);
43             this.fileName = values.name.substring(index + 1);
44         } else {
45             this.path = "";
46             this.fileName = values.name;
47         }
48     }
49
50
51     /**
52      * Gets The path of the presentation file
53      *
54      * @return The path of the presentation file
55      */

56     public String JavaDoc getPath() {
57         return path;
58     }
59
60     /**
61      * Gets The file name of the presentation file
62      *
63      * @return The file name of the presentation file
64      */

65     public String JavaDoc getFileName() {
66         return fileName;
67     }
68
69     /**
70      * Returns the URL of this presentation node. This value can be used for
71      * forwards or redirects (with some work maybe).
72      *
73      * @see com.inversoft.verge.mvc.controller.Result#getURL()
74      */

75     public String JavaDoc getURL() {
76         return values.name;
77     }
78
79     /**
80      * Currently this type of node are always forwards, but this could change
81      *
82      * @see com.inversoft.verge.mvc.controller.Result#isForward()
83      */

84     public boolean isForward() {
85         return true;
86     }
87
88     /**
89      * Since the ActionFlow system currently only supports local URLs, this method
90      * returns null because local URLs can not have categories associated with
91      * them.
92      */

93     public String JavaDoc getCategory() {
94         return null;
95     }
96
97     /**
98      * Since the ActionFlow system currently only supports local URLs, this method
99      * returns the same value as a call to getURL.
100      */

101     public String JavaDoc getGeneratedURL(HttpServletRequest JavaDoc request) {
102         return getURL();
103     }
104 }
Popular Tags