org.antlr.v4.runtime.misc.Utils.toMap()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(65)

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

Utils.toMap介绍

[英]Convert array of strings to string→index map. Useful for converting rulenames to name→ruleindex map.
[中]

代码示例

代码示例来源:origin: org.antlr/antlr4-runtime

/**
 * Get a map from rule names to rule indexes.
 *
 * <p>Used for XPath and tree pattern compilation.</p>
 */
public Map<String, Integer> getRuleIndexMap() {
  String[] ruleNames = getRuleNames();
  if (ruleNames == null) {
    throw new UnsupportedOperationException("The current recognizer does not provide a list of rule names.");
  }
  synchronized (ruleIndexMapCache) {
    Map<String, Integer> result = ruleIndexMapCache.get(ruleNames);
    if (result == null) {
      result = Collections.unmodifiableMap(Utils.toMap(ruleNames));
      ruleIndexMapCache.put(ruleNames, result);
    }
    return result;
  }
}

代码示例来源:origin: antlr/antlr4-intellij-adaptor

/** Get a map from rule names to rule indexes. */
public static Map<String, Integer> createRuleIndexMap(String[] ruleNames) {
  return Utils.toMap(ruleNames);
}

代码示例来源:origin: antlr/antlr4-intellij-adaptor

/** Get a map from token names to token types. */
public static Map<String, Integer> createTokenTypeMap(String[] tokenNames) {
  return Utils.toMap(tokenNames);
}

代码示例来源:origin: uk.co.nichesolutions/antlr4-runtime

/**
 * Get a map from rule names to rule indexes.
 *
 * <p>Used for XPath and tree pattern compilation.</p>
 */
public Map<String, Integer> getRuleIndexMap() {
  String[] ruleNames = getRuleNames();
  if (ruleNames == null) {
    throw new UnsupportedOperationException("The current recognizer does not provide a list of rule names.");
  }
  synchronized (ruleIndexMapCache) {
    Map<String, Integer> result = ruleIndexMapCache.get(ruleNames);
    if (result == null) {
      result = Collections.unmodifiableMap(Utils.toMap(ruleNames));
      ruleIndexMapCache.put(ruleNames, result);
    }
    return result;
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Get a map from rule names to rule indexes.
 *
 * <p>Used for XPath and tree pattern compilation.</p>
 */
public Map<String, Integer> getRuleIndexMap() {
  String[] ruleNames = getRuleNames();
  if (ruleNames == null) {
    throw new UnsupportedOperationException("The current recognizer does not provide a list of rule names.");
  }
  synchronized (ruleIndexMapCache) {
    Map<String, Integer> result = ruleIndexMapCache.get(ruleNames);
    if (result == null) {
      result = Collections.unmodifiableMap(Utils.toMap(ruleNames));
      ruleIndexMapCache.put(ruleNames, result);
    }
    return result;
  }
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Get a map from rule names to rule indexes.
 *
 * <p>Used for XPath and tree pattern compilation.</p>
 */
public Map<String, Integer> getRuleIndexMap() {
  String[] ruleNames = getRuleNames();
  if (ruleNames == null) {
    throw new UnsupportedOperationException("The current recognizer does not provide a list of rule names.");
  }
  synchronized (ruleIndexMapCache) {
    Map<String, Integer> result = ruleIndexMapCache.get(ruleNames);
    if (result == null) {
      result = Collections.unmodifiableMap(Utils.toMap(ruleNames));
      ruleIndexMapCache.put(ruleNames, result);
    }
    return result;
  }
}

代码示例来源:origin: com.tunnelvisionlabs/antlr4-runtime

/**
 * Get a map from rule names to rule indexes.
 *
 * <p>Used for XPath and tree pattern compilation.</p>
 */
@NotNull
public Map<String, Integer> getRuleIndexMap() {
  String[] ruleNames = getRuleNames();
  if (ruleNames == null) {
    throw new UnsupportedOperationException("The current recognizer does not provide a list of rule names.");
  }
  synchronized (ruleIndexMapCache) {
    Map<String, Integer> result = ruleIndexMapCache.get(ruleNames);
    if (result == null) {
      result = Collections.unmodifiableMap(Utils.toMap(ruleNames));
      ruleIndexMapCache.put(ruleNames, result);
    }
    return result;
  }
}

相关文章

微信公众号

最新文章

更多