use of aQute.lib.utf8properties.UTF8Properties in project intellij-plugins by JetBrains.
the class BundleManifestCache method readProperties.
private static BundleManifest readProperties(PsiFile propertiesFile) {
try {
UTF8Properties properties = new UTF8Properties();
properties.load(new StringReader(propertiesFile.getText()));
Map<String, String> map = ContainerUtil.newHashMap();
for (Object key : properties.keySet()) {
String name = key.toString();
map.put(name, properties.getProperty(name));
}
if (map.get(Constants.BUNDLE_SYMBOLICNAME) == null) {
VirtualFile file = propertiesFile.getVirtualFile();
if (file != null) {
if (!BndProjectImporter.BND_FILE.equals(file.getName())) {
map.put(Constants.BUNDLE_SYMBOLICNAME, FileUtil.getNameWithoutExtension(file.getName()));
} else if (file.getParent() != null) {
map.put(Constants.BUNDLE_SYMBOLICNAME, file.getParent().getName());
}
}
}
return new BundleManifest(map, propertiesFile);
} catch (IOException ignored) {
} catch (InvalidVirtualFileAccessException ignored) {
}
return null;
}
use of aQute.lib.utf8properties.UTF8Properties in project bnd by bndtools.
the class Analyzer method parsePackageinfo.
Attrs parsePackageinfo(PackageRef packageRef, Resource r) throws Exception {
Properties p = new UTF8Properties();
try {
try (InputStream in = r.openInputStream()) {
p.load(in);
}
Attrs attrs = new Attrs();
for (@SuppressWarnings("unchecked") Enumeration<String> t = (Enumeration<String>) p.propertyNames(); t.hasMoreElements(); ) {
String key = t.nextElement();
String propvalue = p.getProperty(key);
if (key.equalsIgnoreCase("include")) {
// Ouch, could be really old syntax
// We ignore the include part upto we
// ignored it long before.
Matcher m = OLD_PACKAGEINFO_SYNTAX_P.matcher(propvalue);
if (m.matches()) {
key = Constants.VERSION_ATTRIBUTE;
propvalue = m.group(2);
if (isPedantic())
warning("found old syntax in package info in package %s, from resource %s", packageRef, r);
}
}
String value = propvalue;
if (value.startsWith(":")) {
key = key + ":";
value = value.substring(1);
}
attrs.put(key, value);
}
return attrs;
} catch (Exception e) {
msgs.NoSuchFile_(r);
}
return null;
}
use of aQute.lib.utf8properties.UTF8Properties in project bnd by bndtools.
the class Workspace method getDefaults.
public static synchronized Processor getDefaults() {
if (defaults != null)
return defaults;
UTF8Properties props = new UTF8Properties();
try (InputStream propStream = Workspace.class.getResourceAsStream("defaults.bnd")) {
if (propStream != null) {
props.load(propStream);
} else {
System.err.println("Cannot load defaults");
}
} catch (IOException e) {
throw new IllegalArgumentException("Unable to load bnd defaults.", e);
}
defaults = new Processor(props, false);
return defaults;
}
use of aQute.lib.utf8properties.UTF8Properties in project bnd by bndtools.
the class Processor method loadProperties.
/**
* Helper to load a properties file from disk.
*
* @param file
* @throws IOException
*/
public Properties loadProperties(File file) throws IOException {
updateModified(file.lastModified(), "Properties file: " + file);
UTF8Properties p = loadProperties0(file);
return p;
}
use of aQute.lib.utf8properties.UTF8Properties in project bnd by bndtools.
the class KnownBundleAnalyzerPlugin method setProperties.
public void setProperties(Map<String, String> config) {
String fileName = config.get(PROP_DATA);
if (fileName == null)
throw new IllegalArgumentException(String.format("Property name '%s' must be set on KnownBundleAnalyzerPlugin", PROP_DATA));
File file = new File(fileName);
if (!file.isFile())
throw new IllegalArgumentException(String.format("Data file does not exist, or is not a plain file: %s", file));
try {
UTF8Properties props = new UTF8Properties();
props.load(file, null);
setKnownBundlesExtra(props);
} catch (Exception e) {
throw new IllegalArgumentException(String.format("Unable to read data file: %s", file), e);
}
}
Aggregations