/**
* Creates an {@link SdkManager} for a given sdk location.
* @param sdkLocation the location of the SDK.
- * @param log the ISdkLog object receiving warning/error from the parsing. Can be null.
+ * @param log the ISdkLog object receiving warning/error from the parsing. Cannot be null.
* @return the created {@link SdkManager} or null if the location is not valid.
*/
public static SdkManager createManager(String sdkLocation, ISdkLog log) {
return manager;
} catch (IllegalArgumentException e) {
- if (log != null) {
- log.error(e, "Error parsing the sdk.");
- }
+ log.error(e, "Error parsing the sdk.");
}
return null;
/**
* Reloads the content of the SDK.
- * @param log the ISdkLog object receiving warning/error from the parsing.
+ *
+ * @param log the ISdkLog object receiving warning/error from the parsing. Cannot be null.
*/
public void reloadSdk(ISdkLog log) {
// get the current target list.
* Loads the Platforms from the SDK.
* @param location Location of the SDK
* @param list the list to fill with the platforms.
- * @param log the ISdkLog object receiving warning/error from the parsing. Can be null.
+ * @param log the ISdkLog object receiving warning/error from the parsing. Cannot be null.
*/
private static void loadPlatforms(String location, ArrayList<IAndroidTarget> list,
ISdkLog log) {
if (target != null) {
list.add(target);
}
- } else if (log != null) {
+ } else {
log.warning("Ignoring platform '%1$s', not a folder.", platform.getName());
}
}
/**
* Loads a specific Platform at a given location.
* @param platform the location of the platform.
- * @param log the ISdkLog object receiving warning/error from the parsing. Can be null.
+ * @param log the ISdkLog object receiving warning/error from the parsing. Cannot be null.
*/
private static PlatformTarget loadPlatform(File platform, ISdkLog log) {
File buildProp = new File(platform, SdkConstants.FN_BUILD_PROP);
// version string
String apiName = map.get(PROP_VERSION_RELEASE);
if (apiName == null) {
- if (log != null) {
- log.error(null,
- "Ignoring platform '%1$s': %2$s is missing from '%3$s'",
- platform.getName(), PROP_VERSION_RELEASE,
- SdkConstants.FN_BUILD_PROP);
- }
+ log.error(null,
+ "Ignoring platform '%1$s': %2$s is missing from '%3$s'",
+ platform.getName(), PROP_VERSION_RELEASE,
+ SdkConstants.FN_BUILD_PROP);
return null;
}
int apiNumber;
String stringValue = map.get(PROP_VERSION_SDK);
if (stringValue == null) {
- if (log != null) {
- log.error(null,
- "Ignoring platform '%1$s': %2$s is missing from '%3$s'",
- platform.getName(), PROP_VERSION_SDK,
- SdkConstants.FN_BUILD_PROP);
- }
+ log.error(null,
+ "Ignoring platform '%1$s': %2$s is missing from '%3$s'",
+ platform.getName(), PROP_VERSION_SDK,
+ SdkConstants.FN_BUILD_PROP);
return null;
} else {
try {
} catch (NumberFormatException e) {
// looks like apiNumber does not parse to a number.
// Ignore this platform.
- if (log != null) {
- log.error(null,
- "Ignoring platform '%1$s': %2$s is not a valid number in %3$s.",
- platform.getName(), PROP_VERSION_SDK,
- SdkConstants.FN_BUILD_PROP);
- }
+ log.error(null,
+ "Ignoring platform '%1$s': %2$s is not a valid number in %3$s.",
+ platform.getName(), PROP_VERSION_SDK,
+ SdkConstants.FN_BUILD_PROP);
return null;
}
}
return target;
}
- } else if (log != null) {
+ } else {
log.error(null, "Ignoring platform '%1$s': %2$s is missing.", platform.getName(),
SdkConstants.FN_BUILD_PROP);
}
* Loads the Add-on from the SDK.
* @param location Location of the SDK
* @param list the list to fill with the add-ons.
- * @param log the ISdkLog object receiving warning/error from the parsing.
+ * @param log the ISdkLog object receiving warning/error from the parsing. Cannot be null.
*/
private static void loadAddOns(String location, ArrayList<IAndroidTarget> list, ISdkLog log) {
File addonFolder = new File(location, SdkConstants.FD_ADDONS);
* Loads a specific Add-on at a given location.
* @param addon the location of the addon.
* @param targetList The list of Android target that were already loaded from the SDK.
- * @param log the ISdkLog object receiving warning/error from the parsing.
+ * @param log the ISdkLog object receiving warning/error from the parsing. Cannot be null.
*/
private static AddOnTarget loadAddon(File addon, ArrayList<IAndroidTarget> targetList,
ISdkLog log) {
if (baseTarget == null) {
// Ignore this add-on.
- if (log != null) {
- log.error(null,
- "Ignoring add-on '%1$s': Unable to find base platform with API level '%2$s'",
- addon.getName(), api);
- }
+ log.error(null,
+ "Ignoring add-on '%1$s': Unable to find base platform with API level '%2$s'",
+ addon.getName(), api);
return null;
}
}
} catch (NumberFormatException e) {
// looks like apiNumber does not parse to a number.
// Ignore this add-on.
- if (log != null) {
- log.error(null,
- "Ignoring add-on '%1$s': %2$s is not a valid number in %3$s.",
- addon.getName(), ADDON_REVISION, SdkConstants.FN_BUILD_PROP);
- }
+ log.error(null,
+ "Ignoring add-on '%1$s': %2$s is not a valid number in %3$s.",
+ addon.getName(), ADDON_REVISION, SdkConstants.FN_BUILD_PROP);
return null;
}
}
if (m.matches()) {
libMap.put(libName, new String[] {
m.group(1), m.group(2) });
- } else if (log != null) {
+ } else {
log.error(null,
"Ignoring library '%1$s', property value has wrong format\n\t%2$s",
libName, libData);
}
- } else if (log != null) {
+ } else {
log.error(null,
"Ignoring library '%1$s', missing property value",
libName, libData);
return target;
}
- } else if (log != null) {
+ } else {
log.error(null, "Ignoring add-on '%1$s': %2$s is missing.", addon.getName(),
SdkConstants.FN_MANIFEST_INI);
}
return IAndroidTarget.NO_USB_ID;
}
+ /**
+ * Displays an error in the log about the addon being ignored due to a missing manifest value.
+ *
+ * @param log The logger object. Cannot be null.
+ * @param addonName The addon name, for display.
+ * @param valueName The missing manifest value, for display.
+ */
private static void displayAddonManifestError(ISdkLog log, String addonName, String valueName) {
- if (log != null) {
- log.error(null, "Ignoring add-on '%1$s': '%2$s' is missing from %3$s.",
- addonName, valueName, SdkConstants.FN_MANIFEST_INI);
- }
+ log.error(null, "Ignoring add-on '%1$s': '%2$s' is missing from %3$s.",
+ addonName, valueName, SdkConstants.FN_MANIFEST_INI);
}
/**
* present.
* <p/>This checks the presence of the following files: android.jar, framework.aidl, aapt(.exe),
* aidl(.exe), dx(.bat), and dx.jar
+ *
+ * @param platform The folder containing the platform.
+ * @param log Logger. Cannot be null.
*/
private static boolean checkPlatformContent(File platform, ISdkLog log) {
for (String relativePath : sPlatformContentList) {
File f = new File(platform, relativePath);
- if (!f.exists() && log != null) {
+ if (!f.exists()) {
log.error(null,
"Ignoring platform '%1$s': %2$s is missing.",
platform.getName(), relativePath);
/**
* Parses a property file (using UTF-8 encoding) and returns a map of the content.
* <p/>If the file is not present, null is returned with no error messages sent to the log.
+ *
* @param propFile the property file to parse
- * @param log the ISdkLog object receiving warning/error from the parsing.
+ * @param log the ISdkLog object receiving warning/error from the parsing. Cannot be null.
* @return the map of (key,value) pairs, or null if the parsing failed.
*/
public static Map<String, String> parsePropertyFile(File propFile, ISdkLog log) {
if (m.matches()) {
map.put(m.group(1), m.group(2));
} else {
- if (log != null) {
- log.warning("Error parsing '%1$s': \"%2$s\" is not a valid syntax",
- propFile.getAbsolutePath(), line);
- }
+ log.warning("Error parsing '%1$s': \"%2$s\" is not a valid syntax",
+ propFile.getAbsolutePath(),
+ line);
return null;
}
}
// calling the method.
// Return null below.
} catch (IOException e) {
- if (log != null) {
- log.warning("Error parsing '%1$s': %2$s.", propFile.getAbsolutePath(),
- e.getMessage());
- }
+ log.warning("Error parsing '%1$s': %2$s.",
+ propFile.getAbsolutePath(),
+ e.getMessage());
} finally {
if (reader != null) {
try {
return new String[0];
}
+ /**
+ * Loads all samples from the {@link SdkConstants#FD_SAMPLES} directory.
+ *
+ * @param log Logger. Cannot be null.
+ */
private void loadSamples(ISdkLog log) {
File sampleFolder = new File(mSdkLocation, SdkConstants.FD_SAMPLES);
if (sampleFolder.isDirectory()) {
}
}
+ /**
+ * Returns the {@link AndroidVersion} of the sample in the given folder.
+ *
+ * @param folder The sample's folder.
+ * @param log Logger for errors. Cannot be null.
+ * @return An {@link AndroidVersion} or null on error.
+ */
private AndroidVersion getSamplesVersion(File folder, ISdkLog log) {
File sourceProp = new File(folder, SdkConstants.FN_SOURCE_PROP);
try {