001    /*
002     * Copyright 2006 Stephen McConnell.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *     http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package net.dpml.http;
017    
018    /**
019     * A ServletEntry maintains a mapping between a servlet name and a relative path.
020     * @author <a href="http://www.dpml.net">Digital Product Meta Library</a>
021     * @version 0.2.0
022     */
023    public class ServletEntry
024    {
025        private final String m_name;
026        private final String m_path;
027        
028       /**
029        * Creation of a new servlet name to path entry.
030        * @param name the servlet name
031        * @param path the context relative path
032        */
033        public ServletEntry( String name, String path )
034        {
035            m_name = name;
036            m_path = path;
037        }
038        
039       /**
040        * Return the servlet name.
041        * @return the servlet name
042        */
043        public String getName()
044        {
045            return m_name;
046        }
047        
048       /**
049        * Return the path.
050        * @return the servlet path
051        */
052        public String getPath()
053        {
054            return m_path;
055        }
056        
057       /**
058        * Test is this object is equal to the supplied object.
059        * @param other the object to evaluate this object against
060        * @return tryue if the objects are equal else false
061        */
062        public boolean equals( Object other )
063        {
064            if( null == other )
065            {
066                return false;
067            }
068            else if( other instanceof ServletEntry )
069            {
070                ServletEntry entry = (ServletEntry) other;
071                if( !m_name.equals( entry.m_name ) )
072                {
073                    return false;
074                }
075                else
076                {
077                    return m_path.equals( entry.m_path ); 
078                }
079            }
080            else
081            {
082                return false;
083            }
084        }
085        
086       /**
087        * Return the instance hashcode.
088        * @return the hash value
089        */
090        public int hashCode()
091        {
092            int hash = m_name.hashCode();
093            hash ^= m_path.hashCode();
094            return hash;
095        }
096    }