[libbluray-devel] javax/tv/media: improve compatibly. Log errors.

hpi1 git at videolan.org
Wed Apr 6 11:05:04 CEST 2016


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Apr  5 11:39:25 2016 +0300| [86ceca630dc7ee4611c11aadd7debf6d77032147] | committer: hpi1

javax/tv/media: improve compatibly. Log errors.

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=86ceca630dc7ee4611c11aadd7debf6d77032147
---

 .../bdj/java/javax/tv/media/AWTVideoSize.java      |   33 +++++++-------------
 .../java/javax/tv/media/MediaSelectPermission.java |   21 ++++++++-----
 2 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/src/libbluray/bdj/java/javax/tv/media/AWTVideoSize.java b/src/libbluray/bdj/java/javax/tv/media/AWTVideoSize.java
index e2eafdb..b75f98e 100644
--- a/src/libbluray/bdj/java/javax/tv/media/AWTVideoSize.java
+++ b/src/libbluray/bdj/java/javax/tv/media/AWTVideoSize.java
@@ -24,8 +24,12 @@ import java.awt.Rectangle;
 public class AWTVideoSize
 {
     public AWTVideoSize(Rectangle source, Rectangle dest) {
-        this.source = source;
-        this.dest = dest;
+        if (source == null || dest == null) {
+            System.err.println("null rect");
+            throw new NullPointerException("null rect");
+        }
+        this.source = (Rectangle)source.clone();
+        this.dest = (Rectangle)dest.clone();
     }
 
     public Rectangle getSource() {
@@ -37,11 +41,11 @@ public class AWTVideoSize
     }
 
     public float getXScale() {
-        return getDestination().width / getSource().width;
+        return dest.width / source.width;
     }
 
     public float getYScale() {
-        return getDestination().height / getSource().height;
+        return dest.height / source.height;
     }
 
     public int hashCode() {
@@ -53,28 +57,15 @@ public class AWTVideoSize
     }
 
     public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-        if (obj == null)
-            return false;
-        if (getClass() != obj.getClass())
+        if (!(obj instanceof AWTVideoSize)) {
             return false;
+        }
         AWTVideoSize other = (AWTVideoSize) obj;
-        if (dest == null) {
-            if (other.dest != null)
-                return false;
-        } else if (!dest.equals(other.dest))
-            return false;
-        if (source == null) {
-            if (other.source != null)
-                return false;
-        } else if (!source.equals(other.source))
-            return false;
-        return true;
+        return dest.equals(other.dest) && source.equals(other.source);
     }
 
     public String toString() {
-        return "AWTVideoSize [dest=" + dest + ", source=" + source + "]";
+        return getClass().getName() + "[dest=" + dest + ",source=" + source + "]";
     }
 
     private Rectangle source;
diff --git a/src/libbluray/bdj/java/javax/tv/media/MediaSelectPermission.java b/src/libbluray/bdj/java/javax/tv/media/MediaSelectPermission.java
index 0453ec9..1d8bd80 100644
--- a/src/libbluray/bdj/java/javax/tv/media/MediaSelectPermission.java
+++ b/src/libbluray/bdj/java/javax/tv/media/MediaSelectPermission.java
@@ -38,25 +38,30 @@ public final class MediaSelectPermission extends Permission
     public MediaSelectPermission(String locator, String actions) {
         super("javax.tv.media.MediaSelectPermission");
 
+        if (locator == null)
+            throw new NullPointerException("null locator");
+
         this.locator = locator;
     }
 
     public boolean implies(Permission perm) {
-        return (perm instanceof MediaSelectPermission) && (this.equals(perm) || this.locator.equals("*"));
+        if (perm == null)
+            throw new NullPointerException("permission is null");
+
+        if (!(perm instanceof MediaSelectPermission))
+            return false;
+
+        return equals(perm) || locator.equals("*");
     }
 
     public boolean equals(Object obj) {
-        if (obj == null)
-            return false;
         if (this == obj)
             return true;
-        if (getClass() != obj.getClass())
+        if (!(obj instanceof MediaSelectPermission))
             return false;
+
         MediaSelectPermission other = (MediaSelectPermission) obj;
-        if (locator == null) {
-            if (other.locator != null)
-                return false;
-        } else if (!locator.equals(other.locator))
+        if (!locator.equals(other.locator))
             return false;
         return true;
     }



More information about the libbluray-devel mailing list