use of java.util.PropertyResourceBundle in project eclipse-cs by checkstyle.
the class ConfigurationType method getPropertyResolver.
/**
* Gets the property resolver for this configuration type used to expand property values within
* the checkstyle configuration.
*
* @param checkConfiguration
* the actual check configuration
* @return the property resolver
* @throws IOException
* error creating the property resolver
* @throws URISyntaxException
*/
protected PropertyResolver getPropertyResolver(ICheckConfiguration config, CheckstyleConfigurationFile configFile) throws IOException, URISyntaxException {
MultiPropertyResolver multiResolver = new MultiPropertyResolver();
multiResolver.addPropertyResolver(new ResolvablePropertyResolver(config));
File f = URIUtil.toFile(configFile.getResolvedConfigFileURL().toURI());
if (f != null) {
multiResolver.addPropertyResolver(new StandardPropertyResolver(f.toString()));
} else {
multiResolver.addPropertyResolver(new StandardPropertyResolver(configFile.getResolvedConfigFileURL().toString()));
}
multiResolver.addPropertyResolver(new ClasspathVariableResolver());
multiResolver.addPropertyResolver(new SystemPropertyResolver());
if (configFile.getAdditionalPropertiesBundleStream() != null) {
ResourceBundle bundle = new PropertyResourceBundle(configFile.getAdditionalPropertiesBundleStream());
multiResolver.addPropertyResolver(new ResourceBundlePropertyResolver(bundle));
}
return multiResolver;
}
use of java.util.PropertyResourceBundle in project clusterMaker2 by RBVI.
the class Console method findAndReadConfigIfGivenAndSetMode.
/**
* Looks through the input variables to see if a config file is defined. If
* so all parameters are read from this config file. If some do not exist, a
* warning is given, but the program continues. It may be the case that
* these parameters are unwanted or belong to an unused implementation. It
* also looks if a mode was given and sets this, otherwise the default is
* used.
*
* It also checks whether input AND output files/directories are given,
* which is compulsory when starting with the console and not with the gui.
*
* @return boolean value if an input and an output file (both) are given.
* @throws InvalidInputFileException
* If the given config class does not end in .conf.
*/
private boolean findAndReadConfigIfGivenAndSetMode() throws InvalidInputFileException, ArgsParseException {
boolean input = false;
boolean output = false;
String configPath = TaskConfig.DEFAULTCONFIG;
for (int i = 0; i < args.length; i++) {
/* check whether an input file is given */
if (args[i].trim().equals("-i")) {
input = true;
++i;
}
if (args[i].trim().equals("-o")) {
output = true;
++i;
}
/* check for mode parameter */
if (args[i].trim().equals("-mode")) {
String value = args[i + 1].trim();
try {
int md = Integer.parseInt(value);
if (md == TaskConfig.GENERAL_TRAINING_MODE) {
TaskConfig.mode = TaskConfig.GENERAL_TRAINING_MODE;
} else if (md == TaskConfig.CLUSTERING_MODE) {
TaskConfig.mode = TaskConfig.CLUSTERING_MODE;
} else if (md == TaskConfig.COMPARISON_MODE) {
TaskConfig.mode = TaskConfig.COMPARISON_MODE;
} else if (md == TaskConfig.HIERARICHAL_MODE) {
TaskConfig.mode = TaskConfig.HIERARICHAL_MODE;
} else {
throw new ArgsParseException("The given mode is incorrect - it does not exist! " + md);
}
} catch (Exception e) {
throw new ArgsParseException("The given mode is not an interger value: " + value);
}
++i;
}
/* check for config parameter */
if (args[i].trim().equals("-config")) {
String value = args[i + 1].trim();
if (value.endsWith(".conf")) {
TaskConfig.useConfigFile = true;
TaskConfig.inputConfigPath = value;
configPath = value;
} else {
throw new InvalidInputFileException("An invalid config file was entered. The file must end with '.conf'. Please try again! Given file=" + value);
}
++i;
}
/* check for if -cf parameter is set */
if (args[i].trim().equals("-cf")) {
TaskConfig.useConfigFile = Boolean.parseBoolean(args[i + 1].trim());
++i;
}
}
if (TaskConfig.useConfigFile) {
try {
FileInputStream s = new FileInputStream(configPath);
PropertyResourceBundle configrb = new PropertyResourceBundle(s);
// log.debug("Using config file " + configPath);
TaskConfig.initFromConfigFile(configrb);
FORCEnDLayoutConfig.initFromConfigFile(configrb);
GeometricClusteringConfig.initSLCFromConfigFile(configrb);
GeometricClusteringConfig.initKmeansFromConfigFile(configrb);
} catch (MissingResourceException ex) {
TaskConfig.monitor.showMessage(TaskMonitor.Level.ERROR, "WARNING: Resources are missing in the given config file: " + TaskConfig.DEFAULTCONFIG + ", key=" + ex.getKey() + ". Either you have defined these parameters in the input, or the default values are used from the " + TaskConfig.DEFAULTCONFIG + ". Or these parameters do not interest you, because they belong to an unused implemtation.");
} catch (IOException ex) {
TaskConfig.monitor.showMessage(TaskMonitor.Level.ERROR, "ERROR: Unable to read the given config file: " + configPath);
System.exit(-1);
} catch (InvalidTypeException ex) {
TaskConfig.monitor.showMessage(TaskMonitor.Level.ERROR, "ERROR: You have perhaps given an incorrect class name of an " + "implemtation. Please note that this is case sensitive.");
System.exit(-1);
}
}
if (input && output)
return true;
else
return false;
}
use of java.util.PropertyResourceBundle in project mycore by MyCoRe-Org.
the class MCRCombinedResourceBundleControl method newBundle.
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("New bundle: {}, locale {}", baseName, locale);
}
if (locale.equals(Locale.ROOT)) {
// MCR-1064 fallback should be default language, if property key does not exist
locale = defaultLocale;
}
String bundleName = baseName.substring(baseName.indexOf(':') + 1);
String filename = CONTROL_HELPER.toBundleName(bundleName, locale) + ".properties";
try (MCRConfigurationInputStream propertyStream = new MCRConfigurationInputStream(filename)) {
if (propertyStream.isEmpty()) {
throw new MissingResourceException(// className
"Can't find bundle for base name " + baseName + ", locale " + locale, // className
bundleName + "_" + locale, "");
}
return new PropertyResourceBundle(propertyStream);
}
}
use of java.util.PropertyResourceBundle in project Frankenstein by olir.
the class ProcessingSceneController method filterSetup.
@FXML
public void filterSetup() {
PropertyResourceBundle bundleConfiguration = (PropertyResourceBundle) ResourceBundle.getBundle("de/serviceflow/frankenstein/bundles/filtersetup", Configuration.getInstance().getLocale());
FXMLLoader loader = new FXMLLoader(getClass().getResource("FilterSetupPopup.fxml"), bundleConfiguration);
Stage stage = new Stage();
try {
FilterSetupController controller = new FilterSetupController();
loader.setController(controller);
stage.setScene(new Scene(loader.load()));
controller.configure(this, stage);
stage.setTitle("Edit filter " + selectedFilter.toStringRange());
stage.initModality(Modality.APPLICATION_MODAL);
stage.initOwner(btnListFilter.getScene().getWindow());
stage.showAndWait();
SegmentVideoFilter f = controller.getSelectedFilterInstance();
selectedFilter.setType(f);
processor.applyLocalFilters(filterListData);
Runnable r = new Runnable() {
public void run() {
processor.setPreviewFilter(null);
processor.seek(ProcessingSceneController.this, position);
}
};
ExecutorThread.getInstance().execute(r);
Platform.runLater(() -> {
listViewFilter.refresh();
drawEditCanvas();
});
} catch (IOException e) {
e.printStackTrace();
}
}
use of java.util.PropertyResourceBundle in project LanternServer by LanternPowered.
the class LanternTranslationManager method loadAssetBundle.
private void loadAssetBundle(Asset asset, Locale locale, boolean refresh) {
try {
final InputStream inputStream = asset.getUrl().openStream();
try {
final ResourceBundle bundle = new PropertyResourceBundle(inputStream);
this.bundles.computeIfAbsent(locale, locale0 -> Sets.newConcurrentHashSet()).add(bundle);
if (refresh) {
final Set<ResourceKey> refreshKeys = Sets.newHashSet();
for (ResourceKey key : this.resourceBundlesCache.asMap().keySet()) {
Locale locale1 = key.locale == null ? Locale.ENGLISH : key.locale;
if (locale1.equals(locale) && bundle.containsKey(key.name)) {
refreshKeys.add(key);
}
}
if (!refreshKeys.isEmpty()) {
this.resourceBundlesCache.invalidateAll(refreshKeys);
}
}
} catch (IOException e) {
Lantern.getLogger().warn("Unable to create the resource bundle for: " + asset.getId(), e);
}
} catch (IOException e) {
Lantern.getLogger().warn("Unable to open the asset stream for: " + asset.getId(), e);
}
}
Aggregations