KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > web > config > NavigationResult


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the GNU Lesser General Public License as
5  * published by the Free Software Foundation; either version
6  * 2.1 of the License, or (at your option) any later version.
7  * You may obtain a copy of the License at
8  *
9  * http://www.gnu.org/licenses/lgpl.txt
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the
16  * License.
17  */

18 package org.alfresco.web.config;
19
20 /**
21  * Represents the result of a navigation config result.
22  *
23  * This object holds the string result which can either represent an outcome
24  * or a view id.
25  *
26  * @author gavinc
27  */

28 public class NavigationResult
29 {
30    private String JavaDoc result;
31    private boolean isOutcome = true;
32    
33    /**
34     * Default constructor
35     *
36     * @param viewId The to-view-id value
37     * @param outcome The to-outcome value
38     */

39    public NavigationResult(String JavaDoc viewId, String JavaDoc outcome)
40    {
41       if (viewId != null && outcome != null)
42       {
43          throw new IllegalStateException JavaDoc("You can not have both a to-view-id and to-outcome");
44       }
45       
46       if (outcome != null)
47       {
48          this.result = outcome;
49       }
50       else if (viewId != null)
51       {
52          this.result = viewId;
53          this.isOutcome = false;
54       }
55    }
56    
57    /**
58     * Returns the result
59     *
60     * @return The result
61     */

62    public String JavaDoc getResult()
63    {
64       return this.result;
65    }
66    
67    /**
68     * Determines whether the result is an outcome
69     *
70     * @return true if the result represents an outcome,
71     * false if it represents a view id
72     */

73    public boolean isOutcome()
74    {
75       return this.isOutcome;
76    }
77    
78    /**
79     * @see java.lang.Object#toString()
80     */

81    public String JavaDoc toString()
82    {
83       StringBuilder JavaDoc buffer = new StringBuilder JavaDoc(super.toString());
84       buffer.append(" (result=").append(this.result);
85       buffer.append(" isOutcome=").append(this.isOutcome).append(")");
86       return buffer.toString();
87    }
88 }
89
Popular Tags