org.apache.calcite.util.Util.toMap()方法的使用及代码示例

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

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

Util.toMap介绍

[英]Converts a Properties object to a Map<String, String>.

This is necessary because Properties is a dinosaur class. It ought to extend Map<String,String>, but instead extends Hashtable<Object,Object>.

Typical usage, to iterate over a Properties:
Properties properties; for (Map.Entry<String, String> entry = Util.toMap(properties).entrySet()) { println("key=" + entry.getKey() + ", value=" + entry.getValue()); }
[中]将属性对象转换为Map<String, String>
这是必要的,因为属性是一个恐龙类。它应该扩展Map<String,String>,但应该扩展Hashtable<Object,Object>
在属性上迭代的典型用法:
Properties properties; for (Map.Entry<String, String> entry = Util.toMap(properties).entrySet()) { println("key=" + entry.getKey() + ", value=" + entry.getValue()); }

代码示例

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

@Test public void testIterableProperties() {
 Properties properties = new Properties();
 properties.put("foo", "george");
 properties.put("bar", "ringo");
 StringBuilder sb = new StringBuilder();
 for (Map.Entry<String, String> entry : Util.toMap(properties).entrySet()) {
  sb.append(entry.getKey()).append("=").append(entry.getValue());
  sb.append(";");
 }
 assertEquals("bar=ringo;foo=george;", sb.toString());
 assertEquals(2, Util.toMap(properties).entrySet().size());
 properties.put("nonString", 34);
 try {
  for (Map.Entry<String, String> e : Util.toMap(properties).entrySet()) {
   String s = e.getValue();
   Util.discard(s);
  }
  fail("expected exception");
 } catch (ClassCastException e) {
  // ok
 }
}

代码示例来源:origin: Qihoo360/Quicksql

final Map<String, Object> operandMap = json.map();
schema.put("operand", operandMap);
for (Map.Entry<String, String> entry : Util.toMap(info).entrySet()) {
 if (entry.getKey().startsWith("schema.")) {
  operandMap.put(entry.getKey().substring("schema.".length()),

代码示例来源:origin: Qihoo360/Quicksql

@Test public void testIterableProperties() {
 Properties properties = new Properties();
 properties.put("foo", "george");
 properties.put("bar", "ringo");
 StringBuilder sb = new StringBuilder();
 for (Map.Entry<String, String> entry : Util.toMap(properties).entrySet()) {
  sb.append(entry.getKey()).append("=").append(entry.getValue());
  sb.append(";");
 }
 assertEquals("bar=ringo;foo=george;", sb.toString());
 assertEquals(2, Util.toMap(properties).entrySet().size());
 properties.put("nonString", 34);
 try {
  for (Map.Entry<String, String> e : Util.toMap(properties).entrySet()) {
   String s = e.getValue();
   Util.discard(s);
  }
  fail("expected exception");
 } catch (ClassCastException e) {
  // ok
 }
}

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

final Map<String, Object> operandMap = json.map();
schema.put("operand", operandMap);
for (Map.Entry<String, String> entry : Util.toMap(info).entrySet()) {
 if (entry.getKey().startsWith("schema.")) {
  operandMap.put(entry.getKey().substring("schema.".length()),

相关文章