6

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());

Yasin Okumuş
  • 2,299
  • 7
  • 31
  • 62
  • Does Eclipse auto-complete correclty when you press `CTRL+Space` right after typing `Type.STR`? – Philipp Reichart Sep 11 '11 at 22:36
  • Actually I do not use it by typing directly. There must be something like reflection or something which uses it. But as the answer of your question, by typing, there is no problem. Ctrl+Space gives me Type.STRING (correct, without problem) – Yasin Okumuş Sep 11 '11 at 22:40
  • Maybe there is a problem with the code that reflectively calls the enum -- where does that value come from? User input form Turkish-only keyboard, or another system that sends `İ` instead of `I`? – Philipp Reichart Sep 11 '11 at 22:44
  • Thanks for your effort. I added some code I used, I hope that gives some clues about what I want to do. I work on Eclipse and until now, I have never seen such a problem. I know there could be some about this Turkish encoding but this one is just different, and I can't even get the resource/first point of that. This is just weird, I thought it must be some kind of "preference" part but all the preferences I know show UTF-8, and nothing helps. – Yasin Okumuş Sep 11 '11 at 22:56
  • Could you add the stacktrace for the exception, so we can see where it gets called from? – Philipp Reichart Sep 11 '11 at 22:57
  • I added stacktrace and some sources of the classes. – Yasin Okumuş Sep 11 '11 at 23:06
  • The code that sets 'word' would be the critical thing. – bmargulies Sep 11 '11 at 23:22
  • Maybe, but there is no "word" I put actually. What can it be? I mean I need to know if the problem is on Eclipse or on OrientDB or me? – Yasin Okumuş Sep 11 '11 at 23:24
  • 1
    Last thing for tonight, I just checked out the whole OrientDB trunk and searched it for `STRİNG` -- found nothing. It must be in your code or config files somewhere. – Philipp Reichart Sep 11 '11 at 23:27

4 Answers4

6

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.

Jörn Horstmann
  • 33,639
  • 11
  • 75
  • 118
  • Thank you very much. I think the most reasonable answer is yours for now. But how would I do this? I am only using this library and why this happening only to this library? – Yasin Okumuş Sep 12 '11 at 20:19
  • I found out the problem, not at the line you pointed but very similar. There is a "toUpperCase()" method in OCommandExecuterSQLAbstract line 40. It gives me STRİNG as Turkish locale supposed to give. I change my locale as Locale.setLocale(Locale.ENGLISH), it works well. But there is a problem; if I need to work with Turkish datas, and if I don't have Turkish locale, it will be another problem. I suggest OrientDB to fix this by changing their code as toUpperCase(Locale.ENGLISH); We will see what happens :) Thanks a lot – Yasin Okumuş Sep 12 '11 at 22:29
  • I've used this solution and committed as OrientDB SVN r3818. I've left the .toUpperCase() SQL operator because it's right that use the Locale settings to work with Turkish text. Lvc@ – Lvca Sep 13 '11 at 08:15
1

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/%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

serkan
  • 555
  • 7
  • 13
1

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.

bmargulies
  • 97,814
  • 39
  • 186
  • 310
  • Thank you. Well, actually it happens even there is no datas on database. This exception is thrown while database creation, I don't even put anything. Then I should think more on a problem of OrientDB classes? – Yasin Okumuş Sep 11 '11 at 23:19
  • 1
    It does seem to suggest that the problem is in the OrientDB metadata. Is `String` one of the supported data types? Are you using a Turkish version of OrientDB or its driver? It's hard to imagine something this basic slipping through QA, but unless you're managing the metadata (possibly a mapping file?) that's where I'd look. – TMN Sep 12 '11 at 14:15
  • I am not using any Turkish version. Only my OS (Windows7) is Turkish (and maybe JVM gets default locale as Turkish) but I don't use Turkish version of any Eclipse plugin or any package/libraries, OrientDB and its driver either. I think there is no problem about String datatype as supporting. And, I am not managing the metadata/mapping, I am only on the beginning :) – Yasin Okumuş Sep 12 '11 at 20:24
0

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. :)

Ted Hopp
  • 232,168
  • 48
  • 399
  • 521