/*
**	Class:			SystemProperties
**	Version:		1.0.0
**	Author:			Dario de Judicibus
**	E-mail:			dejudicibus@geocities.com
**	Created on:		June 10th, 1998
**	Changed on:		June 10th, 1998
**	Language:		Java (jdk 1.1)
**	-------------------------------------------------------------
**	(c) 1998 - All rights reserved
**	-------------------------------------------------------------
**	I make no representations or warranties about the suitability of
**	the software, either express or implied, including but not limited
**	to the implied warranties of merchantability, fitness for a
**	particular purpose, or non-infringement. I shall not be liable for
**	any damages suffered by licensee as a result of using, modifying or
**	distributing this software or its derivatives.
*/

/**
 *	@author Dario de Judicibus
 *	@version 1.0.0
 *	@see jdk 1.1
 *	Return the properties available from the machine where the
 *	class is running on. The following properties are supported:
 *		"file.separator" 		File separator (for example, "/")
 *		"java.class.path" 		Java classpath
 *		"java.class.version" 	Java class version number
 *		"java.home" 			Java installation directory
 *		"java.vendor" 			Java vendor-specific string
 *		"java.vendor.url" 		Java vendor URL
 *		"java.version" 			Java version number
 *		"line.separator" 		Line separator
 *		"os.arch" 				Operating system architecture
 *		"os.name" 				Operating system name
 *		"os.version" 			Operating system version
 *		"path.separator" 		Path separator (for example, ":")
 *		"user.dir" 				User's current working directory
 *		"user.home" 			User home directory
 *		"user.name" 			User account name
 */
public class SystemProperties
{
	private static final String[] cvPropertyNames =
	{
		"file.separator"
 	,	"java.class.path"
 	,	"java.class.version"
 	,	"java.home"
 	,	"java.vendor"
 	,	"java.vendor.url"
 	,	"java.version"
 	,	"line.separator"
 	,	"os.arch"
 	,	"os.name"
 	,	"os.version"
 	,	"path.separator"
 	,	"user.dir"
 	,	"user.home"
 	,	"user.name"
	} ;

    final static int cvNumProperties = cvPropertyNames.length ;

	public static String getValue( String propertyName )
	{
		String value = null ;

		if ( isSupported( propertyName ) )
		{
			try
			{
                value = System.getProperty( propertyName ) ;
            }
			catch ( SecurityException e )
			{
                value = "Security exception for property " + propertyName ;
            }
		}
		else
		{
			value = propertyName + " is not supported" ;
		}

		return value ;
	}

	public static boolean isSupported( String propertyName )
	{
		boolean supported = false ;

		for ( int i = 0 ; i < cvNumProperties && ! supported ; i++ )
		{
            if ( propertyName.equals( cvPropertyNames[i] ) )
			{
				supported = true ;
			}
		}

		return supported ;
	}
}