/** * Writes a log message. * * @param str strings to be written * @param time add performance info */ public void log(final boolean time, final Object... str) { final Object[] obj = new Object[str.length + (time ? 2 : 1)]; obj[0] = remote(); System.arraycopy(str, 0, obj, 1, str.length); if (time) obj[obj.length - 1] = perf.toString(); context.log.write(obj); }
/** * Adds part of a byte array to the token. * * @param value the byte array to be added * @param start start position * @param end end position * @return self reference */ public TokenBuilder add(final byte[] value, final int start, final int end) { byte[] chrs = chars; final int cl = chrs.length, l = end - start, s = size, ns = s + l; if (ns > cl) chrs = Arrays.copyOf(chrs, Array.newSize(ns)); System.arraycopy(value, start, chrs, s, l); chars = chrs; size = ns; return this; }
/** * Inserts the given elements at the specified position. * * @param i insert position * @param e elements to insert */ public void insert(final int i, final byte[][] e) { final int l = e.length; if (l == 0) return; if (size + l > list.length) list = Arrays.copyOf(list, newSize(size + l)); Array.move(list, i, l, size - i); System.arraycopy(e, 0, list, i, l); size += l; }
/** * Sets the output text. * * @param out cached output */ public void setText(final ArrayOutput out) { final byte[] buf = out.buffer(); final int size = (int) out.size(); final byte[] chop = token(DOTS); if (out.finished() && size >= chop.length) { System.arraycopy(chop, 0, buf, size - chop.length, chop.length); } text.setText(buf, size); header.setText((out.finished() ? CHOPPED : "") + RESULT); home.setEnabled(gui.context.data() != null); }
/** * Adds values to the index. * * @param key key to be indexed * @param vals sorted values */ void add(final byte[] key, final int... vals) { // token index: add values. otherwise, reference existing values final int id = type == IndexType.TOKEN ? values.put(key) : values.id(key), vl = vals.length; // updatable index: if required, resize existing arrays while (idsList.size() < id + 1) idsList.add(null); if (lenList.size() < id + 1) lenList.set(id, 0); final int len = lenList.get(id), size = len + vl; int[] ids = idsList.get(id); if (ids == null) { ids = vals; } else { if (ids.length < size) ids = Arrays.copyOf(ids, Array.newSize(size)); System.arraycopy(vals, 0, ids, len, vl); if (ids[len - 1] > vals[0]) { if (reorder == null) reorder = new BoolList(values.size()); reorder.set(id, true); } } idsList.set(id, ids); lenList.set(id, size); }
/** * Constructor, specifying an initial token. * * @param token initial token */ public TokenBuilder(final byte[] token) { this(token.length + Array.CAPACITY); size = token.length; System.arraycopy(token, 0, chars, 0, size); }