[libbluray-devel] javax.media.MediaLocator: improve compatibility
hpi1
git at videolan.org
Wed Apr 13 10:28:50 CEST 2016
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Apr 11 15:10:46 2016 +0300| [4cf2f0d6a6f0158cc8985a4a36917e60d236285c] | committer: hpi1
javax.media.MediaLocator: improve compatibility
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=4cf2f0d6a6f0158cc8985a4a36917e60d236285c
---
.../bdj/java/javax/media/MediaLocator.java | 33 ++++++++++++++------
1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/src/libbluray/bdj/java/javax/media/MediaLocator.java b/src/libbluray/bdj/java/javax/media/MediaLocator.java
index 245ac54..1698764 100644
--- a/src/libbluray/bdj/java/javax/media/MediaLocator.java
+++ b/src/libbluray/bdj/java/javax/media/MediaLocator.java
@@ -26,26 +26,39 @@ import java.net.URL;
public class MediaLocator implements Serializable
{
public MediaLocator(URL url) {
- this(url.toExternalForm());
+ this.url = url;
+ if (url != null) {
+ this.locatorString = url.toString().trim();
+ }
}
public MediaLocator(String locatorString) {
- int index = locatorString.indexOf(":");
- if (index <= 0)
- throw new IllegalArgumentException("Bad locator string.");
- protocol = locatorString.substring(0, index);
- remainder = locatorString.substring(index + 1);
+ if (locatorString != null)
+ this.locatorString = locatorString.trim();
}
public URL getURL() throws MalformedURLException {
- return new URL(toExternalForm());
+ if (url == null) {
+ url = new URL(locatorString);
+ }
+ return url;
}
public String getProtocol() {
+ String protocol = "";
+ int col = locatorString.indexOf(":");
+ if (col >= 0) {
+ protocol = locatorString.substring(0, col);
+ }
return protocol;
}
public String getRemainder() {
+ String remainder = "";
+ int col = locatorString.indexOf(":");
+ if (col >= 0) {
+ remainder = locatorString.substring(col + 1);
+ }
return remainder;
}
@@ -54,11 +67,11 @@ public class MediaLocator implements Serializable
}
public String toExternalForm() {
- return protocol + ":" + remainder;
+ return locatorString;
}
- private String protocol = "";
- private String remainder = "";
+ private String locatorString = "";
+ private URL url = null;
private static final long serialVersionUID = 1L;
}
More information about the libbluray-devel
mailing list