alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Friki example source code file (Policy.java)

This example Friki source code file (Policy.java) 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.

Java - Friki tags/keywords

file, file, io, mapstringrepository, mapstringrepository, object, object, policy, policy, string, tmp, util

The Friki Policy.java 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);
	}
}

Other Friki examples (source code examples)

Here is a short list of links related to this Friki Policy.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.