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 */
019package org.apache.wiki.diff;
020
021import java.io.IOException;
022import java.util.Properties;
023
024import org.apache.wiki.WikiContext;
025import org.apache.wiki.WikiEngine;
026import org.apache.wiki.WikiProvider;
027import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
028
029/**
030 *  Provides an SPI for creating a diff between two page versions.
031 */
032public interface DiffProvider extends WikiProvider
033{
034    /**
035     * The return string is to be XHTML compliant ready to display html.  No further
036     * processing of this text will be done by the wiki engine.
037     * 
038     * @return An XHTML diff.
039     * @param context The Wiki Context
040     * @param oldWikiText the old text
041     * @param newWikiText the new text
042     */
043    String makeDiffHtml(WikiContext context, String oldWikiText, String newWikiText);
044    
045    /**
046     *  If there is no diff provider set, this provider will work instead.
047     */
048    class NullDiffProvider implements DiffProvider
049    {
050        /**
051         *  {@inheritDoc}
052         */
053        public String makeDiffHtml(WikiContext ctx, String oldWikiText, String newWikiText)
054        {
055            return "You are using the NullDiffProvider, check your properties file.";
056        }
057
058        /**
059         *  {@inheritDoc}
060         */
061        public void initialize(WikiEngine engine, Properties properties) 
062            throws NoRequiredPropertyException, IOException
063        {
064        }
065
066        /**
067         *  {@inheritDoc}
068         */
069        public String getProviderInfo()
070        {
071            return "NullDiffProvider";
072        }
073    }
074    
075}