/** Create a name from the bytes in array cs. * Assume that bytes are in utf8 format. */ public Name fromUtf(byte cs[]) { return Name.fromUtf(this, cs, 0, cs.length); }
/** Create a name from the bytes in array cs. * Assume that bytes are in utf8 format. */ public Name fromUtf(byte cs[]) { return Name.fromUtf(this, cs, 0, cs.length); }
/** Returns the sub-name starting at position start, up to and * excluding position end. */ public Name subName(int start, int end) { if (end < start) end = start; return fromUtf(table, table.names, index + start, end - start); }
/** Create a name from the bytes in cs[start..start+len-1]. * Assume that bytes are in utf8 format. */ public Name fromUtf(byte cs[], int start, int len) { return Name.fromUtf(this, cs, start, len); }
/** Returns the sub-name starting at position start, up to and * excluding position end. */ public Name subName(int start, int end) { if (end < start) end = start; return fromUtf(table, table.names, index + start, end - start); }
/** Create a name from the bytes in array cs. * Assume that bytes are in utf8 format. */ public static Name fromUtf(Table table, byte cs[]) { return fromUtf(table, cs, 0, cs.length); }
/** Create a name from the bytes in array cs. * Assume that bytes are in utf8 format. */ public static Name fromUtf(Table table, byte cs[]) { return fromUtf(table, cs, 0, cs.length); }
/** Create a name from the bytes in cs[start..start+len-1]. * Assume that bytes are in utf8 format. */ public Name fromUtf(byte cs[], int start, int len) { return Name.fromUtf(this, cs, start, len); }
/** Replace all `from' bytes in this name with `to' bytes. */ public Name replace(byte from, byte to) { byte[] names = table.names; int i = 0; while (i < len) { if (names[index + i] == from) { byte[] bs = new byte[len]; System.arraycopy(names, index, bs, 0, i); bs[i] = to; i++; while (i < len) { byte b = names[index + i]; bs[i] = b == from ? to : b; i++; } return fromUtf(table, bs, 0, len); } i++; } return this; }
/** Replace all `from' bytes in this name with `to' bytes. */ public Name replace(byte from, byte to) { byte[] names = table.names; int i = 0; while (i < len) { if (names[index + i] == from) { byte[] bs = new byte[len]; System.arraycopy(names, index, bs, 0, i); bs[i] = to; i++; while (i < len) { byte b = names[index + i]; bs[i] = b == from ? to : b; i++; } return fromUtf(table, bs, 0, len); } i++; } return this; }
/** Return the concatenation of all names in the array `ns'. */ public static Name concat(Table table, Name ns[]) { int len = 0; for (int i = 0; i < ns.length; i++) len = len + ns[i].len; byte[] bs = new byte[len]; len = 0; for (int i = 0; i < ns.length; i++) { ns[i].getBytes(bs, len); len = len + ns[i].len; } return fromUtf(table, bs, 0, len); }
/** Return the concatenation of all names in the array `ns'. */ public static Name concat(Table table, Name ns[]) { int len = 0; for (int i = 0; i < ns.length; i++) len = len + ns[i].len; byte[] bs = new byte[len]; len = 0; for (int i = 0; i < ns.length; i++) { ns[i].getBytes(bs, len); len = len + ns[i].len; } return fromUtf(table, bs, 0, len); }
/** Return the concatenation of this name and name `n'. */ public Name append(Name n) { byte[] bs = new byte[len + n.len]; getBytes(bs, 0); n.getBytes(bs, len); return fromUtf(table, bs, 0, bs.length); }
/** Return the concatenation of this name, the given ASCII * character, and name `n'. */ public Name append(char c, Name n) { byte[] bs = new byte[len + n.len + 1]; getBytes(bs, 0); bs[len] = (byte)c; n.getBytes(bs, len+1); return fromUtf(table, bs, 0, bs.length); }
/** Return the concatenation of this name and name `n'. */ public Name append(Name n) { byte[] bs = new byte[len + n.len]; getBytes(bs, 0); n.getBytes(bs, len); return fromUtf(table, bs, 0, bs.length); }
/** Return the concatenation of this name, the given ASCII * character, and name `n'. */ public Name append(char c, Name n) { byte[] bs = new byte[len + n.len + 1]; getBytes(bs, 0); bs[len] = (byte)c; n.getBytes(bs, len+1); return fromUtf(table, bs, 0, bs.length); }