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 org.apache.wiki.api.core.Context; 022import org.apache.wiki.api.core.Engine; 023import org.apache.wiki.api.exceptions.NoRequiredPropertyException; 024import org.apache.wiki.api.providers.WikiProvider; 025 026import java.io.IOException; 027import java.util.Properties; 028 029 030/** 031 * Provides an SPI for creating a diff between two page versions. 032 */ 033public interface DiffProvider extends WikiProvider { 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( Context 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 * {@inheritDoc} 051 */ 052 @Override 053 public String makeDiffHtml( final Context ctx, final String oldWikiText, final String newWikiText ) { 054 return "You are using the NullDiffProvider, check your properties file."; 055 } 056 057 /** 058 * {@inheritDoc} 059 */ 060 @Override 061 public void initialize( final Engine engine, final Properties properties ) throws NoRequiredPropertyException, IOException { 062 } 063 064 /** 065 * {@inheritDoc} 066 */ 067 @Override 068 public String getProviderInfo() 069 { 070 return "NullDiffProvider"; 071 } 072 } 073 074}