public ByteArrayInputStream(byte[] buf, int offset, int length) { this.buf = buf; this.pos = offset; this.count = Math.min(offset + length, buf.Length); this._mark = offset; }
internal Matcher(Pattern parent, CharSequence text) { this.parentPattern = parent; this.text = text; // Allocate state storage int parentGroupCount = Math.max(parent.capturingGroupCount, 10); groups = new int[parentGroupCount * 2]; locals = new int[parent.localCount]; // Put fields into initial states reset(); }
public static char[] copyOfRange(char[] original, int from, int to) { int newLength = to - from; if (newLength < 0) { throw new IllegalArgumentException(from + " > " + to); } char[] copy = new char[newLength]; Array.Copy(original, from, copy, 0, Math.min(original.Length - from, newLength)); return(copy); }
public Matcher usePattern(Pattern newPattern) { if (newPattern == null) { throw new IllegalArgumentException("Pattern cannot be null"); } parentPattern = newPattern; // Reallocate state storage int parentGroupCount = Math.max(newPattern.capturingGroupCount, 10); groups = new int[parentGroupCount * 2]; locals = new int[newPattern.localCount]; for (int i = 0; i < groups.Length; i++) { groups[i] = -1; } for (int i = 0; i < locals.Length; i++) { locals[i] = -1; } return(this); }
public virtual long skip(long n) { long remaining = n; int nr; if (n <= 0) { return(0); } int size = (int)Math.min(MAX_SKIP_BUFFER_SIZE, (int)remaining); byte[] skipBuffer = new byte[size]; while (remaining > 0) { nr = read(skipBuffer, 0, (int)Math.min(size, (int)remaining)); if (nr < 0) { break; } remaining -= nr; } return(n - remaining); }
public static T[] copyOf <T>(T[] original, int newLength) { T[] copy = new T[newLength]; Array.Copy(original, copy, Math.min(original.Length, newLength)); return(copy); }