Class Strings

java.lang.Object
convex.core.data.Strings

public class Strings extends Object
  • Field Details

    • EMPTY

      public static final StringShort EMPTY
    • NIL

      public static final StringShort NIL
    • TRUE

      public static final StringShort TRUE
    • FALSE

      public static final StringShort FALSE
    • BAD_SIGNATURE

      public static final StringShort BAD_SIGNATURE
    • BAD_FORMAT

      public static final StringShort BAD_FORMAT
    • COLON

      public static final StringShort COLON
    • HEX_PREFIX

      public static final StringShort HEX_PREFIX
    • MAX_ENCODING_LENGTH

      public static final int MAX_ENCODING_LENGTH
    • EXCESS_BYTE

      public static final byte EXCESS_BYTE
      Byte value used for looking outside a String 0xff (-1) is invalid UTF-8
      See Also:
      Constant Field Values
  • Constructor Details

    • Strings

      public Strings()
  • Method Details

    • read

      public static AString read(ByteBuffer bb) throws BadFormatException
      Reads a CVM String value from a bytebuffer. Assumes tag already read.
      Parameters:
      bb - ByteBuffer to read from
      Returns:
      String instance
      Throws:
      BadFormatException - If format has problems
    • create

      public static AString create(String s)
      Create a canonical CVM String from a regular Java String
      Parameters:
      s - Java String to convert.
      Returns:
      CVM String instance.
    • join

      public static AString join(ASequence<AString> ss, AString separator)
      Creates a string by joining a sequence of substrings with the given separator
      Parameters:
      ss - Sequence of Strings to join
      separator - any String to use as a separator.
      Returns:
      Concatenated String, including the separator. Will return the empty string if the seqence is empty.
    • join

      public static AString join(ASequence<AString> ss, CVMChar separator)
      Creates a String by joining a sequence of substrings with the given separator
      Parameters:
      ss - Sequence of Strings to join
      separator - any CVM Character to use as a separator.
      Returns:
      Concatenated String, including the separator. Will return the empty string if the sequence is empty.
    • create

      public static AString create(ABlob b)
    • fromHex

      public static AString fromHex(String hexString)
      Constructs a UTF-8 CVM String from raw hex digits. This does not perform checking of valid UTF: It is possible to construct bad strings this way. This is allowable on the CVM, and useful for testing.
      Parameters:
      hexString - String containing hex digits
      Returns:
      New CVM String (possibly not valid UTF)
    • empty

      public static StringShort empty()
    • getDecoder

      public static CharsetDecoder getDecoder()
    • appendAll

      public static AString appendAll(AString[] strs)