001    /*
002        Licensed to the Apache Software Foundation (ASF) under one
003        or more contributor license agreements.  See the NOTICE file
004        distributed with this work for additional information
005        regarding copyright ownership.  The ASF licenses this file
006        to you under the Apache License, Version 2.0 (the
007        "License"); you may not use this file except in compliance
008        with the License.  You may obtain a copy of the License at
009    
010           http://www.apache.org/licenses/LICENSE-2.0
011    
012        Unless required by applicable law or agreed to in writing,
013        software distributed under the License is distributed on an
014        "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015        KIND, either express or implied.  See the License for the
016        specific language governing permissions and limitations
017        under the License.  
018     */
019    
020    package org.apache.wiki.event;
021    
022    /**
023     *  WikiPageRenameEvent extends WikiPageEvent to indicate a change in
024     *  the name of a WikiPage.
025     *  <p>
026     *  This reuses {@link #getPageName()} to return the new name of the
027     *  page, with {@link #getOldPageName()} returning the old name.
028     *
029     * @see     org.apache.wiki.event.WikiPageEvent
030     * @since   2.5.108
031     */
032    public class WikiPageRenameEvent extends WikiPageEvent
033    {
034        private static final long serialVersionUID = 1L;
035    
036        /** Indicates a page rename event. This is based on events
037          * generated by {@link org.apache.wiki.content.PageRenamer}. */
038        public static final int PAGE_RENAMED         = 28;
039    
040        private String m_oldpagename  = null;
041    
042        // ............
043    
044    
045        /**
046         *  Constructs an instance of this event.
047         *
048         * @param src    the Object that is the source of the event.
049         * @param oldname   the old name of the WikiPage being acted upon.
050         * @param newname   the new name of the WikiPage being acted upon.
051         */
052        public WikiPageRenameEvent( Object src, String oldname, String newname )
053        {
054            super( src, PAGE_RENAMED, newname );
055            m_oldpagename = oldname;
056        }
057    
058    
059       /**
060         * Returns the old Wiki page name associated with this event.
061         * This may be null if unavailable.
062         *
063         * @return     the old Wiki page name associated with this WikiEvent, or null.
064         */
065        public String getOldPageName()
066        {
067            return m_oldpagename;
068        }
069    
070    
071       /**
072         * Returns the new Wiki page name associated with this event. This
073         * returns the same value as the superclass' {@link #getPageName()}.
074         * This may be null if unavailable.
075         *
076         * @return     the new Wiki page name associated with this WikiEvent, or null.
077         */
078        public String getNewPageName()
079        {
080            return super.getPageName();
081        }
082    
083    
084       /**
085         * Returns true if the int value is a WikiPageRenameEvent type.
086         */
087        public static boolean isValidType( int type )
088        {
089            return type == PAGE_RENAMED;
090        }
091    
092    
093        /**
094         * Returns a textual representation of the event type.
095         * @return a String representation of the type
096         */
097        public String eventName()
098        {
099            return "PAGE_RENAMED";
100        //  switch ( getType() )
101        //  {
102        //      case PAGE_RENAMED:         return "PAGE_RENAMED";
103        //      default:                   return super.eventName();
104        //  }
105        }
106    
107    
108       /** Returns a human-readable description of the event type.
109         * @return a String description of the type
110         */
111        public String getTypeDescription()
112        {
113            return "page renamed event";
114        //  switch ( getType() )
115        //  {
116        //      case PAGE_RENAMED:         return "page renamed event";
117        //      default:                   return super.getTypeDescription();
118        //  }
119        }
120    
121    } // end class org.apache.wiki.event.WikiPageRenameEvent