Methods Summary |
---|
public static com.android.sdklib.project.ProjectProperties | create(java.lang.String projectFolderOsPath, com.android.sdklib.project.ProjectProperties$PropertyType type)Creates a new project properties object, with no properties.
The file is not created until {@link #save()} is called.
// create and return a ProjectProperties with an empty map.
return new ProjectProperties(projectFolderOsPath, new HashMap<String, String>(), type);
|
public java.lang.String | getProperty(java.lang.String name)Returns the value of a property.
return mProperties.get(name);
|
public static com.android.sdklib.project.ProjectProperties | load(java.lang.String projectFolderOsPath, com.android.sdklib.project.ProjectProperties$PropertyType type)Loads a project properties file and return a {@link ProjectProperties} object
containing the properties
File projectFolder = new File(projectFolderOsPath);
if (projectFolder.isDirectory()) {
File defaultFile = new File(projectFolder, type.mFilename);
if (defaultFile.isFile()) {
Map<String, String> map = SdkManager.parsePropertyFile(defaultFile, null /* log */);
if (map != null) {
return new ProjectProperties(projectFolderOsPath, map, type);
}
}
}
return null;
|
public com.android.sdklib.project.ProjectProperties | merge(com.android.sdklib.project.ProjectProperties$PropertyType type)Merges all properties from the given file into the current properties.
This emulates the Ant behavior: existing properties are not overriden.
Only new undefined properties become defined.
Typical usage:
- Create a ProjectProperties with {@link PropertyType#BUILD}
- Merge in values using {@link PropertyType#DEFAULT}
- The result is that this contains all the properties from default plus those
overridden by the build.properties file.
File projectFolder = new File(mProjectFolderOsPath);
if (projectFolder.isDirectory()) {
File defaultFile = new File(projectFolder, type.mFilename);
if (defaultFile.isFile()) {
Map<String, String> map = SdkManager.parsePropertyFile(defaultFile, null /* log */);
if (map != null) {
for(Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (!mProperties.containsKey(key) && value != null) {
mProperties.put(key, value);
}
}
}
}
}
return this;
|
public java.lang.String | removeProperty(java.lang.String name)Removes a property and returns its previous value (or null if the property did not exist).
return mProperties.remove(name);
|
public void | save()Saves the property file.
File toSave = new File(mProjectFolderOsPath, mType.mFilename);
FileWriter writer = new FileWriter(toSave);
// write the header
writer.write(mType.mHeader);
// write the properties.
for (Entry<String, String> entry : mProperties.entrySet()) {
String comment = COMMENT_MAP.get(entry.getKey());
if (comment != null) {
writer.write(comment);
}
String value = entry.getValue();
value = value.replaceAll("\\\\", "\\\\\\\\");
writer.write(String.format("%s=%s\n", entry.getKey(), value));
}
// close the file to flush
writer.close();
|
public void | setAndroidTarget(com.android.sdklib.IAndroidTarget target)Sets the target property to the given {@link IAndroidTarget} object.
assert mType == PropertyType.DEFAULT;
mProperties.put(PROPERTY_TARGET, target.hashString());
|
public void | setProperty(java.lang.String name, java.lang.String value)Sets a new properties. If a property with the same name already exists, it is replaced.
mProperties.put(name, value);
|