com.sun.jini.tool.envcheck
Class Util

java.lang.Object
  extended by com.sun.jini.tool.envcheck.Util

public class Util
extends Object

Miscellaneous utility methods for use by the checking framework and plugins.


Field Summary
private static ResourceBundle bundle
          the resource bundle for this class
private static Properties nonStandardProperties
          the properties which were provided to the local VM
private static HashMap resourceMap
          table of localization resources
 
Constructor Summary
Util()
           
 
Method Summary
static String checkFileName(String name, String desc)
          Validate the accessibility of the non-directory file identified by name.
static String checkSystemPropertyFile(String prop, String desc)
          Validate the accessibility of the non-directory file identified by the system property prop.
static String checkURL(URL url, String desc)
          Check the accessibility of the given URL.
private static String getFormat(String key, ResourceBundle bundle)
          Get the format string associated with key in the given resource bundle.
static ResourceBundle getResourceBundle(Class clazz)
          Get the resource bundle associated with class clazz.
static String getString(String key, ResourceBundle bundle)
          Print out string according to resourceBundle format.
static String getString(String key, ResourceBundle bundle, Object val)
          Print out string according to resourceBundle format.
static String getString(String key, ResourceBundle bundle, Object val1, Object val2)
          Print out string according to resourceBundle format.
static String getString(String key, ResourceBundle bundle, Object val1, Object val2, Object val3)
          Print out string according to resourceBundle format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resourceMap

private static final HashMap resourceMap
table of localization resources


bundle

private static ResourceBundle bundle
the resource bundle for this class


nonStandardProperties

private static Properties nonStandardProperties
the properties which were provided to the local VM

Constructor Detail

Util

public Util()
Method Detail

checkFileName

public static String checkFileName(String name,
                                   String desc)
Validate the accessibility of the non-directory file identified by name. The file must exist, must not be a directory, and must be readable. If any check fails, an error message is returned. If all checks are successful, null is returned.

Parameters:
name - the file name
desc - a short descriptive string which describes the file, suitable for inclusion in the error message
Returns:
and error message, or null if all checks pass

checkURL

public static String checkURL(URL url,
                              String desc)
Check the accessibility of the given URL. If the url is a file: url, the usual file access checks are performed. For any other url a stream is opened, and a non-exceptional return is considered a success.

Parameters:
url - the URL to check
desc - a description of the source of the url
Returns:
an error message, or null if the access check passes

checkSystemPropertyFile

public static String checkSystemPropertyFile(String prop,
                                             String desc)
Validate the accessibility of the non-directory file identified by the system property prop. The system property must have a non-null value. The file identified by the value must exist, must not be a directory, and must be readable. If any check fails, an error message is returned. If all checks are successful, null is returned.

Parameters:
prop - name of a system property whose value must be a file name
desc - a short descriptive string which describes the file, suitable for inclusion in the error message
Returns:
an error message, or null if all checks pass

getResourceBundle

public static ResourceBundle getResourceBundle(Class clazz)
Get the resource bundle associated with class clazz. The resource bundle name is constructed by the class name to lower case and inserting .resources in front of the name. Thus, if clazz.getName() returned a.b.Foo then the associated resource bundle name would be a.b.resources.foo. If no resource bundle having the associated name is found, a stack trace is printed and null is returned. The resource bundle is loaded using the class loader for the given class, and is cached so that the search is performed only once.

Parameters:
clazz - the class for which to obtain a resource bundle
Returns:
the resource bundle

getFormat

private static String getFormat(String key,
                                ResourceBundle bundle)
Get the format string associated with key in the given resource bundle. If key is not present in the bundle, a default format string is returned which will identify the missing key when printed.

Parameters:
key - the key of the format string to retrieve
bundle - the bundle to retrieve the format string from
Returns:
the format string.

getString

public static String getString(String key,
                               ResourceBundle bundle)
Print out string according to resourceBundle format.

Parameters:
key - the key of the format string to retrieve
bundle - the bundle to retrieve the format string from

getString

public static String getString(String key,
                               ResourceBundle bundle,
                               Object val)
Print out string according to resourceBundle format.

Parameters:
key - the key of the format string to retrieve
bundle - the bundle to retrieve the format string from
val - the value to substitute into the {0} parameter

getString

public static String getString(String key,
                               ResourceBundle bundle,
                               Object val1,
                               Object val2)
Print out string according to resourceBundle format.

Parameters:
key - the key of the format string to retrieve
bundle - the bundle to retrieve the format string from
val1 - the value to substitute into the {0} parameter
val2 - the value to substitute into the {1} parameter

getString

public static String getString(String key,
                               ResourceBundle bundle,
                               Object val1,
                               Object val2,
                               Object val3)
Print out string according to resourceBundle format.

Parameters:
key - the key of the format string to retrieve
bundle - the bundle to retrieve the format string from
val1 - the value to substitute into the {0} parameter
val2 - the value to substitute into the {1} parameter
val3 - the value to substitute into the {2} parameter


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.