From 7417d5e925e15721d02207329b8a2ed22b6aa024 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 22 Apr 2014 17:45:51 +0100 Subject: [PATCH] Bug 999398 - Rename RawResource.get() to RawResource.getAsString() (r=nalexander) --- mobile/android/base/db/HomeProvider.java | 2 +- mobile/android/base/util/RawResource.java | 11 ++++++++++- .../browser/junit3/src/tests/TestRawResource.java | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/mobile/android/base/db/HomeProvider.java b/mobile/android/base/db/HomeProvider.java index b20ada364833..9960abda7609 100644 --- a/mobile/android/base/db/HomeProvider.java +++ b/mobile/android/base/db/HomeProvider.java @@ -83,7 +83,7 @@ public class HomeProvider extends SQLiteBridgeContentProvider { private Cursor queryFakeItems(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { JSONArray items = null; try { - final String jsonString = RawResource.get(getContext(), R.raw.fake_home_items); + final String jsonString = RawResource.getAsString(getContext(), R.raw.fake_home_items); items = new JSONArray(jsonString); } catch (IOException e) { Log.e(LOGTAG, "Error getting fake home items", e); diff --git a/mobile/android/base/util/RawResource.java b/mobile/android/base/util/RawResource.java index 684dceeedb21..5bcad1c6024d 100644 --- a/mobile/android/base/util/RawResource.java +++ b/mobile/android/base/util/RawResource.java @@ -12,8 +12,17 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.StringWriter; +/** + * {@code RawResource} provides API to load raw resources in different + * forms. For now, we only load them as strings. We're using raw resources + * as localizable 'assets' as opposed to a string that can be directly + * translatable e.g. JSON file vs string. + * + * This is just a utility class to avoid code duplication for the different + * cases where need to read such assets. + */ public final class RawResource { - public static String get(Context context, int id) throws IOException { + public static String getAsString(Context context, int id) throws IOException { InputStreamReader reader = null; try { diff --git a/mobile/android/tests/browser/junit3/src/tests/TestRawResource.java b/mobile/android/tests/browser/junit3/src/tests/TestRawResource.java index 5bed8c45cae2..96f41a327e6e 100644 --- a/mobile/android/tests/browser/junit3/src/tests/TestRawResource.java +++ b/mobile/android/tests/browser/junit3/src/tests/TestRawResource.java @@ -16,7 +16,7 @@ import java.io.IOException; import org.mozilla.gecko.util.RawResource; /** - * Tests whether RawResource.get() produces the right String + * Tests whether RawResource.getAsString() produces the right String * result after reading the returned raw resource's InputStream. */ public class TestRawResource extends BrowserTestCase { @@ -57,7 +57,7 @@ public class TestRawResource extends BrowserTestCase { String result; try { - result = RawResource.get(context, RAW_RESOURCE_ID); + result = RawResource.getAsString(context, RAW_RESOURCE_ID); } catch (IOException e) { result = null; }