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 com.efsol.friki;

import java.io.File;
import java.util.Map;

import org.stringtree.factory.memory.MapStringRepository;
import org.stringtree.util.BooleanUtils;

public class Policy
	extends MapStringRepository
{
	private File tmpDir;
	private File baseDir;
	
	public Policy(Map map, File tmpDir, File baseDir)
	{
		super(map);
		this.tmpDir = tmpDir;
		this.baseDir = baseDir;
	}

	public Policy(File tmpDir, File baseDir)
	{
		this.tmpDir = tmpDir;
		this.baseDir = baseDir;
	}

	public Policy(File tmpDir)
	{
		this.tmpDir = tmpDir;
		this.baseDir = tmpDir;
	}
	
	public void setBaseDir(File baseDir)
	{
		this.baseDir = baseDir;
	}

	public boolean getBoolean(String name)
	{
		return BooleanUtils.booleanValue(getObject(name));
	}

	public File getFile(String name)
	{
		File ret = null;
		
		Object obj = getObject(name);
		if (obj != null)
		{
			if (obj instanceof File)
			{
				ret = (File)obj;
			}
			else if ("*TMP*".equals(obj))
			{
				ret = tmpDir;
			}
			else
			{
				ret = new File(baseDir, (String)obj);
			}
		}

		return ret; 
	}

	public void putAll(Map other)
	{
		map.putAll(other);
	}
}




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