-
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.
- Loading branch information
Showing
15 changed files
with
216 additions
and
92 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
45 changes: 45 additions & 0 deletions
45
...client-lib/client-core/src/main/java/net/zscript/javaclient/commandPaths/NumberField.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,45 @@ | ||
package net.zscript.javaclient.commandPaths; | ||
|
||
import net.zscript.tokenizer.BlockIterator; | ||
import net.zscript.tokenizer.ZscriptField; | ||
import net.zscript.util.ByteString; | ||
import net.zscript.util.ByteString.ByteStringBuilder; | ||
|
||
public class NumberField implements ZscriptField, ByteString.ByteAppendable { | ||
private byte key; | ||
private int value; | ||
|
||
public NumberField(byte key, int value) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public byte getKey() { | ||
return key; | ||
} | ||
|
||
@Override | ||
public int getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public boolean isBigField() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public BlockIterator iterator() { | ||
return BlockIterator.EMPTY; | ||
} | ||
|
||
@Override | ||
public void appendTo(ByteStringBuilder builder) { | ||
append(key, value, builder); | ||
} | ||
|
||
public static void append(byte key, int value, ByteStringBuilder builder) { | ||
builder.appendByte(key).appendNumeric16(value); | ||
} | ||
} |
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
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.