Java Code Examples for com.android.io.IAbstractFile#exists()

The following examples show how to use com.android.io.IAbstractFile#exists() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectPropertiesWorkingCopy.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Merges all properties from the given file into the current properties.
 * <p/>
 * This emulates the Ant behavior: existing properties are <em>not</em> overridden.
 * Only new undefined properties become defined.
 * <p/>
 * Typical usage:
 * <ul>
 * <li>Create a ProjectProperties with {@code PropertyType#ANT}
 * <li>Merge in values using {@code PropertyType#PROJECT}
 * <li>The result is that this contains all the properties from default plus those
 *     overridden by the build.properties file.
 * </ul>
 *
 * @param type One the possible {@link ProjectProperties.PropertyType}s.
 * @return this object, for chaining.
 */
public synchronized ProjectPropertiesWorkingCopy merge(PropertyType type) {
    if (mProjectFolder.exists() && mType != type) {
        IAbstractFile propFile = mProjectFolder.getFile(type.getFilename());
        if (propFile.exists()) {
            Map<String, String> map = parsePropertyFile(propFile, 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;
}
 
Example 2
Source File: ProjectPropertiesWorkingCopy.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Merges all properties from the given file into the current properties.
 * <p/>
 * This emulates the Ant behavior: existing properties are <em>not</em> overridden.
 * Only new undefined properties become defined.
 * <p/>
 * Typical usage:
 * <ul>
 * <li>Create a ProjectProperties with {@code PropertyType#ANT}
 * <li>Merge in values using {@code PropertyType#PROJECT}
 * <li>The result is that this contains all the properties from default plus those
 *     overridden by the build.properties file.
 * </ul>
 *
 * @param type One the possible {@link ProjectProperties.PropertyType}s.
 * @return this object, for chaining.
 */
public synchronized ProjectPropertiesWorkingCopy merge(PropertyType type) {
    if (mProjectFolder.exists() && mType != type) {
        IAbstractFile propFile = mProjectFolder.getFile(type.getFilename());
        if (propFile.exists()) {
            Map<String, String> map = parsePropertyFile(propFile, 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;
}
 
Example 3
Source File: ProjectProperties.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Loads a project properties file and return a {@link ProjectProperties} object
 * containing the properties.
 *
 * @param projectFolder the project folder.
 * @param type One the possible {@link PropertyType}s.
 */
public static ProjectProperties load(IAbstractFolder projectFolder, PropertyType type) {
    if (projectFolder.exists()) {
        IAbstractFile propFile = projectFolder.getFile(type.mFilename);
        if (propFile.exists()) {
            Map<String, String> map = parsePropertyFile(propFile, null /* log */);
            if (map != null) {
                return new ProjectProperties(projectFolder, map, type);
            }
        }
    }
    return null;
}
 
Example 4
Source File: ProjectProperties.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Deletes a project properties file.
 *
 * @param projectFolder the project folder.
 * @param type One the possible {@link PropertyType}s.
 * @return true if success.
 */
public static boolean delete(IAbstractFolder projectFolder, PropertyType type) {
    if (projectFolder.exists()) {
        IAbstractFile propFile = projectFolder.getFile(type.mFilename);
        if (propFile.exists()) {
            return propFile.delete();
        }
    }

    return false;
}
 
Example 5
Source File: ProjectProperties.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Reloads the properties from the underlying file.
 */
public synchronized void reload() {
    if (mProjectFolder.exists()) {
        IAbstractFile propFile = mProjectFolder.getFile(mType.mFilename);
        if (propFile.exists()) {
            Map<String, String> map = parsePropertyFile(propFile, null /* log */);
            if (map != null) {
                mProperties.clear();
                mProperties.putAll(map);
            }
        }
    }
}
 
Example 6
Source File: AndroidManifest.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an {@link IAbstractFile} object representing the manifest for the given project.
 *
 * @param projectFolder The project containing the manifest file.
 * @return An IAbstractFile object pointing to the manifest or null if the manifest
 *         is missing.
 */
public static IAbstractFile getManifest(IAbstractFolder projectFolder) {
    IAbstractFile file = projectFolder.getFile(SdkConstants.FN_ANDROID_MANIFEST_XML);
    if (file != null && file.exists()) {
        return file;
    }

    return null;
}
 
Example 7
Source File: ProjectProperties.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Loads a project properties file and return a {@link ProjectProperties} object
 * containing the properties.
 *
 * @param projectFolder the project folder.
 * @param type One the possible {@link PropertyType}s.
 */
public static ProjectProperties load(IAbstractFolder projectFolder, PropertyType type) {
    if (projectFolder.exists()) {
        IAbstractFile propFile = projectFolder.getFile(type.mFilename);
        if (propFile.exists()) {
            Map<String, String> map = parsePropertyFile(propFile, null /* log */);
            if (map != null) {
                return new ProjectProperties(projectFolder, map, type);
            }
        }
    }
    return null;
}
 
Example 8
Source File: ProjectProperties.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Deletes a project properties file.
 *
 * @param projectFolder the project folder.
 * @param type One the possible {@link PropertyType}s.
 * @return true if success.
 */
public static boolean delete(IAbstractFolder projectFolder, PropertyType type) {
    if (projectFolder.exists()) {
        IAbstractFile propFile = projectFolder.getFile(type.mFilename);
        if (propFile.exists()) {
            return propFile.delete();
        }
    }

    return false;
}
 
Example 9
Source File: ProjectProperties.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Reloads the properties from the underlying file.
 */
public synchronized void reload() {
    if (mProjectFolder.exists()) {
        IAbstractFile propFile = mProjectFolder.getFile(mType.mFilename);
        if (propFile.exists()) {
            Map<String, String> map = parsePropertyFile(propFile, null /* log */);
            if (map != null) {
                mProperties.clear();
                mProperties.putAll(map);
            }
        }
    }
}
 
Example 10
Source File: AndroidManifest.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns an {@link IAbstractFile} object representing the manifest for the given project.
 *
 * @param projectFolder The project containing the manifest file.
 * @return An IAbstractFile object pointing to the manifest or null if the manifest
 *         is missing.
 */
public static IAbstractFile getManifest(IAbstractFolder projectFolder) {
    IAbstractFile file = projectFolder.getFile(SdkConstants.FN_ANDROID_MANIFEST_XML);
    if (file != null && file.exists()) {
        return file;
    }

    return null;
}