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

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

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

Regex.nameToBackrefNumber介绍

暂无

代码示例

代码示例来源:origin: org.codelibs.elasticsearch.lib/grok

public String groupMatch(String name, Region region, String pattern) {
  try {
    int number = GROK_PATTERN_REGEX.nameToBackrefNumber(name.getBytes(StandardCharsets.UTF_8), 0,
        name.getBytes(StandardCharsets.UTF_8).length, region);
    int begin = region.beg[number];
    int end = region.end[number];
    return new String(pattern.getBytes(StandardCharsets.UTF_8), begin, end - begin, StandardCharsets.UTF_8);
  } catch (StringIndexOutOfBoundsException e) {
    return null;
  } catch (ValueException e) {
    return null;
  }
}

代码示例来源:origin: logzio/sawmill

private String matchPatternValue(String groupName, Region region, String pattern) {
  try {
    int matchNumber = GROK_PATTERN_REGEX.nameToBackrefNumber(groupName.getBytes(StandardCharsets.UTF_8), 0,
        groupName.getBytes(StandardCharsets.UTF_8).length, region);
    Match match = match(groupName, region, pattern.getBytes(), matchNumber);
    List<Object> values = match.getValues();
    return values.size() == 0 ? null : (String) values.get(0);
  } catch (ValueException e) {
    return null;
  }
}

代码示例来源:origin: logzio/sawmill

private String getKey(byte[] message, Region region) {
  int matchNumber = pattern.nameToBackrefNumber(KEY.getBytes(), 0, KEY.getBytes().length, region);
  String key = prefix + trim(extractString(message, region.beg[matchNumber], region.end[matchNumber]), trimKey);
  return key.length() <= maxKeyLength ? key : null;
}

代码示例来源: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.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-complete

public int getNameToBackrefNumber(String name) {
  try {
    byte[] bytes = name.getBytes();
    return getPattern().nameToBackrefNumber(bytes, 0, bytes.length, regs);
  } catch (JOniException je) {
    throw getRuntime().newIndexError(je.getMessage());
  }
}

代码示例来源: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: org.jruby/jruby-core

public int getNameToBackrefNumber(String name) {
  try {
    byte[] bytes = name.getBytes();
    return getPattern().nameToBackrefNumber(bytes, 0, bytes.length, regs);
  } catch (JOniException je) {
    throw getRuntime().newIndexError(je.getMessage());
  }
}

代码示例来源: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.netbeans.api/org-jruby

private int nameToBackrefNumber(RubyString str) {
  ByteList value = str.getByteList();
  try {
    return pattern.nameToBackrefNumber(value.bytes, value.begin, value.begin + value.realSize, regs);
  } catch (JOniException je) {
    throw getRuntime().newIndexError(je.getMessage());
  }
}

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

private static int nameToBackrefNumber(Ruby runtime, Regex pattern, Region regs, ByteListHolder str) {
  if (pattern == null) {
    throw runtime.newIndexError("undefined group name reference: " + str);
  }
  ByteList value = str.getByteList();
  try {
    return pattern.nameToBackrefNumber(value.getUnsafeBytes(), value.getBegin(), value.getBegin() + value.getRealSize(), regs);
  } catch (JOniException je) {
    throw runtime.newIndexError(je.getMessage());
  }
}

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

private static int nameToBackrefNumber(Ruby runtime, Regex pattern, Region regs, ByteListHolder str) {
  if (pattern == null) {
    throw runtime.newIndexError("undefined group name reference: " + str);
  }
  ByteList value = str.getByteList();
  try {
    return pattern.nameToBackrefNumber(value.getUnsafeBytes(), value.getBegin(), value.getBegin() + value.getRealSize(), regs);
  } catch (JOniException je) {
    throw runtime.newIndexError(je.getMessage());
  }
}

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

private int nameToBackrefNumber(RubyString str) {
  ByteList value = str.getByteList();
  try {
    return pattern.nameToBackrefNumber(value.getUnsafeBytes(), value.getBegin(), value.getBegin() + value.getRealSize(), regs);
  } catch (JOniException je) {
    throw getRuntime().newIndexError(je.getMessage());
  }
}

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

private int nameToBackrefNumber(RubyString str) {
  ByteList value = str.getByteList();
  try {
    return pattern.nameToBackrefNumber(value.getUnsafeBytes(), value.getBegin(), value.getBegin() + value.getRealSize(), regs);
  } catch (JOniException je) {
    throw getRuntime().newIndexError(je.getMessage());
  }
}

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

no = pattern.nameToBackrefNumber(sBytes, name, nameEnd, regs);
} catch (JOniException je) {
  throw runtime.newIndexError(je.getMessage());

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

no = pattern.nameToBackrefNumber(sBytes, name, nameEnd, regs);
} catch (JOniException je) {
  throw runtime.newIndexError(je.getMessage());

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

no = pattern.nameToBackrefNumber(bytes, name, nameEnd, regs);
} catch (JOniException je) {
  throw str.getRuntime().newIndexError(je.getMessage());

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

no = pattern.nameToBackrefNumber(bytes, name, nameEnd, regs);
} catch (JOniException je) {
  throw str.getRuntime().newIndexError(je.getMessage());

相关文章