public abstract class AbstractResourceBundleCli extends AbstractVersionedMain
CLI program
to process NlsBundle
s or
AbstractResourceBundle
s for localization maintenance.ResourceBundleSynchronizer
Modifier and Type | Field and Description |
---|---|
private List<Class<?>> |
bundleClasses |
private NlsBundleHelper |
bundleHelper |
private String |
datePattern |
protected static String |
DEFAULT_BASE_PATH |
private static String |
DEFAULT_DATE_PATTERN |
private static String |
DEFAULT_ENCODING |
private String |
encoding |
private String |
newline |
static String |
OPTION_BUNDLE_CLASS
The command-line option to set the bundle-class.
|
static String |
OPTION_DATE_PATTERN
The command-line option to
set the date-pattern . |
static String |
OPTION_ENCODING
The command-line option to
set the encoding . |
static String |
OPTION_LOCALE
The command-line option to set the locales.
|
static String |
OPTION_PATH
The command-line option to
set the path . |
private String |
path |
private ReflectionUtil |
reflectionUtil |
private NlsResourceBundleLocator |
resourceBundleLocator |
EXIT_CODE_CONSTRAINT_VIOLATION, EXIT_CODE_ILLEGAL_SYNTAX, EXIT_CODE_OK, EXIT_CODE_UNEXPECTED
Constructor and Description |
---|
AbstractResourceBundleCli()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
List<Class<?>> |
getBundleClasses()
This method gets the
Class reflecting the ResourceBundle to synchronize. |
NlsBundleHelper |
getBundleHelper() |
String |
getDatePattern()
This method gets the pattern used to format the date comment.
|
String |
getEncoding()
This method gets the encoding used to read and write the bundles.
|
abstract String[] |
getLocales()
This method gets the locales of the bundles that should be
synchronized . |
protected List<String> |
getLocales(NlsBundleDescriptor bundle) |
String |
getNewline()
This method sets the newline string used to terminate a line in the resource bundle.
|
String |
getPath()
This method gets the base-path where the bundles are written to.
|
ReflectionUtil |
getReflectionUtil()
This method gets the
ReflectionUtil . |
NlsResourceBundleLocator |
getResourceBundleLocator()
This method gets the
NlsResourceBundleLocator . |
protected abstract File |
getTargetFile(NlsBundleDescriptor bundle,
String locale) |
protected File |
getTargetFileMkdirs(NlsBundleDescriptor bundle,
String locale) |
private boolean |
isProductive(Class<?> bundleClass)
Determines if the given
bundleClass is productive . |
protected int |
runDefaultMode()
This method is called from
AbstractVersionedMain.run(CliModeObject) if the program is executed in default mode . |
void |
setBundleClasses(List<Class<?>> bundleClasses)
This method sets the
bundle-classes . |
void |
setBundleHelper(NlsBundleHelper bundleHelper) |
void |
setDatePattern(String datePattern) |
void |
setEncoding(String encoding)
This method sets the
encoding . |
void |
setLocales(Locale... locales)
This method sets the
locales . |
abstract void |
setLocales(String[] locales)
This method sets the
locales . |
void |
setNewline(String newline) |
void |
setPath(String basePath)
This method sets the
base-path . |
void |
setReflectionUtil(ReflectionUtil reflectionUtil) |
void |
setResourceBundleLocator(NlsResourceBundleLocator resourceBundleFinder) |
void |
synchronize(NlsBundleDescriptor bundle)
This method synchronizes (creates or updates) the localized bundles (properties).
|
protected abstract void |
synchronize(NlsBundleDescriptor bundle,
String locale,
File targetFile,
String date)
Like
synchronize(NlsBundleDescriptor) but for a single Locale . |
getVersion, run
getIocContainer, getOutputSettings, getParserBuilder, getStandardError, getStandardOutput, getStreamUtil, handleError, printHelp, run, runAndExit, setStandardError, setStandardOutput, validate
getLogger
public static final String OPTION_DATE_PATTERN
set the date-pattern
.public static final String OPTION_ENCODING
set the encoding
.public static final String OPTION_PATH
set the path
.public static final String OPTION_BUNDLE_CLASS
public static final String OPTION_LOCALE
protected static final String DEFAULT_BASE_PATH
getPath()
,
Constant Field Valuesprivate static final String DEFAULT_ENCODING
private static final String DEFAULT_DATE_PATTERN
@CliOption(name="--path", aliases="-p", operand="DIR", usage="Write property-files to the base-path {operand} (Default is \"{default}\").") private String path
@CliOption(name="--encoding", aliases="-e", operand="ENC", usage="Read and write property-files using the specified encoding {operand} (Default is {default}).") private String encoding
private String newline
@CliOption(name="--date-pattern", aliases="-d", operand="PATTERN", usage="Use the specified date pattern {operand} for writing synchronization date to property-files (Default is \"{default}\").") private String datePattern
@CliOption(name="--bundle", aliases="-b", operand="CLASS", usage="The explicit list of bundle-classes for which the property-files should be created or updated. It has to be the fully qualified name of a subclass of AbstractResourceBundle. For all given locales the according property-file is created or updated. If this option is omitted the bundle-classes are resolved from all instances of META-INF/net.sf.mmm/nls-bundles on your classpath.") private List<Class<?>> bundleClasses
private NlsResourceBundleLocator resourceBundleLocator
private ReflectionUtil reflectionUtil
private NlsBundleHelper bundleHelper
public String getDatePattern()
SimpleDateFormat
public void setDatePattern(String datePattern)
datePattern
- the datePattern to setpublic abstract String[] getLocales()
synchronized
.
Examples for locales (entries of the returned array) are ""
, "en"
, or "en_GB"
.public abstract void setLocales(String[] locales)
locales
.locales
- are the locales to setpublic void setLocales(Locale... locales)
locales
.locales
- are the locales to setpublic String getPath()
DEFAULT_BASE_PATH
.public void setPath(String basePath)
base-path
.basePath
- the basePath to setpublic String getEncoding()
UTF-8
.public void setEncoding(String encoding)
encoding
.encoding
- the encoding to setpublic String getNewline()
\n
).public void setNewline(String newline)
newline
- the newline to setpublic List<Class<?>> getBundleClasses()
Class
reflecting the ResourceBundle
to synchronize.public void setBundleClasses(List<Class<?>> bundleClasses)
bundle-classes
.bundleClasses
- is the List
of bundle-classes to setpublic NlsResourceBundleLocator getResourceBundleLocator()
NlsResourceBundleLocator
.NlsResourceBundleLocator
.public void setResourceBundleLocator(NlsResourceBundleLocator resourceBundleFinder)
resourceBundleFinder
- is the resourceBundleFinder to setpublic ReflectionUtil getReflectionUtil()
ReflectionUtil
.ReflectionUtil
.public void setReflectionUtil(ReflectionUtil reflectionUtil)
reflectionUtil
- is the ReflectionUtil
.public NlsBundleHelper getBundleHelper()
NlsBundleHelper
.public void setBundleHelper(NlsBundleHelper bundleHelper)
bundleHelper
- is the NlsBundleHelper
.public void synchronize(NlsBundleDescriptor bundle) throws IOException
bundle
- is the bundle instance as java object.IOException
- if the operation failed with an input/output error.protected File getTargetFileMkdirs(NlsBundleDescriptor bundle, String locale)
protected abstract File getTargetFile(NlsBundleDescriptor bundle, String locale)
protected List<String> getLocales(NlsBundleDescriptor bundle)
bundle
- the NlsBundleDescriptor
.locales
to process for the bundle.protected abstract void synchronize(NlsBundleDescriptor bundle, String locale, File targetFile, String date) throws IOException
synchronize(NlsBundleDescriptor)
but for a single Locale
.bundle
- the bundle instance as java object.locale
- the locale to synchronize as string.targetFile
- the File
to write to. May not yet exists but parent folder exists.date
- is the current date as string.IOException
- if an I/O problem occurred.protected int runDefaultMode() throws Exception
AbstractVersionedMain
AbstractVersionedMain.run(CliModeObject)
if the program is executed in default
mode
.runDefaultMode
in class AbstractVersionedMain
AbstractMain.EXIT_CODE_OK
on success.Exception
- in case of an unexpected error.private boolean isProductive(Class<?> bundleClass)
bundleClass
is productive
.bundleClass
- is the Class
to test.true
if productive
, false
otherwise.Copyright © 2001–2016 mmm-Team. All rights reserved.