class JAVAModelDefinition
Attributes
packageName[RW]
Public Instance Methods
finishTranslate()
click to toggle source
# File lib/translate2java.rb, line 72 def finishTranslate print "请输入java文件的包名:" @packageName = STDIN.gets.chomp replace_file("#{getDirPath}/#{class_name}.java",implementation) end
implementation_body(property)
click to toggle source
# File lib/translate2java.rb, line 21 def implementation_body(property) case property when String return "decodeString" when TrueClass,FalseClass return "decodeBoolean" when Float return "decodeDouble" when Fixnum return "decodeInt" when Bignum return "decodeLong" else end end
implementation_template()
click to toggle source
# File lib/translate2java.rb, line 53 def implementation_template template = <<-EOS package <%= packageName %>; import com.tencent.videobase.videoconfig.VideoConfigCacheMgr; public final class <%= context.class_name %> { <% context.properties.each do |prop| -%> <%= property_definition(true,prop) %> <% end -%> <% context.properties.each do |prop| -%> <%=propterty_getterGenerator(prop) %> <% end -%> } EOS end
property_definition(readonly, args)
click to toggle source
# File lib/translate2java.rb, line 6 def property_definition(readonly, args) property_value = args[1] if String === args[1] property_value = %Q("#{property_value}") end property_str = "private static #{property_type(args[1])} #{args[0]} = #{property_value}; " end
property_type(property)
click to toggle source
# File lib/translate2java.rb, line 37 def property_type(property) case property when String return "String" when TrueClass,FalseClass return "boolean" when Float return "double" when Fixnum return "int" when Bignum return "long" else end end
propterty_getterGenerator(args)
click to toggle source
# File lib/translate2java.rb, line 14 def propterty_getterGenerator(args) argParam = %Q("#{args[0]}") getter = "public static #{property_type(args[1])} get#{args[0]}(){ return VideoConfigCacheMgr.#{implementation_body(args[1])}(#{argParam},#{args[0]}); } " end