aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/show/ShowChannel.java
diff options
context:
space:
mode:
authorMatt Windsor <mbw500@student.cs.york.ac.uk>2011-03-07 13:50:24 +0000
committerMatt Windsor <mbw500@student.cs.york.ac.uk>2011-03-07 13:50:24 +0000
commit9b4647f1ae8c3f41163d0d4053504dab861d0c94 (patch)
treeb621e8c0b75a5cadd69f938116b1637f7ad0c94d /src/uk/org/ury/show/ShowChannel.java
parentc33f098de8a43a2df778d4d694e0c07bbde59828 (diff)
Emergency impending hard drive failure dump - lots of changes on the frontend, but they're all potentially controversial so I'm not pushing to master yet. Beginnings of show viewer. Application now run through demo menu, which allows for the links between modules to be tested.
Diffstat (limited to 'src/uk/org/ury/show/ShowChannel.java')
-rw-r--r--src/uk/org/ury/show/ShowChannel.java92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/uk/org/ury/show/ShowChannel.java b/src/uk/org/ury/show/ShowChannel.java
new file mode 100644
index 0000000..6aa3ee8
--- /dev/null
+++ b/src/uk/org/ury/show/ShowChannel.java
@@ -0,0 +1,92 @@
+package uk.org.ury.show;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * A channel of ShowItems in a show.
+ *
+ * @author Matt Windsor
+ */
+
+public class ShowChannel
+{
+ /* Items enqueued in channel. */
+ private List<ShowItem> items;
+
+
+ /**
+ * Construct a new, empty channel.
+ */
+
+ public
+ ShowChannel ()
+ {
+ items = new ArrayList<ShowItem> ();
+ }
+
+
+ /**
+ * Add a new item to the channel.
+ *
+ * @param index The position at which to add the item.
+ *
+ * @param item The new item to add.
+ *
+ * @throws IllegalArgumentException if the item is
+ * null, the index is negative or the index
+ * is out of bounds.
+ */
+
+ public void
+ add (int index, ShowItem item)
+ {
+ if (item == null)
+ throw new IllegalArgumentException ("Item is null.");
+
+ if (index < 0 || index >= items.size ())
+ throw new IllegalArgumentException ("Index " + index +
+ " out of bounds.");
+
+ items.add (index, item);
+ }
+
+
+ /**
+ * Add a new item to the end of the channel.
+ *
+ * @param item The new item to add.
+ */
+
+ public void
+ add (ShowItem item)
+ {
+ if (item == null)
+ throw new IllegalArgumentException ("Item is null.");
+
+ items.add (item);
+ }
+
+
+ /**
+ * Retrieve an item from the channel.
+ *
+ * @param index The index of the item to retrieve from the channel.
+ *
+ * @return the item at the given index in the list.
+ *
+ * @throws IllegalArgumentException if the index is negative
+ * or overflowing.
+ */
+
+ public ShowItem
+ get (int index)
+ {
+ if (index < 0 || index >= items.size ())
+ throw new IllegalArgumentException ("Index " + index +
+ " out of bounds.");
+
+ return items.get (index);
+ }
+}