Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EngineUtils |
|
| 5.5;5.5 |
1 | // Copyright 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.tapestry.engine; | |
16 | ||
17 | import org.apache.tapestry.web.WebRequest; | |
18 | ||
19 | /** | |
20 | * Utilities needed by engine services and etc. | |
21 | * | |
22 | * @author Howard M. Lewis Ship | |
23 | * @since 4.0 | |
24 | */ | |
25 | public final class EngineUtils | |
26 | { | |
27 | ||
28 | /* defeat instantiation */ | |
29 | 0 | private EngineUtils() { } |
30 | ||
31 | /** | |
32 | * Invoked by to see if an absolute URL is needed (because a specific scheme, server or port | |
33 | * was indicated that does not match the incoming request). | |
34 | * | |
35 | * @param scheme | |
36 | * the desired URL scheme, or null | |
37 | * @param server | |
38 | * the desired URL server name, or null | |
39 | * @param port | |
40 | * the desired URL port, or 0 | |
41 | * @param request | |
42 | * the request to check against | |
43 | * @return true if absolute URL is needed, false otherwise | |
44 | */ | |
45 | public static boolean needAbsoluteURL(String scheme, String server, int port, WebRequest request) | |
46 | { | |
47 | 0 | if (scheme != null && !scheme.equals(request.getScheme())) return true; |
48 | ||
49 | 0 | if (server != null && !server.equals(request.getServerName())) |
50 | 0 | return true; |
51 | ||
52 | 0 | if (port != 0 && port != request.getServerPort()) return true; |
53 | ||
54 | 0 | return false; |
55 | } | |
56 | ||
57 | } |