本文整理了Java中org.apache.calcite.util.Util.toJavaId()
方法的一些代码示例,展示了Util.toJavaId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.toJavaId()
方法的具体详情如下:
包路径:org.apache.calcite.util.Util
类名称:Util
方法名:toJavaId
[英]Converts an arbitrary string into a string suitable for use as a Java identifier.
The mapping is one-to-one (that is, distinct strings will produce distinct java identifiers). The mapping is also reversible, but the inverse mapping is not implemented.
A valid Java identifier must start with a Unicode letter, underscore, or dollar sign ($). The other characters, if any, can be a Unicode letter, underscore, dollar sign, or digit.
This method uses an algorithm similar to URL encoding. Valid characters are unchanged; invalid characters are converted to an underscore followed by the hex code of the character; and underscores are doubled.
Examples:
toJavaId("foo")
returns "foo"
toJavaId("foo bar")
returns "foo_20_bar"
toJavaId("foo_bar")
returns "foo__bar"
toJavaId("0bar")
returns "_40_bar"
(digits are illegal as a prefix)toJavaId("foo0bar")
returns "foo0bar"
代码示例来源:origin: Qihoo360/Quicksql
@Test public void testToJavaId() throws UnsupportedEncodingException {
assertEquals(
"ID$0$foo",
Util.toJavaId("foo", 0));
assertEquals(
"ID$0$foo_20_bar",
Util.toJavaId("foo bar", 0));
assertEquals(
"ID$0$foo__bar",
Util.toJavaId("foo_bar", 0));
assertEquals(
"ID$100$_30_bar",
Util.toJavaId("0bar", 100));
assertEquals(
"ID$0$foo0bar",
Util.toJavaId("foo0bar", 0));
assertEquals(
"ID$0$it_27_s_20_a_20_bird_2c__20_it_27_s_20_a_20_plane_21_",
Util.toJavaId("it's a bird, it's a plane!", 0));
Util.toJavaId(
"\u00f6\u00cb\u00c4\u00ca\u00ae\u00c1\u00f9\u00cb",
0));
assertEquals(
"ID$0$_f6cb__c4ca__aec1__f9cb_",
Util.toJavaId("\uf6cb\uc4ca\uaec1\uf9cb", 0));
byte[] bytes1 = {3, 12, 54, 23, 33, 23, 45, 21, 127, -34, -92, -113};
assertEquals(
"ID$0$_3__c_6_17__21__17__2d__15__7f__6cd9__fffd_",
Util.toJavaId(
代码示例来源:origin: org.apache.calcite/calcite-core
@Test public void testToJavaId() throws UnsupportedEncodingException {
assertEquals(
"ID$0$foo",
Util.toJavaId("foo", 0));
assertEquals(
"ID$0$foo_20_bar",
Util.toJavaId("foo bar", 0));
assertEquals(
"ID$0$foo__bar",
Util.toJavaId("foo_bar", 0));
assertEquals(
"ID$100$_30_bar",
Util.toJavaId("0bar", 100));
assertEquals(
"ID$0$foo0bar",
Util.toJavaId("foo0bar", 0));
assertEquals(
"ID$0$it_27_s_20_a_20_bird_2c__20_it_27_s_20_a_20_plane_21_",
Util.toJavaId("it's a bird, it's a plane!", 0));
Util.toJavaId(
"\u00f6\u00cb\u00c4\u00ca\u00ae\u00c1\u00f9\u00cb",
0));
assertEquals(
"ID$0$_f6cb__c4ca__aec1__f9cb_",
Util.toJavaId("\uf6cb\uc4ca\uaec1\uf9cb", 0));
byte[] bytes1 = {3, 12, 54, 23, 33, 23, 45, 21, 127, -34, -92, -113};
assertEquals(
"ID$0$_3__c_6_17__21__17__2d__15__7f__6cd9__fffd_",
Util.toJavaId(
代码示例来源:origin: Qihoo360/Quicksql
String aggName = "a" + agg.aggIdx;
if (CalcitePrepareImpl.DEBUG) {
aggName = Util.toJavaId(agg.call.getAggregation().getName(), 0)
.substring("ID$0$".length()) + aggName;
代码示例来源:origin: org.apache.calcite/calcite-core
String aggName = "a" + agg.aggIdx;
if (CalcitePrepareImpl.DEBUG) {
aggName = Util.toJavaId(agg.call.getAggregation().getName(), 0)
.substring("ID$0$".length()) + aggName;
代码示例来源:origin: Qihoo360/Quicksql
String aggName = "a" + agg.aggIdx;
if (CalcitePrepareImpl.DEBUG) {
aggName = Util.toJavaId(agg.call.getAggregation().getName(), 0)
.substring("ID$0$".length()) + aggName;
代码示例来源:origin: org.apache.calcite/calcite-core
String aggName = "a" + agg.aggIdx;
if (CalcitePrepareImpl.DEBUG) {
aggName = Util.toJavaId(agg.call.getAggregation().getName(), 0)
.substring("ID$0$".length()) + aggName;
内容来源于网络,如有侵权,请联系作者删除!