1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.trinidad.event;
20
21 import org.apache.myfaces.trinidad.context.Window;
22
23 /**
24 * WindowLifecycleEvent delivered when the current window is being unloaded
25 * in order to navigate to a new location
26 */
27 public final class WindowLifecycleNavigateEvent extends WindowLifecycleEvent
28 {
29 public WindowLifecycleNavigateEvent(Window source, String destination)
30 {
31 super(source, WindowLifecycleEvent.Cause.NAVIGATE);
32
33 if (destination == null)
34 throw new NullPointerException();
35
36 _destination = destination;
37 }
38
39 /**
40 * Returns the URL to which the page is navigating.
41 * <p>
42 * The destination is not guaranteed to be normalized; it may
43 * be absolute, page-relative, or server-relative. It is also
44 * not guaranteed to be correct, as a browser
45 * may be redirected to an alternate destination.
46 */
47 public String getDestination()
48 {
49 return _destination;
50 }
51
52 @Override
53 public int hashCode()
54 {
55 return super.hashCode() * 37 + _destination.hashCode();
56 }
57
58
59 @Override
60 public boolean equals(Object o)
61 {
62 if (this == o)
63 return true;
64 else if ((o != null) && (o instanceof WindowLifecycleNavigateEvent))
65 {
66 return subclassEquals((WindowLifecycleEvent)o) &&
67 _destination.equals(((WindowLifecycleNavigateEvent)o)._destination);
68 }
69 else
70 {
71 return false;
72 }
73 }
74
75 @Override
76 public String toString()
77 {
78 return super.toString() + ",destination=" + _destination;
79 }
80
81
82 private final String _destination;
83
84 private static final long serialVersionUID = 1L;
85 }