org.joni.Matcher.getRegion()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中org.joni.Matcher.getRegion()方法的一些代码示例,展示了Matcher.getRegion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matcher.getRegion()方法的具体详情如下:
包路径:org.joni.Matcher
类名称:Matcher
方法名:getRegion

Matcher.getRegion介绍

暂无

代码示例

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

private void populateCapturesForSplit(Ruby runtime, RubyArray result, Matcher matcher, boolean is19) {
  Region region = matcher.getRegion();
  for (int i = 1; i < region.numRegs; i++) {
    int beg = region.beg[i];
    if (beg == -1) continue;
    result.append(is19 ? makeShared19(runtime, beg, region.end[i] - beg) : makeShared(runtime, beg, region.end[i] - beg));
  }
}

代码示例来源:origin: anba/es6draft

private boolean update(int r) {
  begin = matcher.getBegin();
  end = matcher.getEnd();
  region = matcher.getRegion();
  position = position.relativeTo(begin, end);
  return r > Matcher.FAILED;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

private void populateCapturesForSplit(Ruby runtime, RubyArray result, Matcher matcher, boolean is19) {
  Region region = matcher.getRegion();
  for (int i = 1; i < region.numRegs; i++) {
    int beg = region.beg[i];
    if (beg == -1) continue;
    result.append(is19 ? makeShared19(runtime, beg, region.end[i] - beg) : makeShared(runtime, beg, region.end[i] - beg));
  }
}

代码示例来源:origin: org.jruby/jruby-complete

static RubyString regsub(ThreadContext context, RubyString str, RubyString src, Regex pattern, Matcher matcher) {
  return regsub(context, str, src, pattern, matcher.getRegion(), matcher.getBegin(), matcher.getEnd());
}

代码示例来源:origin: org.jruby/jruby-core

static RubyString regsub(ThreadContext context, RubyString str, RubyString src, Regex pattern, Matcher matcher) {
  return regsub(context, str, src, pattern, matcher.getRegion(), matcher.getBegin(), matcher.getEnd());
}

代码示例来源:origin: eiiches/jackson-jq

final Region regions = m.getRegion();
if (regions != null) {
  for (int i = 1; i < regions.numRegs; ++i) {

代码示例来源:origin: net.thisptr/jackson-jq

final Region regions = m.getRegion();
if (regions != null) {
  for (int i = 1; i < regions.numRegs; ++i) {

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

protected void handleFileEncodingComment(ByteList encodingLine) throws IOException {
  int realSize = encodingLine.getRealSize();
  int begin = encodingLine.getBegin();
  Matcher matcher = encodingRegexp.matcher(encodingLine.getUnsafeBytes(), begin, begin + realSize);
  int result = RubyRegexp.matcherSearch(parserSupport.getConfiguration().getRuntime(), matcher, begin, begin + realSize, Option.IGNORECASE);
  if (result < 0) return;
  int begs[] = matcher.getRegion().beg;
  int ends[] = matcher.getRegion().end;
  setEncoding(new ByteList(encodingLine.getUnsafeBytes(), begs[1], ends[1] - begs[1]));
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

protected void handleFileEncodingComment(ByteList encodingLine) throws IOException {
  int realSize = encodingLine.getRealSize();
  int begin = encodingLine.getBegin();
  Matcher matcher = encodingRegexp.matcher(encodingLine.getUnsafeBytes(), begin, begin + realSize);
  int result = RubyRegexp.matcherSearch(parserSupport.getConfiguration().getRuntime(), matcher, begin, begin + realSize, Option.IGNORECASE);
  if (result < 0) return;
  int begs[] = matcher.getRegion().beg;
  int ends[] = matcher.getRegion().end;
  setEncoding(new ByteList(encodingLine.getUnsafeBytes(), begs[1], ends[1] - begs[1]));
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

protected boolean parseMagicComment(ByteList magicLine) throws IOException {
  int length = magicLine.length();
  if (length <= 7) return false;
  int beg = magicCommentMarker(magicLine, 0);
  if (beg < 0) return false;
  int end = magicCommentMarker(magicLine, beg);
  if (end < 0) return false;
  // We only use a regex if -*- ... -*- is found.  Not too hot a path?
  int realSize = magicLine.getRealSize();
  int begin = magicLine.getBegin();
  Matcher matcher = magicRegexp.matcher(magicLine.getUnsafeBytes(), begin, begin + realSize);
  int result = RubyRegexp.matcherSearch(parserSupport.getConfiguration().getRuntime(), matcher, begin, begin + realSize, Option.NONE);
  if (result < 0) return false;
  // Regexp is guarateed to have three matches
  int begs[] = matcher.getRegion().beg;
  int ends[] = matcher.getRegion().end;
  String name = magicLine.subSequence(begs[1], ends[1]).toString();
  if (!name.equalsIgnoreCase("encoding")) return false;
  setEncoding(new ByteList(magicLine.getUnsafeBytes(), begs[2], ends[2] - begs[2]));
  return true;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

protected boolean parseMagicComment(ByteList magicLine) throws IOException {
  int length = magicLine.length();
  if (length <= 7) return false;
  int beg = magicCommentMarker(magicLine, 0);
  if (beg < 0) return false;
  int end = magicCommentMarker(magicLine, beg);
  if (end < 0) return false;
  // We only use a regex if -*- ... -*- is found.  Not too hot a path?
  int realSize = magicLine.getRealSize();
  int begin = magicLine.getBegin();
  Matcher matcher = magicRegexp.matcher(magicLine.getUnsafeBytes(), begin, begin + realSize);
  int result = RubyRegexp.matcherSearch(parserSupport.getConfiguration().getRuntime(), matcher, begin, begin + realSize, Option.NONE);
  if (result < 0) return false;
  // Regexp is guarateed to have three matches
  int begs[] = matcher.getRegion().beg;
  int ends[] = matcher.getRegion().end;
  String name = magicLine.subSequence(begs[1], ends[1]).toString();
  if (!name.equalsIgnoreCase("encoding")) return false;
  setEncoding(new ByteList(magicLine.getUnsafeBytes(), begs[2], ends[2] - begs[2]));
  return true;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

static final RubyMatchData createMatchData(ThreadContext context, RubyString str, Matcher matcher, Regex pattern) {
  Ruby runtime = context.runtime;
  final RubyMatchData match = new RubyMatchData(runtime);
  // FIXME: This is pretty gross; we should have a cleaner initialization
  // that doesn't depend on package-visible fields and ideally is atomic,
  // probably using an immutable structure we replace all at once.
  // The region must be cloned because a subsequent match will update the
  // region, resulting in the MatchData created here pointing at the
  // incorrect region (capture/group).
  Region region = matcher.getRegion(); // lazy, null when no groups defined
  match.regs = region == null ? null : region.clone();
  match.begin = matcher.getBegin();
  match.end = matcher.getEnd();
  match.pattern = pattern;
  match.str = (RubyString)str.strDup(runtime).freeze(context);
  match.infectBy(str);
  return match;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

static final RubyMatchData createMatchData(ThreadContext context, RubyString str, Matcher matcher, Regex pattern) {
  Ruby runtime = context.runtime;
  final RubyMatchData match = new RubyMatchData(runtime);
  // FIXME: This is pretty gross; we should have a cleaner initialization
  // that doesn't depend on package-visible fields and ideally is atomic,
  // probably using an immutable structure we replace all at once.
  // The region must be cloned because a subsequent match will update the
  // region, resulting in the MatchData created here pointing at the
  // incorrect region (capture/group).
  Region region = matcher.getRegion(); // lazy, null when no groups defined
  match.regs = region == null ? null : region.clone();
  match.begin = matcher.getBegin();
  match.end = matcher.getEnd();
  match.pattern = pattern;
  match.str = (RubyString)str.strDup(runtime).freeze(context);
  match.infectBy(str);
  return match;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

private IRubyObject populateCapturesForScan(Ruby runtime, Matcher matcher, int range, int tuFlags, boolean is19) {
  Region region = matcher.getRegion();
  RubyArray result = getRuntime().newArray(region.numRegs);
  for (int i=1; i<region.numRegs; i++) {
    int beg = region.beg[i]; 
    if (beg == -1) {
      result.append(runtime.getNil());
    } else {
      RubyString substr = is19 ? makeShared19(runtime, beg, region.end[i] - beg) : makeShared(runtime, beg, region.end[i] - beg);
      substr.infectBy(tuFlags);
      result.append(substr);
    }
  }
  return result;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

private IRubyObject populateCapturesForScan(Ruby runtime, Matcher matcher, int range, int tuFlags, boolean is19) {
  Region region = matcher.getRegion();
  RubyArray result = getRuntime().newArray(region.numRegs);
  for (int i=1; i<region.numRegs; i++) {
    int beg = region.beg[i]; 
    if (beg == -1) {
      result.append(runtime.getNil());
    } else {
      RubyString substr = is19 ? makeShared19(runtime, beg, region.end[i] - beg) : makeShared(runtime, beg, region.end[i] - beg);
      substr.infectBy(tuFlags);
      result.append(substr);
    }
  }
  return result;
}

代码示例来源:origin: org.netbeans.api/org-jruby

private IRubyObject scanOnce(RubyRegexp regex, Matcher matcher, int range) {    
  if (matcher.search(matcher.value + value.begin, range, Option.NONE) >= 0) {
    Region region = matcher.getRegion();
    int end = region.end[0];
    if (region.beg[0] == end) {
      if (value.realSize > end) {
        matcher.value = end + regex.getPattern().getEncoding().length(value.bytes[value.begin + end]);
      } else {
        matcher.value = end + 1;
      }
    } else {
      matcher.value = end;
    }
    
    RubyArray result = getRuntime().newArray(region.numRegs);
    for (int i=1; i<region.numRegs; i++) {
      int beg = region.beg[i]; 
      if (beg == -1) {
        result.append(getRuntime().getNil());
      } else {
        result.append(substr(beg, region.end[i] - beg).infectBy(regex));
      }
    }
    return result;
  }
  return null;
}

代码示例来源:origin: org.netbeans.api/org-jruby

final RubyMatchData updateBackRef(ThreadContext context, RubyString str, Frame frame, Matcher matcher) {
  Ruby runtime = context.getRuntime();
  IRubyObject backref = frame.getBackRef();
  final RubyMatchData match;
  if (backref == null || backref.isNil() || ((RubyMatchData)backref).used()) {
    match = new RubyMatchData(runtime);
  } else {
    match = (RubyMatchData)backref;
    match.setTaint(runtime.getSafeLevel() >= 3);
  }
  
  match.regs = matcher.getRegion(); // lazy, null when no groups defined
  match.begin = matcher.getBegin();
  match.end = matcher.getEnd();
  
  match.str = (RubyString)str.strDup(runtime).freeze(context);
  match.pattern = pattern;
  frame.setBackRef(match);
  
  match.infectBy(this);
  match.infectBy(str);
  return match;
}

代码示例来源:origin: org.netbeans.api/org-jruby

regs = matcher.getRegion(); 
if (regs == null) {
  beg = matcher.getBegin();

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

regs = matcher.getRegion(); 
if (regs == null) {
  beg = matcher.getBegin();

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

regs = matcher.getRegion(); 
if (regs == null) {
  beg = matcher.getBegin();

相关文章