* @throws SecurityException like {@link File#delete()} does if file/folder is not writable.
*/
private boolean deleteContentOf(File folder) throws SecurityException {
- for (File f : folder.listFiles()) {
- if (f.isDirectory()) {
- if (deleteContentOf(f) == false) {
+ File[] files = folder.listFiles();
+ if (files != null) {
+ for (File f : files) {
+ if (f.isDirectory()) {
+ if (deleteContentOf(f) == false) {
+ return false;
+ }
+ }
+ if (f.delete() == false) {
return false;
}
- }
- if (f.delete() == false) {
- return false;
- }
+ }
}
return true;
}\r
\r
/**\r
+ * Returns the short description of the source, if not null.\r
+ * Otherwise returns the default Object toString result.\r
+ * <p/>\r
+ * This is mostly helpful for debugging.\r
+ * For UI display, use the {@link IDescription} interface.\r
+ */\r
+ @Override\r
+ public String toString() {\r
+ String s = getShortDescription();\r
+ if (s != null) {\r
+ return s;\r
+ }\r
+ return super.toString();\r
+ }\r
+\r
+ /**\r
* Generates a short description for this archive.\r
*/\r
public String getShortDescription() {\r
// We're not going to check that all tools are present. At the very least\r
// we should expect to find android and an emulator adapted to the current OS.\r
Set<String> names = new HashSet<String>();\r
- for (File file : toolFolder.listFiles()) {\r
- names.add(file.getName());\r
+ File[] files = toolFolder.listFiles();\r
+ if (files != null) {\r
+ for (File file : files) {\r
+ names.add(file.getName());\r
+ }\r
}\r
if (!names.contains(SdkConstants.androidCmdName()) ||\r
!names.contains(SdkConstants.FN_EMULATOR)) {\r
}\r
\r
/**\r
+ * Returns the short description of the source, if not null.\r
+ * Otherwise returns the default Object toString result.\r
+ * <p/>\r
+ * This is mostly helpful for debugging.\r
+ * For UI display, use the {@link IDescription} interface.\r
+ */\r
+ @Override\r
+ public String toString() {\r
+ String s = getShortDescription();\r
+ if (s != null) {\r
+ return s;\r
+ }\r
+ return super.toString();\r
+ }\r
+\r
+ /**\r
* Returns a short description for an {@link IDescription}.\r
* Can be empty but not null.\r
*/\r
mPackages = null;\r
}\r
\r
+ /**\r
+ * Returns the short description of the source, if not null.\r
+ * Otherwise returns the default Object toString result.\r
+ * <p/>\r
+ * This is mostly helpful for debugging.\r
+ * For UI display, use the {@link IDescription} interface.\r
+ */\r
+ @Override\r
+ public String toString() {\r
+ String s = getShortDescription();\r
+ if (s != null) {\r
+ return s;\r
+ }\r
+ return super.toString();\r
+ }\r
+\r
public String getShortDescription() {\r
\r
// TODO extract domain from URL and add to UiName if not present.\r
public IAbstractResource[] listMembers() {
File[] files = listFiles();
- final int count = files.length;
+ final int count = files == null ? 0 : files.length;
IAbstractResource[] afiles = new IAbstractResource[count];
- for (int i = 0 ; i < count ; i++) {
- File f = files[i];
- if (f.isFile()) {
- afiles[i] = new FileWrapper(f);
- } else {
- afiles[i] = new FolderWrapper(f);
+ if (files != null) {
+ for (int i = 0 ; i < count ; i++) {
+ File f = files[i];
+ if (f.isFile()) {
+ afiles[i] = new FileWrapper(f);
+ } else {
+ afiles[i] = new FolderWrapper(f);
+ }
}
}
public String[] list(FilenameFilter filter) {
File[] files = listFiles();
- if (files.length > 0) {
+ if (files != null && files.length > 0) {
ArrayList<String> list = new ArrayList<String>();
for (File file : files) {
}\r
return "";\r
}\r
+\r
+ /**\r
+ * Returns the short description of the parent package of the new archive, if not null.\r
+ * Otherwise returns the default Object toString result.\r
+ * <p/>\r
+ * This is mostly helpful for debugging. For UI display, use the {@link IDescription}\r
+ * interface.\r
+ */\r
+ @Override\r
+ public String toString() {\r
+ if (mNewArchive != null) {\r
+ Package p = mNewArchive.getParentPackage();\r
+ if (p != null) {\r
+ return p.getShortDescription();\r
+ }\r
+ }\r
+ return super.toString();\r
+ }\r
}\r