devdaily home | apple | java | perl | unix | directory | blog

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

package wiki;

import org.stringtree.factory.AbstractStringFetcher;
import org.stringtree.factory.Container;
import org.stringtree.factory.Fetcher;
import org.stringtree.juicer.Initialisable;

import com.efsol.friki.NamePreserver;

public class LocalWikiLink 
	extends AbstractStringFetcher
	implements Initialisable
{
	private Container pages;

	public LocalWikiLink(Container pages)
	{
		this.pages = pages;
	}

	public LocalWikiLink()
	{
		this(null);
	}
	
	public Object getObject(String key)
	{
		String ret = "";

		if (pages.contains(key))
		{
			ret = "\nview{" + key + "," + NamePreserver.escape(key) + "}\n";
		}
		else
		{
			ret = "\nedit{" + key + "," + NamePreserver.escape(key) + "}\n";
		}
		return ret;
	}

	public void init(Fetcher context)
	{
		pages = (Container)context.getObject("wiki.pages");
	}
}




Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
 
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com