001    // Copyright 2004, 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.tapestry.link;
016    
017    import org.apache.tapestry.engine.ILink;
018    
019    /**
020     * Used by {@link org.apache.tapestry.link.GenericLink} to represent an external, static URL.
021     * 
022     * @author Howard Lewis Ship
023     * @since 3.0
024     */
025    public class StaticLink implements ILink
026    {
027        private String _url;
028    
029        public StaticLink(String url)
030        {
031            _url = url;
032        }
033    
034        public String getURL()
035        {
036            return _url;
037        }
038    
039        public String getURL(String anchor, boolean includeParameters)
040        {
041            if (anchor == null)
042                return _url;
043    
044            return _url + "#" + anchor;
045        }
046    
047        public String getAbsoluteURL()
048        {
049            return _url;
050        }
051    
052        /**
053         * Ignores its parameter and return {@link #getURL(String, boolean)}.
054         */
055        public String getAbsoluteURL(String scheme, String server, int port, String anchor,
056                boolean includeParameters)
057        {
058            return getURL(anchor, false);
059        }
060    
061        /**
062         * Ignores its parameter and return {@link #getURL(String, boolean)}.
063         */
064        public String getURL(String scheme, String server, int port, String anchor,
065                boolean includeParameters)
066        {
067            return getURL(anchor, false);
068        }
069    
070        public String[] getParameterNames()
071        {
072            return null;
073        }
074    
075        public String[] getParameterValues(String name)
076        {
077            throw new IllegalArgumentException();
078        }
079    
080    }