org.joni.Regex.numberOfNames()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(184)

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

Regex.numberOfNames介绍

暂无

代码示例

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

public String[] getNames() {
  int nameLength = pattern.numberOfNames();
  if (nameLength == 0) return NO_NAMES;
  String[] names = new String[nameLength];
  int j = 0;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    names[j++] = new String(e.name, e.nameP, e.nameEnd - e.nameP).intern();
  }
  return names;
}

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

public String[] getNames() {
  int nameLength = pattern.numberOfNames();
  if (nameLength == 0) return NO_NAMES;
  String[] names = new String[nameLength];
  int j = 0;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    names[j++] = new String(e.name, e.nameP, e.nameEnd - e.nameP).intern();
  }
  return names;
}

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

public IRubyObject[] getNamedBackrefValues(Ruby runtime) {
  if (pattern.numberOfNames() == 0) return NULL_ARRAY;
  IRubyObject[] values = new IRubyObject[pattern.numberOfNames()];
  int j = 0;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    int nth = pattern.nameToBackrefNumber(e.name, e.nameP, e.nameEnd, regs);
    values[j++] = RubyRegexp.nth_match(nth, this);
  }
  return values;
}

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

/**
 * returns all names in a regexp pattern as id (8859_1) strings
 * @return array of id strings.
 */
public String[] getNames() {
  int nameLength = pattern.numberOfNames();
  if (nameLength == 0) return EMPTY_STRING_ARRAY;
  String[] names = new String[nameLength];
  int j = 0;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    names[j++] = new String(e.name, e.nameP, e.nameEnd - e.nameP).intern();
  }
  return names;
}

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

public IRubyObject[] getNamedBackrefValues(Ruby runtime) {
  if (pattern.numberOfNames() == 0) return NULL_ARRAY;
  IRubyObject[] values = new IRubyObject[pattern.numberOfNames()];
  int j = 0;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    int nth = pattern.nameToBackrefNumber(e.name, e.nameP, e.nameEnd, regs);
    values[j++] = RubyRegexp.nth_match(nth, this);
  }
  return values;
}

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

/**
 * returns all names in a regexp pattern as id (8859_1) strings
 * @return array of id strings.
 */
public String[] getNames() {
  int nameLength = pattern.numberOfNames();
  if (nameLength == 0) return EMPTY_STRING_ARRAY;
  String[] names = new String[nameLength];
  int j = 0;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    names[j++] = new String(e.name, e.nameP, e.nameEnd - e.nameP).intern();
  }
  return names;
}

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

public IRubyObject[] getNamedBackrefValues(Ruby runtime) {
  final Regex pattern = getPattern();
  if (pattern.numberOfNames() == 0) return NULL_ARRAY;
  IRubyObject[] values = new IRubyObject[pattern.numberOfNames()];
  int j = 0;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    int nth = pattern.nameToBackrefNumber(e.name, e.nameP, e.nameEnd, regs);
    values[j++] = RubyRegexp.nth_match(nth, this);
  }
  return values;
}

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

public IRubyObject[] getNamedBackrefValues(Ruby runtime) {
  final Regex pattern = getPattern();
  if (pattern.numberOfNames() == 0) return NULL_ARRAY;
  IRubyObject[] values = new IRubyObject[pattern.numberOfNames()];
  int j = 0;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    int nth = pattern.nameToBackrefNumber(e.name, e.nameP, e.nameEnd, regs);
    values[j++] = RubyRegexp.nth_match(nth, this);
  }
  return values;
}

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

private static String[] names(final Regex regex) {
    final String[] names = new String[regex.numberOfCaptures() + 1];
    if (regex.numberOfNames() == 0)
      return names;
    for (final Iterator<NameEntry> iter = regex.namedBackrefIterator(); iter.hasNext();) {
      final NameEntry backref = iter.next();
      final String name = new String(backref.name, backref.nameP, backref.nameEnd - backref.nameP, StandardCharsets.UTF_8);
      for (final int index : backref.getBackRefs()) {
        names[index] = name;
      }
    }
    return names;
  }
}

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

private static String[] names(final Regex regex) {
    final String[] names = new String[regex.numberOfCaptures() + 1];
    if (regex.numberOfNames() == 0)
      return names;
    for (final Iterator<NameEntry> iter = regex.namedBackrefIterator(); iter.hasNext();) {
      final NameEntry backref = iter.next();
      final String name = new String(backref.name, backref.nameP, backref.nameEnd - backref.nameP, StandardCharsets.UTF_8);
      for (final int index : backref.getBackRefs()) {
        names[index] = name;
      }
    }
    return names;
  }
}

代码示例来源:origin: jruby/joni

public boolean noNameGroupIsActive(Syntax syntax) {
  if (isDontCaptureGroup(options)) return false;
  if (Config.USE_NAMED_GROUP) {
    if (numberOfNames() > 0 && syntax.captureOnlyNamedGroup() && !isCaptureGroup(options)) return false;
  }
  return true;
}

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

public boolean noNameGroupIsActive(Syntax syntax) {
  if (isDontCaptureGroup(options)) return false;
  if (Config.USE_NAMED_GROUP) {
    if (numberOfNames() > 0 && syntax.captureOnlyNamedGroup() && !isCaptureGroup(options)) return false;
  }
  return true;
}

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

/** rb_reg_names
 *
 */
@JRubyMethod
public IRubyObject names(ThreadContext context) {
  check();
  final Ruby runtime = context.runtime;
  if (pattern.numberOfNames() == 0) return runtime.newEmptyArray();
  RubyArray ary = RubyArray.newBlankArray(runtime, pattern.numberOfNames());
  int index = 0;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    RubyString name = RubyString.newStringShared(runtime, e.name, e.nameP, e.nameEnd - e.nameP, pattern.getEncoding());
    ary.store(index++, name);
  }
  return ary;
}

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

/** rb_reg_names
 * 
 */
@JRubyMethod(name = "names", compat = CompatVersion.RUBY1_9)
public IRubyObject names() {
  if (pattern.numberOfNames() == 0) return getRuntime().newEmptyArray();
  RubyArray ary = getRuntime().newArray(pattern.numberOfNames());
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    ary.append(RubyString.newStringShared(getRuntime(), e.name, e.nameP, e.nameEnd - e.nameP));
  }
  return ary;
}

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

/** rb_reg_names
 *
 */
@JRubyMethod
public IRubyObject names(ThreadContext context) {
  check();
  final Ruby runtime = context.runtime;
  if (pattern.numberOfNames() == 0) return runtime.newEmptyArray();
  RubyArray ary = RubyArray.newBlankArray(runtime, pattern.numberOfNames());
  int index = 0;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    RubyString name = RubyString.newStringShared(runtime, e.name, e.nameP, e.nameEnd - e.nameP, pattern.getEncoding());
    ary.store(index++, name);
  }
  return ary;
}

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

/** rb_reg_names
 * 
 */
@JRubyMethod(name = "names", compat = CompatVersion.RUBY1_9)
public IRubyObject names(ThreadContext context) {
  check();
  if (pattern.numberOfNames() == 0) return getRuntime().newEmptyArray();
  RubyArray ary = context.runtime.newArray(pattern.numberOfNames());
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    ary.append(RubyString.newStringShared(getRuntime(), e.name, e.nameP, e.nameEnd - e.nameP));
  }
  return ary;
}

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

/** rb_reg_names
 * 
 */
@JRubyMethod(name = "names", compat = CompatVersion.RUBY1_9)
public IRubyObject names(ThreadContext context) {
  check();
  if (pattern.numberOfNames() == 0) return getRuntime().newEmptyArray();
  RubyArray ary = context.runtime.newArray(pattern.numberOfNames());
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    ary.append(RubyString.newStringShared(getRuntime(), e.name, e.nameP, e.nameEnd - e.nameP));
  }
  return ary;
}

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

/** rb_reg_named_captures
 * 
 */
@JRubyMethod(name = "named_captures", compat = CompatVersion.RUBY1_9)
public IRubyObject named_captures(ThreadContext context) {
  RubyHash hash = RubyHash.newHash(getRuntime());
  if (pattern.numberOfNames() == 0) return hash;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    int[]backrefs = e.getBackRefs();
    RubyArray ary = getRuntime().newArray(backrefs.length);
    for (int backref : backrefs) ary.append(RubyFixnum.newFixnum(getRuntime(), backref));
    hash.fastASet(RubyString.newStringShared(getRuntime(), e.name, e.nameP, e.nameEnd - e.nameP).freeze(context), ary);
  }
  return hash;
}

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

/** rb_reg_named_captures
 * 
 */
@JRubyMethod(name = "named_captures", compat = CompatVersion.RUBY1_9)
public IRubyObject named_captures(ThreadContext context) {
  check();
  RubyHash hash = RubyHash.newHash(getRuntime());
  if (pattern.numberOfNames() == 0) return hash;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    int[]backrefs = e.getBackRefs();
    RubyArray ary = getRuntime().newArray(backrefs.length);
    for (int backref : backrefs) ary.append(RubyFixnum.newFixnum(getRuntime(), backref));
    hash.fastASet(RubyString.newStringShared(getRuntime(), e.name, e.nameP, e.nameEnd - e.nameP).freeze(context), ary);
  }
  return hash;
}

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

/** rb_reg_named_captures
 * 
 */
@JRubyMethod(name = "named_captures", compat = CompatVersion.RUBY1_9)
public IRubyObject named_captures(ThreadContext context) {
  check();
  RubyHash hash = RubyHash.newHash(getRuntime());
  if (pattern.numberOfNames() == 0) return hash;
  for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) {
    NameEntry e = i.next();
    int[]backrefs = e.getBackRefs();
    RubyArray ary = getRuntime().newArray(backrefs.length);
    for (int backref : backrefs) ary.append(RubyFixnum.newFixnum(getRuntime(), backref));
    hash.fastASet(RubyString.newStringShared(getRuntime(), e.name, e.nameP, e.nameEnd - e.nameP).freeze(context), ary);
  }
  return hash;
}

相关文章