4 files + 85 − 19 Side-by-side Compare changes Side-by-side Inline Show whitespace changes Files 4 lib/java/Makefile +1 −0 Original line number Original line Diff line number Diff line MODULES=Constant \ MODULES=Constant \ Decoder \ Decoder \ DecoderChannel \ DecoderChannel \ DynamicDecoderChannel \ DecoderRegistry \ DecoderRegistry \ Encoder \ Encoder \ EncoderChannel \ EncoderChannel \ Loading lib/java/se/lth/control/labcomm/DecoderChannel.java +36 −19 Original line number Original line Diff line number Diff line Loading @@ -8,9 +8,9 @@ import java.io.EOFException; public class DecoderChannel implements Decoder { public class DecoderChannel implements Decoder { private DataInputStream in; protected DataInputStream in; private DecoderRegistry def_registry = new DecoderRegistry(); protected DecoderRegistry def_registry = new DecoderRegistry(); private DecoderRegistry ref_registry = new DecoderRegistry(); protected DecoderRegistry ref_registry = new DecoderRegistry(); public DecoderChannel(InputStream in) throws IOException { public DecoderChannel(InputStream in) throws IOException { this.in = new DataInputStream(in); this.in = new DataInputStream(in); Loading Loading @@ -55,9 +55,38 @@ public class DecoderChannel implements Decoder { } } } } protected void processSample(int tag) throws Exception { DecoderRegistry.Entry e = def_registry.get(tag); if (e == null) { throw new IOException("Unhandled tag " + tag); } SampleDispatcher d = e.getDispatcher(); if (d == null) { throw new IOException("No dispatcher for '" + e.getName() + "'"); } SampleHandler h = e.getHandler(); if (h == null) { throw new IOException("No handler for '" + e.getName() +"'"); } d.decodeAndHandle(this, h); } public void runOne() throws Exception { public void runOne() throws Exception { boolean done = false; runOne(true); while (!done) { } /** * Run the decoder. * * @param waitForSample Wether to wait until an actual sample has * been decoded or to return after any complete entity has * been decoded. Set to <code>true</code> to get the old * behaviour. */ public void runOne(boolean waitForSample) throws Exception { boolean done = !waitForSample; do { int tag = decodePacked32(); int tag = decodePacked32(); int length = decodePacked32(); int length = decodePacked32(); switch (tag) { switch (tag) { Loading @@ -84,23 +113,11 @@ public class DecoderChannel implements Decoder { processPragma(length); processPragma(length); } break; } break; default: { default: { DecoderRegistry.Entry e = def_registry.get(tag); processSample(tag); if (e == null) { throw new IOException("Unhandled tag " + tag); } SampleDispatcher d = e.getDispatcher(); if (d == null) { throw new IOException("No dispatcher for '" + e.getName() + "'"); } SampleHandler h = e.getHandler(); if (h == null) { throw new IOException("No handler for '" + e.getName() +"'"); } d.decodeAndHandle(this, h); done = true; done = true; } } } } } } while (!done); } } public void run() throws Exception { public void run() throws Exception { Loading lib/java/se/lth/control/labcomm/DynamicDecoderChannel.java 0 → 100644 +36 −0 Original line number Original line Diff line number Diff line package se.lth.control.labcomm; import java.io.IOException; import java.io.InputStream; public class DynamicDecoderChannel extends DecoderChannel { public DynamicDecoderChannel(InputStream in) throws IOException { super(in); } public void runOne() throws Exception { runOne(false); } protected void processSample(int tag) throws Exception { DecoderRegistry.Entry e = def_registry.get(tag); if (e == null) throw new IOException("Have not read any registration for " + tag); SampleDispatcher d = e.getDispatcher(); if (d != null) { SampleHandler h = e.getHandler(); if (h == null) throw new IOException("No handler for '" + e.getName() +"'"); d.decodeAndHandle(this, h); } else { dynamicDecode(); } } private void dynamicDecode() { throw new UnsupportedOperationException("Dynamic decoding not implemented yet."); } } lib/java/se/lth/control/labcomm2006/DynamicDecoderChannel.java 0 → 100644 +12 −0 Original line number Original line Diff line number Diff line package se.lth.control.labcomm2006; import java.io.IOException; import java.io.InputStream; public class DynamicDecoderChannel extends DecoderChannel { public DynamicDecoderChannel(InputStream in) throws IOException { super(in); throw new UnsupportedOperationException("Use 2014."); } }
lib/java/Makefile +1 −0 Original line number Original line Diff line number Diff line MODULES=Constant \ MODULES=Constant \ Decoder \ Decoder \ DecoderChannel \ DecoderChannel \ DynamicDecoderChannel \ DecoderRegistry \ DecoderRegistry \ Encoder \ Encoder \ EncoderChannel \ EncoderChannel \ Loading
lib/java/se/lth/control/labcomm/DecoderChannel.java +36 −19 Original line number Original line Diff line number Diff line Loading @@ -8,9 +8,9 @@ import java.io.EOFException; public class DecoderChannel implements Decoder { public class DecoderChannel implements Decoder { private DataInputStream in; protected DataInputStream in; private DecoderRegistry def_registry = new DecoderRegistry(); protected DecoderRegistry def_registry = new DecoderRegistry(); private DecoderRegistry ref_registry = new DecoderRegistry(); protected DecoderRegistry ref_registry = new DecoderRegistry(); public DecoderChannel(InputStream in) throws IOException { public DecoderChannel(InputStream in) throws IOException { this.in = new DataInputStream(in); this.in = new DataInputStream(in); Loading Loading @@ -55,9 +55,38 @@ public class DecoderChannel implements Decoder { } } } } protected void processSample(int tag) throws Exception { DecoderRegistry.Entry e = def_registry.get(tag); if (e == null) { throw new IOException("Unhandled tag " + tag); } SampleDispatcher d = e.getDispatcher(); if (d == null) { throw new IOException("No dispatcher for '" + e.getName() + "'"); } SampleHandler h = e.getHandler(); if (h == null) { throw new IOException("No handler for '" + e.getName() +"'"); } d.decodeAndHandle(this, h); } public void runOne() throws Exception { public void runOne() throws Exception { boolean done = false; runOne(true); while (!done) { } /** * Run the decoder. * * @param waitForSample Wether to wait until an actual sample has * been decoded or to return after any complete entity has * been decoded. Set to <code>true</code> to get the old * behaviour. */ public void runOne(boolean waitForSample) throws Exception { boolean done = !waitForSample; do { int tag = decodePacked32(); int tag = decodePacked32(); int length = decodePacked32(); int length = decodePacked32(); switch (tag) { switch (tag) { Loading @@ -84,23 +113,11 @@ public class DecoderChannel implements Decoder { processPragma(length); processPragma(length); } break; } break; default: { default: { DecoderRegistry.Entry e = def_registry.get(tag); processSample(tag); if (e == null) { throw new IOException("Unhandled tag " + tag); } SampleDispatcher d = e.getDispatcher(); if (d == null) { throw new IOException("No dispatcher for '" + e.getName() + "'"); } SampleHandler h = e.getHandler(); if (h == null) { throw new IOException("No handler for '" + e.getName() +"'"); } d.decodeAndHandle(this, h); done = true; done = true; } } } } } } while (!done); } } public void run() throws Exception { public void run() throws Exception { Loading
lib/java/se/lth/control/labcomm/DynamicDecoderChannel.java 0 → 100644 +36 −0 Original line number Original line Diff line number Diff line package se.lth.control.labcomm; import java.io.IOException; import java.io.InputStream; public class DynamicDecoderChannel extends DecoderChannel { public DynamicDecoderChannel(InputStream in) throws IOException { super(in); } public void runOne() throws Exception { runOne(false); } protected void processSample(int tag) throws Exception { DecoderRegistry.Entry e = def_registry.get(tag); if (e == null) throw new IOException("Have not read any registration for " + tag); SampleDispatcher d = e.getDispatcher(); if (d != null) { SampleHandler h = e.getHandler(); if (h == null) throw new IOException("No handler for '" + e.getName() +"'"); d.decodeAndHandle(this, h); } else { dynamicDecode(); } } private void dynamicDecode() { throw new UnsupportedOperationException("Dynamic decoding not implemented yet."); } }
lib/java/se/lth/control/labcomm2006/DynamicDecoderChannel.java 0 → 100644 +12 −0 Original line number Original line Diff line number Diff line package se.lth.control.labcomm2006; import java.io.IOException; import java.io.InputStream; public class DynamicDecoderChannel extends DecoderChannel { public DynamicDecoderChannel(InputStream in) throws IOException { super(in); throw new UnsupportedOperationException("Use 2014."); } }