OrientDB 在处理 Unicode、土耳其语和枚举时遇到问题

发布于 2024-12-03 19:27:35 字数 3285 浏览 1 评论 0 原文

我正在使用一个具有枚举类型和 const 的库,如下所示;

Type.SHORT
Type.LONG
Type.FLOAT
Type.STRING

当我在 Eclipse 中调试时,出现错误:

No enum const class Type.STRİNG

As I am using a Turkey system, There is a Problem onworking i>? but as this is an enum const,即使我将每个属性都设置为 UTF-8,也无法明白 STRING 是 Eclipse 应该寻找的内容。但它仍然寻找STRËNG,但找不到,我也无法使用它。为此我必须做什么?

项目>>属性>资源>文本文件编码现在是UTF-8。问题不断。

编辑:更多信息可能会提供一些我无法得到的线索; 我正在 OrientDB 上工作。这是我第一次尝试,所以我不知道问题是否出在 OrientDB 包上。但我使用很多其他库,我从未见过这样的问题。这个包中有一个 OType 枚举,我只是尝试连接到数据库。

    String url = "local:database";
    ODatabaseObjectTx db = new ODatabaseObjectTx(url).
    Person person = new Person("John");
    db.save(person);
    db.close();

我还没有使用更多的代码。创建数据库,但随后我得到 java.lang.IllegalArgumentException

Caused by: java.lang.IllegalArgumentException: No enum const class com.orientechnologies.orient.core.metadata.schema.OType.STRİNG
    at java.lang.Enum.valueOf(Unknown Source)
    at com.orientechnologies.orient.core.metadata.schema.OType.valueOf(OType.java:41)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLCreateProperty.parse(OCommandExecutorSQLCreateProperty.java:81)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLCreateProperty.parse(OCommandExecutorSQLCreateProperty.java:35)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:43)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:28)
    at com.orientechnologies.orient.core.storage.OStorageEmbedded.command(OStorageEmbedded.java:63)
    at com.orientechnologies.orient.core.command.OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:63)
    at com.orientechnologies.orient.core.metadata.schema.OClassImpl.addProperty(OClassImpl.java:342)
    at com.orientechnologies.orient.core.metadata.schema.OClassImpl.createProperty(OClassImpl.java:258)
    at com.orientechnologies.orient.core.metadata.security.OSecurityShared.create(OSecurityShared.java:177)
    at com.orientechnologies.orient.core.metadata.security.OSecurityProxy.create(OSecurityProxy.java:37)
    at com.orientechnologies.orient.core.metadata.OMetadata.create(OMetadata.java:70)
    at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.create(ODatabaseRecordAbstract.java:142)
    ... 4 more

这是 OType 类:http://code.google.com/p/orient/source/browse/trunk/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OType.java< /a>

和其他类; OCommandExecutorSQLCreateProperty: http://code.google.com/p/orient/source/browse/trunk/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLCreateProperty.java

第81行说:type = OType.valueOf(word.toString());

I am using a lib which has an enum type with consts like these;

Type.SHORT
Type.LONG
Type.FLOAT
Type.STRING

While I am debugging in Eclipse, I got an error:

No enum const class Type.STRİNG

As I am using a Turkish system, there is a problem on working i>İ but as this is an enum const, even though I put every attributes as UTF-8, nothing could get that STRING is what Eclipse should look for. But it still looks for STRİNG and it can't find and I can't use that. What must I do for that?

Project > Properties > Resouce > Text file encoding is UTF-8 now. Problem keeps.

EDIT: More information may give some clues which I can't get;
I am working on OrientDB. This is my first attempt, so I don't know if the problem could be on OrientDB packages. But I am using many other libs, I have never seen such a problem. There is a OType enum in this package, and I am only trying to connect to the database.

    String url = "local:database";
    ODatabaseObjectTx db = new ODatabaseObjectTx(url).
    Person person = new Person("John");
    db.save(person);
    db.close();

There is no more code I use yet. Database created but then I get the java.lang.IllegalArgumentException:

Caused by: java.lang.IllegalArgumentException: No enum const class com.orientechnologies.orient.core.metadata.schema.OType.STRİNG
    at java.lang.Enum.valueOf(Unknown Source)
    at com.orientechnologies.orient.core.metadata.schema.OType.valueOf(OType.java:41)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLCreateProperty.parse(OCommandExecutorSQLCreateProperty.java:81)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLCreateProperty.parse(OCommandExecutorSQLCreateProperty.java:35)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:43)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:28)
    at com.orientechnologies.orient.core.storage.OStorageEmbedded.command(OStorageEmbedded.java:63)
    at com.orientechnologies.orient.core.command.OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:63)
    at com.orientechnologies.orient.core.metadata.schema.OClassImpl.addProperty(OClassImpl.java:342)
    at com.orientechnologies.orient.core.metadata.schema.OClassImpl.createProperty(OClassImpl.java:258)
    at com.orientechnologies.orient.core.metadata.security.OSecurityShared.create(OSecurityShared.java:177)
    at com.orientechnologies.orient.core.metadata.security.OSecurityProxy.create(OSecurityProxy.java:37)
    at com.orientechnologies.orient.core.metadata.OMetadata.create(OMetadata.java:70)
    at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.create(ODatabaseRecordAbstract.java:142)
    ... 4 more

Here is OType class: http://code.google.com/p/orient/source/browse/trunk/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OType.java

And other class; OCommandExecutorSQLCreateProperty:
http://code.google.com/p/orient/source/browse/trunk/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLCreateProperty.java

Line 81 says: type = OType.valueOf(word.toString());

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

鸢与 2024-12-10 19:27:35

我假设您使用土耳其语言环境运行该程序是否正确?那么看来 bug 出现在 OCommandExecutorSQLCreateProperty 的第 118 行:

linkedType = OType.valueOf(linked.toUpperCase());

您必须指定应使用大写规则的区域设置,可能是 Locale.ENGLISH 作为 toUpperCase 的参数。

Am I correct to assume you are running this program using a turkish locale? Then it seems the bug is in line 118 of OCommandExecutorSQLCreateProperty:

linkedType = OType.valueOf(linked.toUpperCase());

You would have to specify the Locale whose upper casing rules should be used, probably Locale.ENGLISH as the parameter to toUpperCase.

九厘米的零° 2024-12-10 19:27:35

这个问题与你的数据库连接有关。据推测,OrientDB 中的某处有一个字符串,您正在读取它,然后尝试使用它来选择枚举的成员。

我假设在您发布的代码中变量 word 来自数据库中的数据。如果它来自其他地方,那么问题就出在“其他地方”。如果 OrientDB 出于某种奇怪的原因返回“STRËNG”作为元数据来告诉您某物的类型,那么这确实是 OrientDB 的缺陷。

如果该字符串实际上包含 ï,则 Eclipse 设置不会对结果产生任何影响。您必须编写代码将 I 标准化为 I。

如果您将“word”的内容转储为字符串的 char 的十六进制值序列,我想你会看到你的 I 正盯着你。您必须更改数据库中的内容才能拥有普通的旧 I。

This problem is related to your database connection. Presumably, there's a string in OrientDB somewhere, and you are reading it, and then trying to use it to select a member of the enum.

I'm assuming in the code that you posted that the variable word comes from data in the database. If it comes from somewhere else, then the problem is the 'somewhere else'. If OrientDB, for some strange reason, returns 'STRİNG' as metadata to tell you the type of something, then that is indeed a defect in OrientDB.

If that string actually contains a İ, then no Eclipse setting will have any effect on the results. You will have to write code to normalize İ to I.

If you dump out the contents of 'word' as a sequence of hex values for the chars of the string, I think you'll see your İ staring right at you. You have to change what's in the DB to have a plain old I.

你丑哭了我 2024-12-10 19:27:35

不幸的是,它与区域设置有关,您的操作系统的区域设置是土耳其语。

两个解决方案:

1. Change your regional settings to English-US

2. Give encoding to the jvm as command line param for setting locale to English

    -Duser.language=en -Duser.region=EN

我为 xmlbeans、exist 和 apache cxf 创建了针对同一问题的错误报告。枚举toUpper是异常点。

一些相关链接:

https://issues.apache.org/jira/browse/XMLSCHEMA- 22

http://mail-archives.apache.org/mod_mbox/xmlbeans-user/201001.mbox/%[电子邮件受保护]%3E

http://mail-archives.apache.org/mod_mbox/cxf-users/201203.mbox/%[电子邮件受保护]%3E

https://vaadin.com/forum/-/message_boards/view_message/793105

<强>http://comments.gmane.org/gmane.comp.apache.cxf。用户/18316

Unfortunately, it is related with regional setting, locale of your OS which is Turkish.

Two work around options :

1. Change your regional settings to English-US

2. Give encoding to the jvm as command line param for setting locale to English

    -Duser.language=en -Duser.region=EN

I have created bug reports for xmlbeans, exist and apache cxf for the same issue. Enumeration toUpper is the point of the exception.

Some related links:

https://issues.apache.org/jira/browse/XMLSCHEMA-22

http://mail-archives.apache.org/mod_mbox/xmlbeans-user/201001.mbox/%[email protected]%3E

http://mail-archives.apache.org/mod_mbox/cxf-users/201203.mbox/%[email protected]%3E

https://vaadin.com/forum/-/message_boards/view_message/793105

http://comments.gmane.org/gmane.comp.apache.cxf.user/18316

执手闯天涯 2024-12-10 19:27:35

一种解决方法是输入 Type.ST,然后按 Ctrl-空格键。 Eclipse 应该自动完成变量名称,而无需您弄清楚如何在土耳其语键盘上输入无点大写字母 I。 :)

One work-around is to type Type.ST and then press Ctrl-space. Eclipse should auto-complete the variable name without you having to figure out how to enter a dotless capital I on a Turkish keyboard. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文