public class Util extends Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
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 . |
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.
|
public static String checkFileName(String name, String desc)
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.name
- the file namedesc
- a short descriptive string which describes the file, suitable
for inclusion in the error messagenull
if all checks passpublic static String checkURL(URL url, String desc)
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.url
- the URL
to checkdesc
- a description of the source of the urlnull
if the access check passespublic static String checkSystemPropertyFile(String prop, String desc)
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.prop
- name of a system property whose value must be a file namedesc
- a short descriptive string which describes the file, suitable
for inclusion in the error messagenull
if all checks passpublic static ResourceBundle getResourceBundle(Class clazz)
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.clazz
- the class for which to obtain a resource bundlepublic static String getString(String key, ResourceBundle bundle)
key
- the key of the format string to retrievebundle
- the bundle to retrieve the format string frompublic static String getString(String key, ResourceBundle bundle, Object val)
key
- the key of the format string to retrievebundle
- the bundle to retrieve the format string fromval
- the value to substitute into the {0} parameterpublic static String getString(String key, ResourceBundle bundle, Object val1, Object val2)
key
- the key of the format string to retrievebundle
- the bundle to retrieve the format string fromval1
- the value to substitute into the {0} parameterval2
- the value to substitute into the {1} parameterpublic static String getString(String key, ResourceBundle bundle, Object val1, Object val2, Object val3)
key
- the key of the format string to retrievebundle
- the bundle to retrieve the format string fromval1
- the value to substitute into the {0} parameterval2
- the value to substitute into the {1} parameterval3
- the value to substitute into the {2} parameterCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.