6

我正在使用一个具有枚举类型的库,其中包含这样的常量;

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

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

No enum const class Type.STRİNG

由于我使用的是土耳其语系统,因此在工作 i>İ 时会出现问题,但由于这是一个枚举常量,即使我将每个属性都设置为 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

和其他类;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());

4

4 回答 4

6

我是否正确假设您正在使用土耳其语言环境运行该程序?然后似乎该错误在 OCommandExecutorSQLCreateProperty 的第 118 行:

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

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

于 2011-09-12T13:53:29.927 回答
1

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

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

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

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

于 2011-09-11T23:16:10.313 回答
1

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

两种解决方法:

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/%3CSNT123-DS11993DD331D6CA7799C46CF6650@phx.gbl%3E

http://mail-archives.apache.org/mod_mbox/cxf-users/201203.mbox/%3CBLU0-SMTP115A668459D9A0DA11EA5FAF6460@phx.gbl%3E

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

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

于 2013-03-01T09:04:57.643 回答
0

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

于 2011-09-11T22:41:43.047 回答