Package io.permazen.cli.cmd
Class AbstractKVCommand
java.lang.Object
io.permazen.cli.cmd.AbstractCommand
io.permazen.cli.cmd.AbstractKVCommand
- All Implemented Interfaces:
Command
- Direct Known Subclasses:
DecodeKeyCommand
,KVGetCommand
,KVLoadCommand
,KVPutCommand
,KVRemoveCommand
,KVSaveCommand
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Parses abyte[]
array as hexadecimal or doubly-quoted "C" style string.static interface
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Pattern
Matches the doubly-quoted C strings returnd bytoCString()
.static final Pattern
Matches hexadecimal byte strings.Fields inherited from class io.permazen.cli.cmd.AbstractCommand
log, name, paramParser
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
fromCString
(String string) Parse abyte[]
array encoded as a double-quoted C-string representation bytoCString()
.protected Parser<?>
Convert parameter spec type name into aParser
.static String
toCString
(byte[] data) Convert abyte[]
array into a double-quoted C-string representation, surrounded by double quotes, with non-ASCII bytes, double-quotes, and backslashes escaped with a backslash.Methods inherited from class io.permazen.cli.cmd.AbstractCommand
execute, getAction, getHelpDetail, getHelpSummary, getName, getSessionModes, getUsage
-
Field Details
-
CSTRING_PATTERN
Matches the doubly-quoted C strings returnd bytoCString()
. -
HEXBYTES_PATTERN
Matches hexadecimal byte strings.
-
-
Constructor Details
-
AbstractKVCommand
-
-
Method Details
-
getParser
Description copied from class:AbstractCommand
Convert parameter spec type name into aParser
. Used for custom type names not supported byParamParser
.The implementation in
AbstractCommand
supports allEncoding
s registered with the database, plus:objid
for an object ID of the form64e8f29755302fe1
(returnsObjId
)
- Overrides:
getParser
in classAbstractCommand
- Parameters:
typeName
- parameter encoding ID or encoding ID alias- Returns:
- parser for parameters of the specified type
-
toCString
Convert abyte[]
array into a double-quoted C-string representation, surrounded by double quotes, with non-ASCII bytes, double-quotes, and backslashes escaped with a backslash.Supported escapes are
\\
,\"
,\b
,\f
,\t
,\n
,\r
, and\xNN
.- Parameters:
data
- byte array- Returns:
- C string representation
-
fromCString
Parse abyte[]
array encoded as a double-quoted C-string representation bytoCString()
.- Parameters:
string
- C string- Returns:
- byte array
- Throws:
IllegalArgumentException
- ifstring
is malformed
-