Rename dummy filter to basic filter.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 4 Jun 2013 04:44:00 +0000 (06:44 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 4 Jun 2013 04:44:00 +0000 (06:44 +0200)
src/main/java/net/pterodactylus/sonitus/data/filter/AudioProcessingFilter.java
src/main/java/net/pterodactylus/sonitus/data/filter/BasicFilter.java [new file with mode: 0644]
src/main/java/net/pterodactylus/sonitus/data/filter/DummyFilter.java [deleted file]
src/main/java/net/pterodactylus/sonitus/data/filter/ExternalFilter.java
src/main/java/net/pterodactylus/sonitus/data/filter/PredicateFilter.java
src/main/java/net/pterodactylus/sonitus/data/filter/RateLimitingFilter.java
src/main/java/net/pterodactylus/sonitus/data/filter/TimeCounterFilter.java

index e87935b..7312f7f 100644 (file)
@@ -28,7 +28,7 @@ import net.pterodactylus.sonitus.io.ProcessingOutputStream;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public abstract class AudioProcessingFilter extends DummyFilter {
+public abstract class AudioProcessingFilter extends BasicFilter {
 
        /**
         * Creates a new audio processing filter with the given name.
@@ -41,7 +41,7 @@ public abstract class AudioProcessingFilter extends DummyFilter {
        }
 
        //
-       // DUMMYFILTER METHODS
+       // BASICFILTER METHODS
        //
 
        @Override
diff --git a/src/main/java/net/pterodactylus/sonitus/data/filter/BasicFilter.java b/src/main/java/net/pterodactylus/sonitus/data/filter/BasicFilter.java
new file mode 100644 (file)
index 0000000..0f248d6
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * Sonitus - AbstractFilter.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sonitus.data.filter;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import net.pterodactylus.sonitus.data.AbstractControlledComponent;
+import net.pterodactylus.sonitus.data.Controller;
+import net.pterodactylus.sonitus.data.Filter;
+import net.pterodactylus.sonitus.data.Metadata;
+
+import com.google.common.io.Closeables;
+
+/**
+ * Basic {@link Filter} implementation that pipes its input to its output.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class BasicFilter extends AbstractControlledComponent implements Filter {
+
+       /** The input stream from which to read. */
+       private InputStream inputStream;
+
+       /** The output stream to which to write. */
+       private OutputStream outputStream;
+
+       /**
+        * Creates a new dummy filter with the given name.
+        *
+        * @param name
+        *              The name of the filter
+        */
+       public BasicFilter(String name) {
+               super(name);
+       }
+
+       //
+       // CONTROLLED METHODS
+       //
+
+       @Override
+       public List<Controller<?>> controllers() {
+               return Collections.emptyList();
+       }
+
+       //
+       // FILTER METHODS
+       //
+
+       @Override
+       public void open(Metadata metadata) throws IOException {
+               metadataUpdated(metadata);
+               inputStream = createInputStream();
+               outputStream = createOutputStream();
+       }
+
+       @Override
+       public void close() {
+               try {
+                       Closeables.close(outputStream, true);
+                       Closeables.close(inputStream, true);
+               } catch (IOException e) {
+                       /* won’t throw. */
+               }
+       }
+
+       @Override
+       public void process(byte[] buffer) throws IOException {
+               outputStream.write(buffer);
+               outputStream.flush();
+       }
+
+       @Override
+       public byte[] get(int bufferSize) throws IOException {
+               byte[] buffer = new byte[bufferSize];
+               int read = inputStream.read(buffer);
+               if (read == -1) {
+                       throw new EOFException();
+               }
+               return Arrays.copyOf(buffer, read);
+       }
+
+       //
+       // SUBCLASS METHODS
+       //
+
+       /**
+        * Creates the input stream from which {@link net.pterodactylus.sonitus.data.Pipeline}
+        * will read the audio data. If you override this, you have to override {@link
+        * #createOutputStream()}, too!
+        *
+        * @return The input stream to read from
+        * @throws IOException
+        *              if an I/O error occurs
+        */
+       protected InputStream createInputStream() throws IOException {
+               return new PipedInputStream();
+       }
+
+       /**
+        * Creates the output stream to which {@link net.pterodactylus.sonitus.data.Pipeline}
+        * will write the audio data. If you override this, you have to override {@link
+        * #createInputStream()}, too!
+        *
+        * @return The output stream to write to
+        * @throws IOException
+        *              if an I/O error occurs
+        */
+       protected OutputStream createOutputStream() throws IOException {
+               return new PipedOutputStream((PipedInputStream) inputStream);
+       }
+
+}
diff --git a/src/main/java/net/pterodactylus/sonitus/data/filter/DummyFilter.java b/src/main/java/net/pterodactylus/sonitus/data/filter/DummyFilter.java
deleted file mode 100644 (file)
index ae6899d..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Sonitus - AbstractFilter.java - Copyright © 2013 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sonitus.data.filter;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import net.pterodactylus.sonitus.data.AbstractControlledComponent;
-import net.pterodactylus.sonitus.data.Controller;
-import net.pterodactylus.sonitus.data.Filter;
-import net.pterodactylus.sonitus.data.Metadata;
-
-import com.google.common.io.Closeables;
-
-/**
- * Dummy {@link Filter} implementation that pipes its input to its output.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class DummyFilter extends AbstractControlledComponent implements Filter {
-
-       /** The input stream from which to read. */
-       private InputStream inputStream;
-
-       /** The output stream to which to write. */
-       private OutputStream outputStream;
-
-       /**
-        * Creates a new dummy filter with the given name.
-        *
-        * @param name
-        *              The name of the filter
-        */
-       public DummyFilter(String name) {
-               super(name);
-       }
-
-       //
-       // CONTROLLED METHODS
-       //
-
-       @Override
-       public List<Controller<?>> controllers() {
-               return Collections.emptyList();
-       }
-
-       //
-       // FILTER METHODS
-       //
-
-       @Override
-       public void open(Metadata metadata) throws IOException {
-               metadataUpdated(metadata);
-               inputStream = createInputStream();
-               outputStream = createOutputStream();
-       }
-
-       @Override
-       public void close() {
-               try {
-                       Closeables.close(outputStream, true);
-                       Closeables.close(inputStream, true);
-               } catch (IOException e) {
-                       /* won’t throw. */
-               }
-       }
-
-       @Override
-       public void process(byte[] buffer) throws IOException {
-               outputStream.write(buffer);
-               outputStream.flush();
-       }
-
-       @Override
-       public byte[] get(int bufferSize) throws IOException {
-               byte[] buffer = new byte[bufferSize];
-               int read = inputStream.read(buffer);
-               if (read == -1) {
-                       throw new EOFException();
-               }
-               return Arrays.copyOf(buffer, read);
-       }
-
-       //
-       // SUBCLASS METHODS
-       //
-
-       /**
-        * Creates the input stream from which {@link net.pterodactylus.sonitus.data.Pipeline}
-        * will read the audio data. If you override this, you have to override {@link
-        * #createOutputStream()}, too!
-        *
-        * @return The input stream to read from
-        * @throws IOException
-        *              if an I/O error occurs
-        */
-       protected InputStream createInputStream() throws IOException {
-               return new PipedInputStream();
-       }
-
-       /**
-        * Creates the output stream to which {@link net.pterodactylus.sonitus.data.Pipeline}
-        * will write the audio data. If you override this, you have to override {@link
-        * #createInputStream()}, too!
-        *
-        * @return The output stream to write to
-        * @throws IOException
-        *              if an I/O error occurs
-        */
-       protected OutputStream createOutputStream() throws IOException {
-               return new PipedOutputStream((PipedInputStream) inputStream);
-       }
-
-}
index 990f976..73338b5 100644 (file)
@@ -34,7 +34,7 @@ import com.google.common.collect.Iterables;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public abstract class ExternalFilter extends DummyFilter {
+public abstract class ExternalFilter extends BasicFilter {
 
        /** The logger. */
        private final Logger logger = Logger.getLogger(getClass().getName());
@@ -70,7 +70,7 @@ public abstract class ExternalFilter extends DummyFilter {
        }
 
        //
-       // DUMMYFILTER METHODS
+       // BASICFILTER METHODS
        //
 
        @Override
index b400dc7..8968596 100644 (file)
@@ -33,7 +33,7 @@ import com.google.common.base.Predicate;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public class PredicateFilter extends DummyFilter {
+public class PredicateFilter extends BasicFilter {
 
        /** The predicate. */
        private final Predicate<Metadata> metadataPredicate;
index b2890ca..881deeb 100644 (file)
@@ -29,7 +29,7 @@ import net.pterodactylus.sonitus.data.Metadata;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public class RateLimitingFilter extends DummyFilter {
+public class RateLimitingFilter extends BasicFilter {
 
        /** The logger. */
        private static final Logger logger = Logger.getLogger(RateLimitingFilter.class.getName());
index 1c53d55..cfa93af 100644 (file)
@@ -31,7 +31,7 @@ import net.pterodactylus.sonitus.data.Metadata;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public class TimeCounterFilter extends DummyFilter {
+public class TimeCounterFilter extends BasicFilter {
 
        /** The byte counter. */
        private final AtomicLong counter = new AtomicLong();
@@ -95,7 +95,7 @@ public class TimeCounterFilter extends DummyFilter {
        }
 
        //
-       // DUMMYFILTER METHODS
+       // BASICFILTER METHODS
        //
 
        @Override