|
RbUtils 0.13 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ktc.rbutils.api.i18n.AbstractLocalized
org.ktc.rbutils.api.audit.AbstractProcessor
org.ktc.rbutils.api.audit.AbstractFileProcessor
org.ktc.rbutils.rb.check.FileChecker
public class FileChecker
Check a properties file against a ResourceBundle
.
Field Summary | |
---|---|
protected PropertiesRB |
propertiesRB
The properties source file. |
protected ResourceBundle |
rbFile
The RB class file to be inspected. |
protected List |
rbKeys
List of keys in the resourcebundle. |
Fields inherited from class org.ktc.rbutils.api.audit.AbstractFileProcessor |
---|
className, fileLocale, fileName |
Fields inherited from class org.ktc.rbutils.api.audit.AbstractProcessor |
---|
loggers |
Fields inherited from class org.ktc.rbutils.api.i18n.AbstractLocalized |
---|
classResource |
Constructor Summary | |
---|---|
FileChecker(File root,
File rbSrcFile)
Instanciates a new FileChecker . |
Method Summary | |
---|---|
protected boolean |
acceptKey(String key)
Tests whether or not the specified key should be checked. |
protected void |
checkIfValuesInSync(String key)
Checks if value in rb and properties are in sync. |
protected boolean |
checkIsRbMissing()
Checks if the ResourceBundle relying on the properties file exists. |
protected boolean |
checkLocalesInSync()
Checks if the Locale of the properties and the rb are in sync. |
protected void |
checkUnreachedRbKeys()
Checks that all keys in the resourcebundle have been reached during the check. |
protected String |
getFormattedPropsValue(String key)
Returns the formatted value of this key in the properties. |
protected String |
getFormattedRbKey(String key)
Formats a key into another one whichwill be used to get the corresponding value in the rb file. |
protected String |
getFormattedRbValue(String key)
Returns the formatted value of the formatted value of this key in the rb. |
protected ResourceBundle |
loadBundle()
Loads the ResourceBundle relying on the properties file and stores it in the
rbfile field. |
void |
performCheck()
Performs the check of properties file. |
Methods inherited from class org.ktc.rbutils.api.audit.AbstractFileProcessor |
---|
fireError, fireInformation, fireProcessFileEnded, fireProcessFileStarted |
Methods inherited from class org.ktc.rbutils.api.audit.AbstractProcessor |
---|
addLogger, addLoggers, fireException |
Methods inherited from class org.ktc.rbutils.api.i18n.AbstractLocalized |
---|
getMessage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.ktc.rbutils.api.audit.Processor |
---|
addLogger, addLoggers, fireException |
Field Detail |
---|
protected PropertiesRB propertiesRB
protected ResourceBundle rbFile
protected final List rbKeys
Constructor Detail |
---|
public FileChecker(File root, File rbSrcFile) throws IOException
FileChecker
.
root
- the root directory of the properties file.rbSrcFile
- the properties file used for the check.
NullArgumentException
- if a parameter is null
.
FileNotFoundException
- if a parameter is a File
that does not
exist in the filesystem.
NotDirectoryException
- if root
is not a
directory in the filesystem.
NotFileException
- if rbSrcFile
is not a file
in the filesystem.
IOException
- if problems occured on Properties file load.Method Detail |
---|
public void performCheck()
First, we look if a ResourceBundle is found in the classpath. If so, we check all keys of the
properties file to check synchronization with the ResourceBundle.
Errors are reported via the registered loggers.
protected ResourceBundle loadBundle()
ResourceBundle
relying on the properties file and stores it in the
rbfile
field. rbKeys
field.
This must be the first step before launching checks.
MissingResourceException
- if the bundle cannot be loaded.protected boolean checkIsRbMissing()
ResourceBundle
relying on the properties file exists.
First, tries to load the bundle using loadBundle()
. If the load fails, the method
fire errors to all listeners and returns true
. Returns false
otherwise.
true
is the ResourceBundle
cannot be loaded;
false
otherwise.protected boolean checkLocalesInSync()
Locale
of the properties and the rb are in sync.
First, check the locales; if they are not in sync, fire errors to all listeners and returns
false
.
In this implementation, tests if the RB and properties Locale
are the same.
true
is the RB and the properties file have the same
Locale
; false
otherwise.protected boolean acceptKey(String key)
key
- the key to be tested.
true
in this implementation.protected String getFormattedRbKey(String key)
key
- the key to be formatted.
protected String getFormattedPropsValue(String key)
key
- key used to get the formatted value.
protected String getFormattedRbValue(String key)
key
- key used to get the formatted value.
protected void checkIfValuesInSync(String key)
This method should not be overriden. Overrides the utility key an value methods instead.
key
- the key to be checked.protected void checkUnreachedRbKeys()
|
Back to the RbUtils Home Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |