public static ByteString concat(String prefix, String suffix) { final int prefixLength = prefix.length(); final int suffixLength = suffix.length(); final byte[] newBytes = new byte[prefixLength + suffixLength]; getStringBytes(false, newBytes, 0, prefix, 0, prefixLength); getStringBytes(false, newBytes, prefixLength, suffix, 0, suffixLength); return new ByteString(newBytes); }
public ByteString concat(String suffix, int offs, int len) { if (len <= 0) { return this; } final byte[] bytes = this.bytes; final int length = this.len; byte[] newBytes = Arrays.copyOfRange(bytes, offs, offs + length + len); getStringBytes(false, newBytes, length, suffix, offs, len); return new ByteString(newBytes); }
/** * Get a byte string from the bytes of the character string. The string must be a Latin-1 string. * * @param str the character string * @return the byte string */ public static ByteString getBytes(String str) { final int length = str.length(); return new ByteString(getStringBytes(false, new byte[length], 0, str, 0, length), 0, length); }
public static ByteString concat(String prefix, ByteString suffix) { final int prefixLength = prefix.length(); final byte[] suffixBytes = suffix.bytes; final int suffixLength = suffixBytes.length; final byte[] newBytes = new byte[prefixLength + suffixLength]; getStringBytes(false, newBytes, 0, prefix, 0, prefixLength); System.arraycopy(suffixBytes, suffix.offs, newBytes, prefixLength, suffixLength); return new ByteString(newBytes); }
public static ByteString concat(String prefix, String suffix) { final int prefixLength = prefix.length(); final int suffixLength = suffix.length(); final byte[] newBytes = new byte[prefixLength + suffixLength]; getStringBytes(false, newBytes, 0, prefix, 0, prefixLength); getStringBytes(false, newBytes, prefixLength, suffix, 0, suffixLength); return new ByteString(newBytes); }
/** * Get a byte string from the bytes of the character string. The string must be a Latin-1 string. * * @param str the character string * @return the byte string */ public static ByteString getBytes(String str) { final int length = str.length(); return new ByteString(getStringBytes(false, new byte[length], 0, str, 0, length), 0, length); }
public ByteString concat(String suffix, int offs, int len) { if (len <= 0) { return this; } final byte[] bytes = this.bytes; final int length = this.len; byte[] newBytes = Arrays.copyOfRange(bytes, offs, offs + length + len); getStringBytes(false, newBytes, length, suffix, offs, len); return new ByteString(newBytes); }
public static ByteString concat(String prefix, ByteString suffix) { final int prefixLength = prefix.length(); final byte[] suffixBytes = suffix.bytes; final int suffixLength = suffixBytes.length; final byte[] newBytes = new byte[prefixLength + suffixLength]; getStringBytes(false, newBytes, 0, prefix, 0, prefixLength); System.arraycopy(suffixBytes, suffix.offs, newBytes, prefixLength, suffixLength); return new ByteString(newBytes); }