-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#163] Renamed streams to CommandOutStream, SequenceOutStream
- Loading branch information
Showing
39 changed files
with
235 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...ivers/jvm/java-receiver/src/main/java/net/zscript/javareceiver/core/CommandOutStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package net.zscript.javareceiver.core; | ||
|
||
import net.zscript.javareceiver.execution.ZscriptTokenField; | ||
|
||
/** | ||
* Defines the operations on the response OutStream available to a command via the CommandContext. Deliberately narrowed interface - we don't want commands confused with machinery | ||
* that can break the sequence flow. | ||
*/ | ||
public interface CommandOutStream { | ||
/** | ||
* Writes the supplied field char and its 16-bit value to this stream in Zscript conventional 0-4 digit notation (ie no leading zeros, even for zero). | ||
* | ||
* @param field the field char | ||
* @param value the 0-0xffff value to write | ||
*/ | ||
void writeField(byte field, int value); | ||
|
||
default void writeField(char field, int value) { | ||
writeField((byte) field, value); | ||
} | ||
|
||
void writeField(ZscriptTokenField field); | ||
|
||
/** | ||
* Writes the supplied string as a quoted Big Field. It is assumed to represent actual text and will be UTF-8 encoded. Forbidden chars (eg '\n', '"', '=', '\0') will be | ||
* automatically Quoted-Printable escaped, eg =0a. | ||
* | ||
* @param text the text to write | ||
*/ | ||
void writeQuotedString(String text); | ||
|
||
/** | ||
* Writes the supplied bytes as a quoted Big Field. It is assumed to already be encoded as required, and will *not* be UTF-8 encoded. However, forbidden chars (eg '\n', '"', | ||
* '=', '\0') will be automatically Quoted-Printable escaped, eg =0a. | ||
* | ||
* @param utf8text the text to write | ||
*/ | ||
void writeQuotedString(byte[] utf8text); | ||
|
||
/** | ||
* Writes the bytes provided as a hex big field, eg +68656c6c6f | ||
* | ||
* @param data the data to write | ||
*/ | ||
void writeBig(byte[] data); | ||
} |
45 changes: 1 addition & 44 deletions
45
receivers/jvm/java-receiver/src/main/java/net/zscript/javareceiver/core/OutStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,4 @@ | ||
package net.zscript.javareceiver.core; | ||
|
||
/** | ||
* Defines the sequence-level life-cycle operations that allow responses to be sent back up to a channel. | ||
*/ | ||
public interface OutStream { | ||
|
||
/** | ||
* Opens the stream. Until it is opened, other operations are undefined. Calling open() may perform tasks such as allocating buffers, establishing upstream connections etc. | ||
* Calling this when already open is safe. | ||
*/ | ||
void open(); | ||
|
||
/** | ||
* Closes the stream. This may perform operations such as transmitting the final stream content, or shutting down the comms protocol with upstream. Calling this when already | ||
* closed is safe. | ||
*/ | ||
void close(); | ||
|
||
/** | ||
* Indicates whether the stream is open. | ||
* | ||
* @return true if open, false otherwise | ||
*/ | ||
boolean isOpen(); | ||
|
||
void writeOrElse(); | ||
|
||
void writeAndThen(); | ||
|
||
void writeOpenParen(); | ||
|
||
void writeCloseParen(); | ||
|
||
void endSequence(); | ||
|
||
void writeBytes(byte[] c); | ||
|
||
/** | ||
* Accesses the command interface to allow command-response activity. | ||
* | ||
* @return a command-oriented output stream | ||
*/ | ||
default ZscriptCommandOutStream asCommandOutStream() { | ||
return (ZscriptCommandOutStream) this; | ||
}; | ||
public interface OutStream extends CommandOutStream, SequenceOutStream { | ||
} |
50 changes: 50 additions & 0 deletions
50
...vers/jvm/java-receiver/src/main/java/net/zscript/javareceiver/core/SequenceOutStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package net.zscript.javareceiver.core; | ||
|
||
/** | ||
* Defines the sequence-level life-cycle operations that allow responses to be sent back up to a channel. | ||
* <p/> | ||
* Any implementation of this interface must either also implement {@link CommandOutStream} directly, or must override {@link #asCommandOutStream()} to provide a CommandOutStream | ||
* implementation. | ||
*/ | ||
public interface SequenceOutStream { | ||
|
||
/** | ||
* Opens the stream. Until it is opened, other operations are undefined. Calling open() may perform tasks such as allocating buffers, establishing upstream connections etc. | ||
* Calling this when already open is safe. | ||
*/ | ||
void open(); | ||
|
||
/** | ||
* Closes the stream. This may perform operations such as transmitting the final stream content, or shutting down the comms protocol with upstream. Calling this when already | ||
* closed is safe. | ||
*/ | ||
void close(); | ||
|
||
/** | ||
* Indicates whether the stream is open. | ||
* | ||
* @return true if open, false otherwise | ||
*/ | ||
boolean isOpen(); | ||
|
||
void writeOrElse(); | ||
|
||
void writeAndThen(); | ||
|
||
void writeOpenParen(); | ||
|
||
void writeCloseParen(); | ||
|
||
void endSequence(); | ||
|
||
void writeBytes(byte[] c); | ||
|
||
/** | ||
* Accesses the command interface to allow command-response activity. | ||
* | ||
* @return a command-oriented output stream | ||
*/ | ||
default CommandOutStream asCommandOutStream() { | ||
return (CommandOutStream) this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
...vm/java-receiver/src/main/java/net/zscript/javareceiver/core/ZscriptCommandOutStream.java
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...vers/jvm/java-receiver/src/main/java/net/zscript/javareceiver/execution/ActionSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
package net.zscript.javareceiver.execution; | ||
|
||
import net.zscript.javareceiver.core.OutStream; | ||
import net.zscript.javareceiver.core.SequenceOutStream; | ||
import net.zscript.javareceiver.core.Zscript; | ||
|
||
public interface ActionSource { | ||
ZscriptAction getAction(); | ||
|
||
OutStream getOutStream(Zscript zscript); | ||
SequenceOutStream getOutStream(Zscript zscript); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.