Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Breadcrumb |
|
| 1.0833333333333333;1,083 |
1 | 0 | /** |
2 | * 2008, Digitalis Informatica. All rights reserved. Distribuicao e Gestao de Informatica, Lda. Estrada de Paco de Arcos | |
3 | * num.9 - Piso -1 2780-666 Paco de Arcos Telefone: (351) 21 4408990 Fax: (351) 21 4408999 http://www.digitalis.pt | |
4 | */ | |
5 | ||
6 | package pt.digitalis.dif.controller.objects; | |
7 | ||
8 | import java.util.Date; | |
9 | ||
10 | import pt.digitalis.dif.controller.interfaces.IDIFSession; | |
11 | import pt.digitalis.dif.utils.ObjectFormatter; | |
12 | ||
13 | /** | |
14 | * A single item in a navigation history, representing stage item | |
15 | * | |
16 | * @author Pedro Viegas <a href="mailto:pviegas@digitalis.pt">pviegas@digitalis.pt</a> | |
17 | * @created 2008/07/20 | |
18 | */ | |
19 | public class Breadcrumb { | |
20 | ||
21 | /** The session as it existed when the access took place */ | |
22 | private IDIFSession difSession; | |
23 | ||
24 | /** the list of parsed parameters of the current stage */ | |
25 | private String parameterPassed; | |
26 | ||
27 | /** The stage ID that was accessed */ | |
28 | private String stageID; | |
29 | ||
30 | /** The timestamp of the stage access */ | |
31 | private Date timestamp; | |
32 | ||
33 | /** | |
34 | * @param stageID | |
35 | */ | |
36 | 0 | public Breadcrumb(String stageID) |
37 | { | |
38 | 0 | this.stageID = stageID; |
39 | 0 | this.timestamp = new Date(); |
40 | 0 | } |
41 | ||
42 | /** | |
43 | * Inspector for the 'difSession' attribute. | |
44 | * | |
45 | * @return the difSession value | |
46 | */ | |
47 | public IDIFSession getDifSession() | |
48 | { | |
49 | 0 | return difSession; |
50 | } | |
51 | ||
52 | /** | |
53 | * Inspector for the 'parameterPassed' attribute. | |
54 | * | |
55 | * @return the parameterPassed value | |
56 | */ | |
57 | public String getParameterPassed() | |
58 | { | |
59 | 0 | return parameterPassed; |
60 | } | |
61 | ||
62 | /** | |
63 | * Inspector for the 'stageID' attribute. | |
64 | * | |
65 | * @return the stageID value | |
66 | */ | |
67 | public String getStageID() | |
68 | { | |
69 | 0 | return stageID; |
70 | } | |
71 | ||
72 | /** | |
73 | * Inspector for the 'timestamp' attribute. | |
74 | * | |
75 | * @return the timestamp value | |
76 | */ | |
77 | public Date getTimestamp() | |
78 | { | |
79 | 0 | return timestamp; |
80 | } | |
81 | ||
82 | /** | |
83 | * @return T if parameters are present | |
84 | */ | |
85 | public boolean hasParameters() | |
86 | { | |
87 | 0 | return (parameterPassed != null && !"".equals(parameterPassed)); |
88 | } | |
89 | ||
90 | /** | |
91 | * Inspector that validates if the present breadcrumb has a session snapshot | |
92 | * | |
93 | * @return T id session is saved | |
94 | */ | |
95 | public boolean hasSessionSnapshot() | |
96 | { | |
97 | 0 | return (difSession != null); |
98 | } | |
99 | ||
100 | /** | |
101 | * Modifier for the 'difSession' attribute. | |
102 | * | |
103 | * @param difSession | |
104 | * the new difSession value to set | |
105 | */ | |
106 | public void setDifSession(IDIFSession difSession) | |
107 | { | |
108 | 0 | this.difSession = difSession; |
109 | 0 | } |
110 | ||
111 | /** | |
112 | * Modifier for the 'parameterPassed' attribute. | |
113 | * | |
114 | * @param parameterPassed | |
115 | * the new parameterPassed value to set | |
116 | */ | |
117 | public void setParameterPassed(String parameterPassed) | |
118 | { | |
119 | 0 | this.parameterPassed = parameterPassed; |
120 | 0 | } |
121 | ||
122 | /** | |
123 | * Modifier for the 'stageID' attribute. | |
124 | * | |
125 | * @param stageID | |
126 | * the new stageID value to set | |
127 | */ | |
128 | public void setStageID(String stageID) | |
129 | { | |
130 | 0 | this.stageID = stageID; |
131 | 0 | } |
132 | ||
133 | /** | |
134 | * Modifier for the 'timestamp' attribute. | |
135 | * | |
136 | * @param timestamp | |
137 | * the new timestamp value to set | |
138 | */ | |
139 | public void setTimestamp(Date timestamp) | |
140 | { | |
141 | 0 | this.timestamp = timestamp; |
142 | 0 | } |
143 | ||
144 | /** | |
145 | * Returns the Request object in a human-readable form. | |
146 | * | |
147 | * @see java.lang.Object#toString() | |
148 | */ | |
149 | @Override | |
150 | public String toString() | |
151 | { | |
152 | 0 | ObjectFormatter formatter = new ObjectFormatter(); |
153 | 0 | formatter.addItem("StageID", stageID); |
154 | 0 | formatter.addItem("Parameters", parameterPassed); |
155 | 0 | formatter.addItem("Timestamp", timestamp); |
156 | 0 | formatter.addItem("Session", difSession); |
157 | ||
158 | 0 | return formatter.getFormatedObject(); |
159 | } | |
160 | } |