summaryrefslogtreecommitdiffstats
path: root/core/java/android/net/Uri.java
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2009-07-29 14:57:05 -0700
committerJean-Baptiste Queru <jbq@google.com>2009-07-29 14:57:05 -0700
commit61e4248f8f6ae8a8f40550cc0800e5190cd1dc09 (patch)
tree07d964042985825b97f51b3744977c25b685b2f1 /core/java/android/net/Uri.java
parent2af1b3db3d4f687d008db74b150f149e956b4bc6 (diff)
parenta8675f67e33bc7337d148358783b0fd138b501ff (diff)
downloadframeworks_base-61e4248f8f6ae8a8f40550cc0800e5190cd1dc09.zip
frameworks_base-61e4248f8f6ae8a8f40550cc0800e5190cd1dc09.tar.gz
frameworks_base-61e4248f8f6ae8a8f40550cc0800e5190cd1dc09.tar.bz2
merge from donut
Diffstat (limited to 'core/java/android/net/Uri.java')
-rw-r--r--core/java/android/net/Uri.java50
1 files changed, 25 insertions, 25 deletions
diff --git a/core/java/android/net/Uri.java b/core/java/android/net/Uri.java
index 08bd67e..298be3b 100644
--- a/core/java/android/net/Uri.java
+++ b/core/java/android/net/Uri.java
@@ -105,6 +105,18 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
private static final String LOG = Uri.class.getSimpleName();
/**
+ * NOTE: EMPTY accesses this field during its own initialization, so this
+ * field *must* be initialized first, or else EMPTY will see a null value!
+ *
+ * Placeholder for strings which haven't been cached. This enables us
+ * to cache null. We intentionally create a new String instance so we can
+ * compare its identity and there is no chance we will confuse it with
+ * user data.
+ */
+ @SuppressWarnings("RedundantStringConstructorCall")
+ private static final String NOT_CACHED = new String("NOT CACHED");
+
+ /**
* The empty URI, equivalent to "".
*/
public static final Uri EMPTY = new HierarchicalUri(null, Part.NULL,
@@ -350,15 +362,6 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
private final static int NOT_CALCULATED = -2;
/**
- * Placeholder for strings which haven't been cached. This enables us
- * to cache null. We intentionally create a new String instance so we can
- * compare its identity and there is no chance we will confuse it with
- * user data.
- */
- @SuppressWarnings("RedundantStringConstructorCall")
- private static final String NOT_CACHED = new String("NOT CACHED");
-
- /**
* Error message presented when a user tries to treat an opaque URI as
* hierarchical.
*/
@@ -1080,7 +1083,7 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
/** Used in parcelling. */
static final int TYPE_ID = 3;
- private final String scheme;
+ private final String scheme; // can be null
private final Part authority;
private final PathPart path;
private final Part query;
@@ -1089,10 +1092,10 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
private HierarchicalUri(String scheme, Part authority, PathPart path,
Part query, Part fragment) {
this.scheme = scheme;
- this.authority = authority;
- this.path = path;
- this.query = query;
- this.fragment = fragment;
+ this.authority = Part.nonNull(authority);
+ this.path = path == null ? PathPart.NULL : path;
+ this.query = Part.nonNull(query);
+ this.fragment = Part.nonNull(fragment);
}
static Uri readFrom(Parcel parcel) {
@@ -1155,21 +1158,18 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
}
private void appendSspTo(StringBuilder builder) {
- if (authority != null) {
- String encodedAuthority = authority.getEncoded();
- if (encodedAuthority != null) {
- // Even if the authority is "", we still want to append "//".
- builder.append("//").append(encodedAuthority);
- }
+ String encodedAuthority = authority.getEncoded();
+ if (encodedAuthority != null) {
+ // Even if the authority is "", we still want to append "//".
+ builder.append("//").append(encodedAuthority);
}
- // path is never null.
String encodedPath = path.getEncoded();
if (encodedPath != null) {
builder.append(encodedPath);
}
- if (query != null && !query.isEmpty()) {
+ if (!query.isEmpty()) {
builder.append('?').append(query.getEncoded());
}
}
@@ -1229,7 +1229,7 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
appendSspTo(builder);
- if (fragment != null && !fragment.isEmpty()) {
+ if (!fragment.isEmpty()) {
builder.append('#').append(fragment.getEncoded());
}
@@ -1503,7 +1503,7 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
throw new UnsupportedOperationException(NOT_HIERARCHICAL);
}
- String query = getQuery();
+ String query = getEncodedQuery();
if (query == null) {
return Collections.emptyList();
}
@@ -1566,7 +1566,7 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
throw new UnsupportedOperationException(NOT_HIERARCHICAL);
}
- String query = getQuery();
+ String query = getEncodedQuery();
if (query == null) {
return null;