|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| EngineUtils.java | 100% | 100% | 100% | 100% |
|
||||||||||||||
| 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 class EngineUtils | |
| 26 | { | |
| 27 | ||
| 28 | /** | |
| 29 | * Invoked by {@link #getURL(String, String, int, String, boolean)} to see if an absolute URL is | |
| 30 | * needed (because a specific scheme, server or port was indicated that does not match the | |
| 31 | * incoming request). | |
| 32 | * | |
| 33 | * @param scheme | |
| 34 | * the desired URL scheme, or null | |
| 35 | * @param server | |
| 36 | * the desired URL server name, or null | |
| 37 | * @param port | |
| 38 | * the desired URL port, or 0 | |
| 39 | * @param request | |
| 40 | * the request to check against | |
| 41 | * @return true if absolute URL is needed, false otherwise | |
| 42 | */ | |
| 43 | 345 | public static boolean needAbsoluteURL(String scheme, String server, int port, WebRequest request) |
| 44 | { | |
| 45 | 345 | if (scheme != null && !scheme.equals(request.getScheme())) |
| 46 | 6 | return true; |
| 47 | ||
| 48 | 339 | if (server != null && !server.equals(request.getServerName())) |
| 49 | 3 | return true; |
| 50 | ||
| 51 | 336 | if (port != 0 && port != request.getServerPort()) |
| 52 | 3 | return true; |
| 53 | ||
| 54 | 333 | return false; |
| 55 | } | |
| 56 | ||
| 57 | } |
|
||||||||||