/** * Get the index of first occurrence of c in ByteList from the beginning of the ByteList. * * @param c byte to be looking for * @return the index of the byte or -1 if not found */ public int indexOf(int c) { return indexOf(c, 0); }
/** * Get the index of first occurrence of Bytelist find in this ByteList starting at index i. * * @param find the ByteList to find * @param i the index to start from * @return the index of the byte or -1 if not found */ public int indexOf(ByteList find, int i) { return indexOf(bytes, begin, realSize, find.bytes, find.begin, find.realSize, i); }
/** * Get the index of first occurrence of Bytelist find in this ByteList starting at index i. * * @param find the ByteList to find * @param i the index to start from * @return the index of the byte or -1 if not found */ public int indexOf(ByteList find, int i) { return indexOf(bytes, begin, realSize, find.bytes, find.begin, find.realSize, i); }
/** * Get the index of first occurrence of Bytelist find in this ByteList. * * @param find the ByteList to find * @return the index of the byte or -1 if not found */ public int indexOf(ByteList find) { return indexOf(find, 0); }
/** * Get the index of first occurrence of Bytelist find in this ByteList starting at index i. * * @param find the ByteList to find * @param i the index to start from * @return the index of the byte or -1 if not found */ public int indexOf(ByteList find, int i) { return indexOf(bytes, begin, realSize, find.bytes, find.begin, find.realSize, i); }
/** * Get the index of first occurrence of c in ByteList from the beginning of the ByteList. * * @param c byte to be looking for * @return the index of the byte or -1 if not found */ public int indexOf(int c) { return indexOf(c, 0); }
/** * Get the index of first occurrence of Bytelist find in this ByteList. * * @param find the ByteList to find * @return the index of the byte or -1 if not found */ public int indexOf(ByteList find) { return indexOf(find, 0); }
private int strIndex(RubyString sub, int offset) { if (offset < 0) { offset += value.realSize; if (offset < 0) return -1; } if (value.realSize - offset < sub.value.realSize) return -1; if (sub.value.realSize == 0) return offset; return value.indexOf(sub.value, offset); }
/** * Get the index of first occurrence of c in ByteList from the beginning of the ByteList. * * @param c byte to be looking for * @return the index of the byte or -1 if not found */ public int indexOf(int c) { return indexOf(c, 0); }
/** * Get the index of first occurrence of Bytelist find in this ByteList. * * @param find the ByteList to find * @return the index of the byte or -1 if not found */ public int indexOf(ByteList find) { return indexOf(find, 0); }
static boolean isMimeText(ByteList str, Map<String, NKFCharset> options) { if (str.length() <= 6) { return false; } if (options.get("mime-decode") == NOCONV) { return false; } if (str.indexOf(BEGIN_MIME_STRING) < 0) { return false; } if (str.lastIndexOf(END_MIME_STRING) < 0) { return false; } return true; }
static boolean isMimeText(ByteList str, Map<String, NKFCharset> options) { if (str.length() <= 6) { return false; } if (options.get("mime-decode") == NOCONV) { return false; } if (str.indexOf(BEGIN_MIME_STRING) < 0) { return false; } if (str.lastIndexOf(END_MIME_STRING) < 0) { return false; } return true; }
static boolean isMimeText(ByteList str, Map<String, NKFCharset> options) { if (str.length() <= 6) { return false; } if (options.get("mime-decode") == NKFCharset.NOCONV) { return false; } if (str.indexOf(BEGIN_MIME_STRING) < 0) { return false; } if (str.lastIndexOf(END_MIME_STRING) < 0) { return false; } return true; }
private int strIndex(RubyString sub, int offset) { ByteList byteList = value; if (offset < 0) { offset += byteList.getRealSize(); if (offset < 0) return -1; } ByteList other = sub.value; if (sizeIsSmaller(byteList, offset, other)) return -1; if (other.getRealSize() == 0) return offset; return byteList.indexOf(other, offset); }
private IRubyObject internalSepGets(ByteList sep) throws IOException { ByteList result = new ByteList(); int ce = io.read(); while (ce != -1 && sep.indexOf(ce) == -1) { result.append((byte)ce); ce = io.read(); } line++; result.append(sep); return RubyString.newString(getRuntime(),result); }
private int strIndex(RubyString sub, int offset) { ByteList byteList = value; if (offset < 0) { offset += byteList.getRealSize(); if (offset < 0) return -1; } ByteList other = sub.value; if (sizeIsSmaller(byteList, offset, other)) return -1; if (other.getRealSize() == 0) return offset; return byteList.indexOf(other, offset); }
@Override public ByteList gets() { int length = completeSource.length(); if (offset >= length) return null; // At end of source/eof int end = completeSource.indexOf('\n', offset) + 1; if (end == 0) end = length; ByteList line = completeSource.makeShared(offset, end - offset); offset = end; if (scriptLines != null) scriptLines.append(RubyString.newString(scriptLines.getRuntime(), line)); return line; }
@Override public ByteList gets() { int length = completeSource.length(); if (offset >= length) return null; // At end of source/eof int end = completeSource.indexOf('\n', offset) + 1; if (end == 0) end = length; ByteList line = completeSource.makeShared(offset, end - offset); offset = end; if (scriptLines != null) scriptLines.append(RubyString.newString(scriptLines.getRuntime(), line)); return line; }
@JRubyMethod(visibility = Visibility.PRIVATE) public IRubyObject initialize(ThreadContext context, IRubyObject path) { if (path.respondsTo("to_path")) { path = path.callMethod(context, "to_path"); } RubyString str = path.convertToString(); if (str.getByteList().indexOf('\0') != -1) { throw context.runtime.newArgumentError("pathname contains null byte"); } infectBy(str); this.setPath((RubyString) str.dup()); return this; }
@JRubyMethod(visibility = Visibility.PRIVATE) public IRubyObject initialize(ThreadContext context, IRubyObject path) { if (path.respondsTo("to_path")) { path = path.callMethod(context, "to_path"); } RubyString str = path.convertToString(); if (str.getByteList().indexOf('\0') != -1) { throw context.runtime.newArgumentError("pathname contains null byte"); } infectBy(str); this.setPath((RubyString) str.dup()); return this; }