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

public abstract class AbstractKVCommand extends AbstractCommand
  • Field Details

    • CSTRING_PATTERN

      public static final Pattern CSTRING_PATTERN
      Matches the doubly-quoted C strings returnd by toCString().
    • HEXBYTES_PATTERN

      public static final Pattern HEXBYTES_PATTERN
      Matches hexadecimal byte strings.
  • Constructor Details

    • AbstractKVCommand

      protected AbstractKVCommand(String spec)
  • Method Details

    • getParser

      protected Parser<?> getParser(String typeName)
      Description copied from class: AbstractCommand
      Convert parameter spec type name into a Parser. Used for custom type names not supported by ParamParser.

      The implementation in AbstractCommand supports all Encodings registered with the database, plus:

      • type for an object type name (returns Integer)
      • objid for an object ID of the form 64e8f29755302fe1 (returns ObjId)
      Overrides:
      getParser in class AbstractCommand
      Parameters:
      typeName - parameter encoding ID or encoding ID alias
      Returns:
      parser for parameters of the specified type
    • toCString

      public static String toCString(byte[] data)
      Convert a byte[] 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

      public static byte[] fromCString(String string)
      Parse a byte[] array encoded as a double-quoted C-string representation by toCString().
      Parameters:
      string - C string
      Returns:
      byte array
      Throws:
      IllegalArgumentException - if string is malformed