summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-10-23 14:18:58 (EDT)
committerEike Stepper2006-10-23 14:18:58 (EDT)
commit13984aa28c8f87088022a0557cc858a10c433a0a (patch)
treee11f16355dd42377970dc745caa9d4376c5734f6
parenta95acf5fcc86191fe51a7e0c8e899bd4614462df (diff)
downloadcdo-13984aa28c8f87088022a0557cc858a10c433a0a.zip
cdo-13984aa28c8f87088022a0557cc858a10c433a0a.tar.gz
cdo-13984aa28c8f87088022a0557cc858a10c433a0a.tar.bz2
Signal protocol
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Indication1.java8
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Indication2.java12
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Request1.java8
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Request2.java12
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java18
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java18
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java46
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/StrictSignalActor.java53
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/StrictSignalReactor.java50
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInput.java (renamed from plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/EncodingTest.java)15
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java34
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutput.java22
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java32
15 files changed, 137 insertions, 211 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Indication1.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Indication1.java
index ffded24..1027717 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Indication1.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Indication1.java
@@ -11,9 +11,9 @@
package org.eclipse.net4j.tests.signal;
import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
+import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
/**
@@ -30,13 +30,13 @@ public class Indication1 extends IndicationWithResponse
}
@Override
- protected void indicating(DataInputStream in) throws IOException
+ protected void indicating(ExtendedDataInputStream in) throws IOException
{
data = in.readInt();
}
@Override
- protected void responding(DataOutputStream out) throws IOException
+ protected void responding(ExtendedDataOutputStream out) throws IOException
{
out.writeInt(data);
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Indication2.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Indication2.java
index 6468b1b..86be8c7 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Indication2.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Indication2.java
@@ -11,9 +11,9 @@
package org.eclipse.net4j.tests.signal;
import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
+import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
/**
@@ -30,14 +30,14 @@ public class Indication2 extends IndicationWithResponse
}
@Override
- protected void indicating(DataInputStream in) throws IOException
+ protected void indicating(ExtendedDataInputStream in) throws IOException
{
- data = readByteArray();
+ data = in.readByteArray();
}
@Override
- protected void responding(DataOutputStream out) throws IOException
+ protected void responding(ExtendedDataOutputStream out) throws IOException
{
- writeByteArray(data);
+ out.writeByteArray(data);
}
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Request1.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Request1.java
index 6aaf642..53b97bc 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Request1.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Request1.java
@@ -12,9 +12,9 @@ package org.eclipse.net4j.tests.signal;
import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.transport.Channel;
+import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
+import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
/**
@@ -37,13 +37,13 @@ public class Request1 extends RequestWithConfirmation<Integer>
}
@Override
- protected void requesting(DataOutputStream out) throws IOException
+ protected void requesting(ExtendedDataOutputStream out) throws IOException
{
out.writeInt(data);
}
@Override
- protected Integer confirming(DataInputStream in) throws IOException
+ protected Integer confirming(ExtendedDataInputStream in) throws IOException
{
return in.readInt();
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Request2.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Request2.java
index 63b568a..2618e1a 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Request2.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/Request2.java
@@ -12,9 +12,9 @@ package org.eclipse.net4j.tests.signal;
import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.transport.Channel;
+import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
+import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
/**
@@ -37,14 +37,14 @@ public class Request2 extends RequestWithConfirmation<byte[]>
}
@Override
- protected void requesting(DataOutputStream out) throws IOException
+ protected void requesting(ExtendedDataOutputStream out) throws IOException
{
- writeByteArray(data);
+ out.writeByteArray(data);
}
@Override
- protected byte[] confirming(DataInputStream in) throws IOException
+ protected byte[] confirming(ExtendedDataInputStream in) throws IOException
{
- return readByteArray();
+ return in.readByteArray();
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java
index fb7931f..4eb729a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Indication.java
@@ -12,14 +12,14 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.util.stream.BufferInputStream;
import org.eclipse.net4j.util.stream.BufferOutputStream;
+import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
-import java.io.DataInputStream;
import java.io.IOException;
/**
* @author Eike Stepper
*/
-public abstract class Indication extends StrictSignalReactor
+public abstract class Indication extends SignalReactor
{
protected Indication()
{
@@ -29,10 +29,8 @@ public abstract class Indication extends StrictSignalReactor
protected final void execute(BufferInputStream in, BufferOutputStream out) throws Exception
{
System.out.println("================ Indicating " + this);
- inputAllowed = true;
- indicating(getDataInputStream());
- inputAllowed = false;
+ indicating(new ExtendedDataInputStream(in));
}
- protected abstract void indicating(DataInputStream in) throws IOException;
+ protected abstract void indicating(ExtendedDataInputStream in) throws IOException;
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
index 5c1da7e..2ba29d2 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
@@ -12,15 +12,15 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.util.stream.BufferInputStream;
import org.eclipse.net4j.util.stream.BufferOutputStream;
+import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
+import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
/**
* @author Eike Stepper
*/
-public abstract class IndicationWithResponse extends StrictSignalReactor
+public abstract class IndicationWithResponse extends SignalReactor
{
protected IndicationWithResponse()
{
@@ -30,18 +30,14 @@ public abstract class IndicationWithResponse extends StrictSignalReactor
protected final void execute(BufferInputStream in, BufferOutputStream out) throws Exception
{
System.out.println("================ Indicating " + this);
- inputAllowed = true;
- indicating(getDataInputStream());
- inputAllowed = false;
+ indicating(new ExtendedDataInputStream(in));
System.out.println("================ Responding " + this);
- outputAllowed = true;
- responding(getDataOutputStream());
- outputAllowed = false;
+ responding(new ExtendedDataOutputStream(out));
out.flush();
}
- protected abstract void indicating(DataInputStream in) throws IOException;
+ protected abstract void indicating(ExtendedDataInputStream in) throws IOException;
- protected abstract void responding(DataOutputStream out) throws IOException;
+ protected abstract void responding(ExtendedDataOutputStream out) throws IOException;
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
index 6e0dc19..e56affa 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
@@ -13,14 +13,14 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.transport.Channel;
import org.eclipse.net4j.util.stream.BufferInputStream;
import org.eclipse.net4j.util.stream.BufferOutputStream;
+import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
/**
* @author Eike Stepper
*/
-public abstract class Request<RESULT> extends StrictSignalActor<RESULT>
+public abstract class Request<RESULT> extends SignalActor<RESULT>
{
protected Request(Channel channel)
{
@@ -31,11 +31,9 @@ public abstract class Request<RESULT> extends StrictSignalActor<RESULT>
protected final void execute(BufferInputStream in, BufferOutputStream out) throws Exception
{
System.out.println("================ Requesting " + this);
- outputAllowed = true;
- requesting(getDataOutputStream());
- outputAllowed = false;
+ requesting(new ExtendedDataOutputStream(out));
out.flush();
}
- protected abstract void requesting(DataOutputStream out) throws IOException;
+ protected abstract void requesting(ExtendedDataOutputStream out) throws IOException;
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
index 281bb36..cbc9a6a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
@@ -13,15 +13,15 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.transport.Channel;
import org.eclipse.net4j.util.stream.BufferInputStream;
import org.eclipse.net4j.util.stream.BufferOutputStream;
+import org.eclipse.net4j.util.stream.ExtendedDataInputStream;
+import org.eclipse.net4j.util.stream.ExtendedDataOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
/**
* @author Eike Stepper
*/
-public abstract class RequestWithConfirmation<RESULT> extends StrictSignalActor<RESULT>
+public abstract class RequestWithConfirmation<RESULT> extends SignalActor<RESULT>
{
protected RequestWithConfirmation(Channel channel)
{
@@ -32,18 +32,14 @@ public abstract class RequestWithConfirmation<RESULT> extends StrictSignalActor<
protected final void execute(BufferInputStream in, BufferOutputStream out) throws Exception
{
System.out.println("================ Requesting " + this);
- outputAllowed = true;
- requesting(getDataOutputStream());
- outputAllowed = false;
+ requesting(new ExtendedDataOutputStream(out));
out.flush();
System.out.println("================ Confirming " + this);
- inputAllowed = true;
- setResult(confirming(getDataInputStream()));
- inputAllowed = false;
+ setResult(confirming(new ExtendedDataInputStream(in)));
}
- protected abstract void requesting(DataOutputStream out) throws IOException;
+ protected abstract void requesting(ExtendedDataOutputStream out) throws IOException;
- protected abstract RESULT confirming(DataInputStream in) throws IOException;
+ protected abstract RESULT confirming(ExtendedDataInputStream in) throws IOException;
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java
index 7bc4305..35f181b 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java
@@ -13,10 +13,6 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.util.stream.BufferInputStream;
import org.eclipse.net4j.util.stream.BufferOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
/**
* @author Eike Stepper
*/
@@ -30,10 +26,6 @@ public abstract class Signal implements Runnable
private BufferOutputStream outputStream;
- private DataInputStream dataInputStream;
-
- private DataOutputStream dataOutputStream;
-
protected Signal()
{
}
@@ -58,40 +50,6 @@ public abstract class Signal implements Runnable
return outputStream;
}
- protected DataInputStream getDataInputStream()
- {
- if (dataInputStream == null)
- {
- dataInputStream = new DataInputStream(inputStream);
- }
-
- return dataInputStream;
- }
-
- protected DataOutputStream getDataOutputStream()
- {
- if (dataOutputStream == null)
- {
- dataOutputStream = new DataOutputStream(outputStream);
- }
-
- return dataOutputStream;
- }
-
- protected void writeByteArray(byte[] bytes) throws IOException
- {
- getDataOutputStream().writeInt(bytes.length);
- getDataOutputStream().write(bytes);
- }
-
- protected byte[] readByteArray() throws IOException
- {
- int length = getDataInputStream().readInt();
- byte[] bytes = new byte[length];
- getDataInputStream().read(bytes);
- return bytes;
- }
-
public final void run()
{
try
@@ -108,10 +66,10 @@ public abstract class Signal implements Runnable
}
}
- protected abstract void execute(BufferInputStream in, BufferOutputStream out) throws Exception;
-
protected abstract short getSignalID();
+ protected abstract void execute(BufferInputStream in, BufferOutputStream out) throws Exception;
+
void setProtocol(SignalProtocol protocol)
{
this.protocol = protocol;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/StrictSignalActor.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/StrictSignalActor.java
deleted file mode 100644
index 1e764f1..0000000
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/StrictSignalActor.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.net4j.signal;
-
-import org.eclipse.net4j.transport.Channel;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-abstract class StrictSignalActor<RESULT> extends SignalActor<RESULT>
-{
- boolean inputAllowed;
-
- boolean outputAllowed;
-
- protected StrictSignalActor(Channel channel)
- {
- super(channel);
- }
-
- @Override
- protected final DataInputStream getDataInputStream()
- {
- if (!inputAllowed)
- {
- throw new IllegalStateException("Input not allowed");
- }
-
- return super.getDataInputStream();
- }
-
- @Override
- protected final DataOutputStream getDataOutputStream()
- {
- if (!outputAllowed)
- {
- throw new IllegalStateException("Output not allowed");
- }
-
- return super.getDataOutputStream();
- }
-}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/StrictSignalReactor.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/StrictSignalReactor.java
deleted file mode 100644
index 04d5b9e..0000000
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/StrictSignalReactor.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.net4j.signal;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-abstract class StrictSignalReactor extends SignalReactor
-{
- boolean inputAllowed;
-
- boolean outputAllowed;
-
- protected StrictSignalReactor()
- {
- }
-
- @Override
- protected final DataInputStream getDataInputStream()
- {
- if (!inputAllowed)
- {
- throw new IllegalStateException("Input not allowed");
- }
-
- return super.getDataInputStream();
- }
-
- @Override
- protected final DataOutputStream getDataOutputStream()
- {
- if (!outputAllowed)
- {
- throw new IllegalStateException("Output not allowed");
- }
-
- return super.getDataOutputStream();
- }
-}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/EncodingTest.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInput.java
index 298bbc1..6039d8c 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/EncodingTest.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInput.java
@@ -8,20 +8,15 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.tests;
+package org.eclipse.net4j.util.stream;
-import org.eclipse.net4j.util.HexUtil;
+import java.io.DataInput;
+import java.io.IOException;
/**
* @author Eike Stepper
*/
-public class EncodingTest
+public interface ExtendedDataInput extends DataInput
{
- public static void main(String[] args)
- {
- System.out.println(HexUtil.toHex(0));
- System.out.println(HexUtil.toHex(127));
- System.out.println(HexUtil.toHex(128));
- System.out.println(HexUtil.toHex(255));
- }
+ public byte[] readByteArray() throws IOException;
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
new file mode 100644
index 0000000..cf5870c
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
@@ -0,0 +1,34 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.util.stream;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class ExtendedDataInputStream extends DataInputStream implements ExtendedDataInput
+{
+ public ExtendedDataInputStream(InputStream in)
+ {
+ super(in);
+ }
+
+ public byte[] readByteArray() throws IOException
+ {
+ int length = readInt();
+ byte[] b = new byte[length];
+ read(b);
+ return b;
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutput.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutput.java
new file mode 100644
index 0000000..b572849
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutput.java
@@ -0,0 +1,22 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.util.stream;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ExtendedDataOutput extends DataOutput
+{
+ public void writeByteArray(byte[] b) throws IOException;
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java
new file mode 100644
index 0000000..ea6e276
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java
@@ -0,0 +1,32 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.util.stream;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class ExtendedDataOutputStream extends DataOutputStream implements ExtendedDataOutput
+{
+ public ExtendedDataOutputStream(OutputStream out)
+ {
+ super(out);
+ }
+
+ public void writeByteArray(byte[] b) throws IOException
+ {
+ writeInt(b.length);
+ write(b);
+ }
+}