[vlma-devel] commit: Initialize fields in constructors. (Adrien Grand )

git version control git at videolan.org
Tue Aug 5 23:30:39 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Tue Aug  5 22:03:23 2008 +0200| [901469c6b770c71df9db41e1ce0e275bb23fadc0] | committer: Adrien Grand 

Initialize fields in constructors.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=901469c6b770c71df9db41e1ce0e275bb23fadc0
---

 .../main/java/org/videolan/vlma/model/Order.java   |   21 ++++++++++++++++++++
 .../videolan/vlma/model/adapter/DVBSAdapter.java   |    7 ++++++
 .../java/org/videolan/vlma/model/media/Media.java  |    8 -------
 .../org/videolan/vlma/model/media/SatChannel.java  |    8 +++++++
 .../main/java/org/videolan/vlma/OrderGiver.java    |    4 +--
 5 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/vlma-api/src/main/java/org/videolan/vlma/model/Order.java b/vlma-api/src/main/java/org/videolan/vlma/model/Order.java
index 7471758..77caeb6 100644
--- a/vlma-api/src/main/java/org/videolan/vlma/model/Order.java
+++ b/vlma-api/src/main/java/org/videolan/vlma/model/Order.java
@@ -37,6 +37,27 @@ public class Order {
     private MediaGroup medias;
 
     /**
+     * Constructs a new Order.
+     *
+     * @param adapter the adapter to send commands to
+     * @param medias the mediagroup that will be streamed when the order will
+     *               be sent
+     */
+    public Order(Adapter adapter, MediaGroup medias) {
+        this.adapter = adapter;
+        this.medias = medias;
+    }
+
+    /**
+     * Constructs a new Order with an empty {@link MediaGroup }.
+     *
+     * @param adapter the adapter to send commands to
+     */
+    public Order(Adapter adapter) {
+        this(adapter, new MediaGroup());
+    }
+
+    /**
      * Gets the adapter associated with the order.
      *
      * @return the adapter
diff --git a/vlma-api/src/main/java/org/videolan/vlma/model/adapter/DVBSAdapter.java b/vlma-api/src/main/java/org/videolan/vlma/model/adapter/DVBSAdapter.java
index 81bc668..e8a920c 100644
--- a/vlma-api/src/main/java/org/videolan/vlma/model/adapter/DVBSAdapter.java
+++ b/vlma-api/src/main/java/org/videolan/vlma/model/adapter/DVBSAdapter.java
@@ -38,6 +38,13 @@ public class DVBSAdapter extends Adapter {
     private Satellite satellite;
 
     /**
+     * Constructs a new DVBSAdapter.
+     */
+    public DVBSAdapter() {
+        this.satellite = new Satellite("");
+    }
+
+    /**
      * Returns the name describing the adapter type.
      *
      * @return the adapter type name
diff --git a/vlma-api/src/main/java/org/videolan/vlma/model/media/Media.java b/vlma-api/src/main/java/org/videolan/vlma/model/media/Media.java
index c487225..09b0483 100644
--- a/vlma-api/src/main/java/org/videolan/vlma/model/media/Media.java
+++ b/vlma-api/src/main/java/org/videolan/vlma/model/media/Media.java
@@ -33,14 +33,6 @@ public abstract class Media implements Serializable {
 
     protected Program program;
 
-    public int compareTo(Media other) {
-        if (name == null) {
-            return -1;
-        } else {
-            return name.compareTo(other.getName());
-        }
-    }
-
     /**
      * Gives the program associated with the media.
      *
diff --git a/vlma-api/src/main/java/org/videolan/vlma/model/media/SatChannel.java b/vlma-api/src/main/java/org/videolan/vlma/model/media/SatChannel.java
index 577669f..9099e8b 100644
--- a/vlma-api/src/main/java/org/videolan/vlma/model/media/SatChannel.java
+++ b/vlma-api/src/main/java/org/videolan/vlma/model/media/SatChannel.java
@@ -54,6 +54,14 @@ public class SatChannel extends Media {
     public static final String DEFAULT_RADIO_SAP_GROUP = "Radio";
 
     /**
+     * Constructs a new SatChannel.
+     */
+    public SatChannel() {
+        this.category = "R-DIG";
+        this.coverage = "";
+    }
+
+    /**
      * Gets the channel category (TV, radio, encrypted, etc.).
      *
      * @return the channel category
diff --git a/vlma-core/src/main/java/org/videolan/vlma/OrderGiver.java b/vlma-core/src/main/java/org/videolan/vlma/OrderGiver.java
index 6f9d639..cba7418 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/OrderGiver.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/OrderGiver.java
@@ -170,9 +170,7 @@ public class OrderGiver {
             Iterator<MediaGroup> groupIt = sameHashTypeGroups.iterator();
             Iterator<Adapter> adapterIt = sameHashTypeAdapters.iterator();
             while(groupIt.hasNext() && adapterIt.hasNext()) {
-                Order order = new Order();
-                order.setAdapter(adapterIt.next());
-                order.setMedias(groupIt.next());
+                Order order = new Order(adapterIt.next(), groupIt.next());
                 orders.add(order);
             }
             while(groupIt.hasNext()) {



More information about the vlma-devel mailing list