Skip to content

Instantly share code, notes, and snippets.

@gimite
Created September 27, 2009 06:31
Show Gist options
  • Save gimite/194635 to your computer and use it in GitHub Desktop.
Save gimite/194635 to your computer and use it in GitHub Desktop.
# Workaround code to solve garbled text issue in appengine-jruby from
# http://d.hatena.ne.jp/yune_kotomi/20090922/1253627829
module AppEngine
module Datastore
def Datastore.ruby_to_java(value) # :nodoc:
if SPECIAL_RUBY_TYPES.include? value.class
value.to_java
else
case value
when Fixnum
java.lang.Long.new(value)
when Float
java.lang.Double.new(value)
when String
#value.to_java_string
# Thanks http://d.hatena.ne.jp/milk1000cc/20090802/1249218370
java.lang.String.new(value)
else
value
end
end
end
class Text < String
def to_java
#JavaDatastore::Text.new(self.to_java_string)
JavaDatastore::Text.new(java.lang.String.new(self.to_s))
end
def self.new_from_java(text)
self.new(text.getValue)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment