kwatable 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.txt +15 -3
- data/README.txt +1 -1
- data/bin/kwatable +3 -9
- data/examples/ex1/Makefile +18 -26
- data/examples/ex1/example1.yaml +9 -6
- data/examples/ex2/Makefile +15 -24
- data/kwatable.gemspec +2 -2
- data/lib/kwatable.rb +1 -1
- data/lib/kwatable/error-msg.rb +1 -1
- data/lib/kwatable/kwatable.schema.yaml +12 -2
- data/lib/kwatable/main-program.rb +18 -7
- data/lib/kwatable/manipulator.rb +3 -3
- data/lib/kwatable/templates/ddl-mysql.eruby +1 -1
- data/lib/kwatable/templates/ddl-postgresql.eruby +3 -3
- data/lib/kwatable/templates/defaults.yaml +1 -1
- data/lib/kwatable/templates/dto-java.eruby +75 -9
- data/lib/kwatable/templates/dto-ruby.eruby +27 -15
- data/lib/kwatable/templates/validator-ruby.eruby +97 -0
- data/test/assert-diff.rb +1 -1
- data/test/test.rb +80 -151
- metadata +4 -25
- data/test/test1/test1.ddl-mysql.expected +0 -23
- data/test/test1/test1.ddl-postgresql.expected +0 -23
- data/test/test1/test1.dto-java.Group.expected +0 -35
- data/test/test1/test1.dto-java.User.expected +0 -57
- data/test/test1/test1.dto-ruby.Group.expected +0 -20
- data/test/test1/test1.dto-ruby.User.expected +0 -33
- data/test/test1/test1.yaml +0 -96
- data/test/test2/test2.ddl-mysql.expected +0 -49
- data/test/test2/test2.ddl-postgresql.expected +0 -49
- data/test/test2/test2.dto-java.Address.expected +0 -40
- data/test/test2/test2.dto-java.Customer.expected +0 -47
- data/test/test2/test2.dto-java.Item.expected +0 -35
- data/test/test2/test2.dto-java.SalesOrder.expected +0 -48
- data/test/test2/test2.dto-java.SalesOrderLine.expected +0 -54
- data/test/test2/test2.dto-ruby.Address.expected +0 -22
- data/test/test2/test2.dto-ruby.Customer.expected +0 -29
- data/test/test2/test2.dto-ruby.Item.expected +0 -20
- data/test/test2/test2.dto-ruby.SalesOrder.expected +0 -29
- data/test/test2/test2.dto-ruby.SalesOrderLine.expected +0 -36
- data/test/test2/test2.yaml +0 -94
data/ChangeLog.txt
CHANGED
@@ -1,9 +1,21 @@
|
|
1
1
|
.=title: ChangeLog
|
2
2
|
.?copyright: copyright(c) 2005 kuwata-lab.com all rights reserved.
|
3
|
-
.?release: $Release: 0.
|
4
|
-
.?version: $Rev:
|
3
|
+
.?release: $Release: 0.2.0 $
|
4
|
+
.?version: $Rev: 18 $
|
5
5
|
|
6
|
-
.:
|
6
|
+
.: 2006-03-03 rev.18
|
7
|
+
.- [bugfix] wrong argument passed to Kwatable.msg() in Manipulaotr#_error()
|
8
|
+
|
9
|
+
.: 2006-02-26 rev.17
|
10
|
+
.- [bugfix] fixed on dto-java.eruby
|
11
|
+
.- [bugfix] fixed on dto-ruby.eruby
|
12
|
+
.- [change] add new entry 'all2' on examples/*/Makefile
|
13
|
+
.- [change] add 'required: yes' and 'pattern: /^\w+$/' on column name in kwatable.schema.yaml
|
14
|
+
.- [enhance] add 'name: label, type: str' in kwatable.schema.yaml
|
15
|
+
.- [enhance] add 'validator-ruby.eruby'
|
16
|
+
.- [change] test/test.rb is rewrited and test/test{1,2} are removed
|
17
|
+
|
18
|
+
.: 2005-10-14 rev.16 (release 0.1.0)
|
7
19
|
.- [release] 0.1.0
|
8
20
|
|
9
21
|
.: 2005-10-13 rev.15
|
data/README.txt
CHANGED
data/bin/kwatable
CHANGED
@@ -4,17 +4,11 @@
|
|
4
4
|
### kwatable - create table, dto class, or other from table definition
|
5
5
|
###
|
6
6
|
### copyright(c) 2005 kuwata-lab.com all rights reserved.
|
7
|
-
### $Release: 0.
|
8
|
-
### $Rev:
|
7
|
+
### $Release: 0.2.0 $
|
8
|
+
### $Rev: 17 $
|
9
9
|
###
|
10
10
|
|
11
11
|
require 'kwatable'
|
12
12
|
require 'kwatable/main-program'
|
13
13
|
|
14
|
-
|
15
|
-
main = Kwatable::MainProgram.new(ARGV)
|
16
|
-
output = main.execute()
|
17
|
-
print output if output
|
18
|
-
rescue Kwatable::KwatableError => ex
|
19
|
-
$stderr.puts "[ERROR] #{ex.message()}"
|
20
|
-
end
|
14
|
+
Kwatable::MainProgram.main(ARGV)
|
data/examples/ex1/Makefile
CHANGED
@@ -1,34 +1,26 @@
|
|
1
1
|
###
|
2
2
|
### copyright(c) 2005 kuwata-lab.com all rights reserved.
|
3
|
-
### $Release: 0.
|
4
|
-
### $Rev:
|
3
|
+
### $Release: 0.2.0 $
|
4
|
+
### $Rev: 17 $
|
5
5
|
###
|
6
6
|
|
7
|
-
|
7
|
+
DATAFILE = example1.yaml
|
8
|
+
OPTS_DTO_JAVA = --package=my.example --parent=Object --populate --constructor
|
9
|
+
OPTS_DTO_RUBY = --module=Example --parent=Object --reqpath=lib --symbolkey
|
8
10
|
|
9
|
-
all: ddl-mysql ddl-postgresql dto-java dto-ruby
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
all:
|
13
|
+
kwatable -f ddl-mysql.eruby $(DATAFILE) > ddl-mysql.sql
|
14
|
+
kwatable -f ddl-postgresql.eruby $(DATAFILE) > ddl-postgresql.sql
|
15
|
+
kwatable -m -f dto-java.eruby $(DATAFILE)
|
16
|
+
kwatable -m -f dto-ruby.eruby $(DATAFILE)
|
17
|
+
|
18
|
+
all2:
|
19
|
+
kwatable -f ddl-mysql.eruby $(DATAFILE) > ddl-mysql.sql
|
20
|
+
kwatable -f ddl-postgresql.eruby $(DATAFILE) > ddl-postgresql.sql
|
21
|
+
kwatable $(OPTS_DTO_JAVA) -m -f dto-java.eruby $(DATAFILE)
|
22
|
+
kwatable $(OPTS_DTO_RUBY) -m -f dto-ruby.eruby $(DATAFILE)
|
13
23
|
|
14
|
-
|
15
|
-
|
16
|
-
ddl-postgresql:
|
17
|
-
kwatable -f ddl-postgresql.eruby $(datafile) > ddl-postgresql.sql
|
18
|
-
dto-java:
|
19
|
-
kwatable -m -f dto-java.eruby $(datafile)
|
20
|
-
dto-ruby:
|
21
|
-
kwatable -m -f dto-ruby.eruby $(datafile)
|
24
|
+
clean:
|
25
|
+
rm -f *.sql *.java *.rb *.class
|
22
26
|
|
23
|
-
#bindir = ../../bin
|
24
|
-
#libdir = ../../lib
|
25
|
-
#tpldir = $(libdir)/kwatable/templates
|
26
|
-
#
|
27
|
-
#ddl-mysql:
|
28
|
-
# ruby -I $(libdir) $(bindir)/kwatable -I $(tpldir) -f ddl-mysql.eruby $(datafile) > ddl-mysql.sql
|
29
|
-
#ddl-postgresql:
|
30
|
-
# ruby -I $(libdir) $(bindir)/kwatable -I $(tpldir) -f ddl-postgresql.eruby $(datafile) > ddl-postgresql.sql
|
31
|
-
#dto-java:
|
32
|
-
# ruby -I $(libdir) $(bindir)/kwatable -I $(tpldir) -m -f dto-java.eruby $(datafile)
|
33
|
-
#dto-ruby:
|
34
|
-
# ruby -I $(libdir) $(bindir)/kwatable -I $(tpldir) -m -f dto-ruby.eruby $(datafile)
|
data/examples/ex1/example1.yaml
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
## example data file for kwatable
|
3
3
|
##
|
4
4
|
## copyright(c) 2005 kuwata-lab.com all rights reserved.
|
5
|
-
## $Release: 0.
|
6
|
-
## $Rev:
|
5
|
+
## $Release: 0.2.0 $
|
6
|
+
## $Rev: 17 $
|
7
7
|
##
|
8
8
|
|
9
9
|
columns:
|
@@ -52,7 +52,7 @@ columns:
|
|
52
52
|
type: timestamp
|
53
53
|
|
54
54
|
- name: gender
|
55
|
-
type:
|
55
|
+
type: char
|
56
56
|
enum:
|
57
57
|
- M
|
58
58
|
- F
|
@@ -68,10 +68,12 @@ tables:
|
|
68
68
|
desc: group name
|
69
69
|
- name: desc
|
70
70
|
desc: group description
|
71
|
-
- name:
|
72
|
-
desc: group class
|
71
|
+
- name: case
|
73
72
|
type: string
|
74
|
-
enum: [
|
73
|
+
enum: [ normal, debug, emergency ]
|
74
|
+
- name: flag_active
|
75
|
+
desc: is active?
|
76
|
+
type: boolean
|
75
77
|
|
76
78
|
- name: users
|
77
79
|
class: User
|
@@ -84,6 +86,7 @@ tables:
|
|
84
86
|
- name: desc
|
85
87
|
desc: description about user
|
86
88
|
- name: email
|
89
|
+
- name: gender
|
87
90
|
- name: group_id
|
88
91
|
ref: groups.id
|
89
92
|
desc: group id to which user belongs
|
data/examples/ex2/Makefile
CHANGED
@@ -1,34 +1,25 @@
|
|
1
1
|
###
|
2
2
|
### copyright(c) 2005 kuwata-lab.com all rights reserved.
|
3
|
-
### $Release: 0.
|
4
|
-
### $Rev:
|
3
|
+
### $Release: 0.2.0 $
|
4
|
+
### $Rev: 17 $
|
5
5
|
###
|
6
6
|
|
7
7
|
datafile = example2.yaml
|
8
|
+
props_dto_java = --package=my.example --parent=Object --populate --constructor
|
9
|
+
props_dto_ruby = --module=Example --parent=Object --reqpath=lib --symbolkey
|
8
10
|
|
9
|
-
all:
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
all:
|
12
|
+
kwatable -f ddl-mysql.eruby $(datafile) > ddl-mysql.sql
|
13
|
+
kwatable -f ddl-postgresql.eruby $(datafile) > ddl-postgresql.sql
|
14
|
+
kwatable -m -f dto-java.eruby $(datafile)
|
15
|
+
kwatable -m -f dto-ruby.eruby $(datafile)
|
13
16
|
|
14
|
-
|
17
|
+
all2:
|
15
18
|
kwatable -f ddl-mysql.eruby $(datafile) > ddl-mysql.sql
|
16
|
-
ddl-postgresql:
|
17
19
|
kwatable -f ddl-postgresql.eruby $(datafile) > ddl-postgresql.sql
|
18
|
-
dto-java
|
19
|
-
kwatable -m -f dto-
|
20
|
-
|
21
|
-
|
20
|
+
kwatable $(props_dto_java) -m -f dto-java.eruby $(datafile)
|
21
|
+
kwatable $(props_dto_ruby) -m -f dto-ruby.eruby $(datafile)
|
22
|
+
|
23
|
+
clean:
|
24
|
+
rm -f *.sql *.java *.rb *.class
|
22
25
|
|
23
|
-
#bindir = ../../bin
|
24
|
-
#libdir = ../../lib
|
25
|
-
#tpldir = $(libdir)/kwatable/templates
|
26
|
-
#
|
27
|
-
#ddl-mysql:
|
28
|
-
# ruby -I $(libdir) $(bindir)/kwatable -I $(tpldir) -f ddl-mysql.eruby $(datafile) > ddl-mysql.sql
|
29
|
-
#ddl-postgresql:
|
30
|
-
# ruby -I $(libdir) $(bindir)/kwatable -I $(tpldir) -f ddl-postgresql.eruby $(datafile) > ddl-postgresql.sql
|
31
|
-
#dto-java:
|
32
|
-
# ruby -I $(libdir) $(bindir)/kwatable -I $(tpldir) -m -f dto-java.eruby $(datafile)
|
33
|
-
#dto-ruby:
|
34
|
-
# ruby -I $(libdir) $(bindir)/kwatable -I $(tpldir) -m -f dto-ruby.eruby $(datafile)
|
data/kwatable.gemspec
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
### RubyGems Specification file for kwatable
|
5
5
|
###
|
6
6
|
### copyright(c) 2005 kuwata-lab.com all rights reserved.
|
7
|
-
### $Release: 0.
|
7
|
+
### $Release: 0.2.0 $
|
8
8
|
### $Rev: 10 $
|
9
9
|
###
|
10
10
|
|
@@ -14,7 +14,7 @@ spec = Gem::Specification.new do |s|
|
|
14
14
|
## package information
|
15
15
|
s.name = 'kwatable'
|
16
16
|
s.author = 'makoto kuwata'
|
17
|
-
s.version = ("$Release: 0.
|
17
|
+
s.version = ("$Release: 0.2.0 $" =~ /Release: ([\.\d]+)/) && $1
|
18
18
|
s.platform = Gem::Platform::RUBY
|
19
19
|
s.homepage = 'http://www.kuwata-lab.com/kwatable'
|
20
20
|
s.summary = "SQL and DTO generator from table definition"
|
data/lib/kwatable.rb
CHANGED
data/lib/kwatable/error-msg.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
### schema definition of kwalify for kwatable
|
3
3
|
###
|
4
4
|
### copyright(c) 2005 kuwata-lab.com all rights reserved.
|
5
|
-
### $Release: 0.
|
6
|
-
### $Rev:
|
5
|
+
### $Release: 0.2.0 $
|
6
|
+
### $Rev: 17 $
|
7
7
|
###
|
8
8
|
|
9
9
|
|
@@ -16,8 +16,12 @@ mapping:
|
|
16
16
|
mapping: &columrule
|
17
17
|
"name":
|
18
18
|
type: str
|
19
|
+
required: yes
|
20
|
+
pattern: /^\w+$/
|
19
21
|
"desc":
|
20
22
|
type: text
|
23
|
+
"label":
|
24
|
+
type: str
|
21
25
|
"type":
|
22
26
|
type: str
|
23
27
|
enum:
|
@@ -36,6 +40,8 @@ mapping:
|
|
36
40
|
- time
|
37
41
|
- timestamp
|
38
42
|
- money
|
43
|
+
- lob
|
44
|
+
- blob
|
39
45
|
"width":
|
40
46
|
type: int
|
41
47
|
#"identifier":
|
@@ -75,10 +81,14 @@ mapping:
|
|
75
81
|
"name":
|
76
82
|
type: str
|
77
83
|
required: yes
|
84
|
+
pattern: /^\w+$/
|
78
85
|
"desc":
|
79
86
|
type: text
|
87
|
+
"label":
|
88
|
+
type: str
|
80
89
|
"class":
|
81
90
|
type: str
|
91
|
+
pattern: /^[A-Z]\w+$/
|
82
92
|
"columns":
|
83
93
|
type: seq
|
84
94
|
sequence:
|
@@ -1,7 +1,7 @@
|
|
1
1
|
###
|
2
2
|
### copyright(c) 2005 kuwata-lab.com all rights reserved.
|
3
|
-
### $Release: 0.
|
4
|
-
### $Rev:
|
3
|
+
### $Release: 0.2.0 $
|
4
|
+
### $Rev: 17 $
|
5
5
|
###
|
6
6
|
|
7
7
|
require 'yaml'
|
@@ -85,7 +85,7 @@ module Kwatable
|
|
85
85
|
output_filename = context[:output_filename]
|
86
86
|
output_filename = "#{options[?d]}/#{output_filename}" if options[?d]
|
87
87
|
File.open(output_filename, 'w') { |f| f.write(output) }
|
88
|
-
unless options[?
|
88
|
+
unless options[?q]
|
89
89
|
#* key=:file_generated msg="generated: %s"
|
90
90
|
$stderr.puts(Kwatable.msg(:file_generated) % output_filename)
|
91
91
|
end
|
@@ -95,8 +95,19 @@ module Kwatable
|
|
95
95
|
return output
|
96
96
|
end
|
97
97
|
|
98
|
+
def self.main(argv=ARGV)
|
99
|
+
begin
|
100
|
+
main = MainProgram.new(ARGV)
|
101
|
+
output = main.execute()
|
102
|
+
print output if output
|
103
|
+
rescue KwatableError => ex
|
104
|
+
$stderr.puts "[ERROR] #{ex.message()}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
98
108
|
private
|
99
|
-
|
109
|
+
|
110
|
+
|
100
111
|
def _option_error(message_key, *args)
|
101
112
|
msg = Kwatable.msg(message_key) % args
|
102
113
|
return CommandOptionError.new(msg)
|
@@ -131,7 +142,7 @@ module Kwatable
|
|
131
142
|
optchar = optstr[0]
|
132
143
|
optstr = optstr[1, optstr.length-1]
|
133
144
|
case optchar
|
134
|
-
when ?h, ?v, ?m, ?
|
145
|
+
when ?h, ?v, ?m, ?q, ?D
|
135
146
|
options[optchar] = true
|
136
147
|
when ?f, ?t
|
137
148
|
arg = optstr.empty? ? argv.shift : optstr
|
@@ -192,12 +203,12 @@ module Kwatable
|
|
192
203
|
s << " -f template : template filename\n"
|
193
204
|
s << " -m : multiple output file\n"
|
194
205
|
s << " -d dir : output file directory (with '-m')\n"
|
195
|
-
s << " -
|
206
|
+
s << " -q : quiet mode\n"
|
196
207
|
return s
|
197
208
|
end
|
198
209
|
|
199
210
|
def _version()
|
200
|
-
return ("$Release: 0.
|
211
|
+
return ("$Release: 0.2.0 $" =~ /[\.\d]+/ && $&)
|
201
212
|
end
|
202
213
|
|
203
214
|
end
|
data/lib/kwatable/manipulator.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
###
|
2
2
|
### copyright(c) 2005 kuwata-lab.com all rights reserved.
|
3
|
-
### $Release: 0.
|
4
|
-
### $Rev:
|
3
|
+
### $Release: 0.2.0 $
|
4
|
+
### $Rev: 18 $
|
5
5
|
###
|
6
6
|
|
7
7
|
require 'yaml'
|
@@ -51,7 +51,7 @@ module Kwatable
|
|
51
51
|
private
|
52
52
|
|
53
53
|
def _error(message_key, *args)
|
54
|
-
msg = Kwatable.msg(
|
54
|
+
msg = Kwatable.msg(message_key) % args
|
55
55
|
return ManipulationError.new(msg)
|
56
56
|
end
|
57
57
|
|
@@ -4,8 +4,8 @@
|
|
4
4
|
## kwatable template file for PostgreSQL
|
5
5
|
##
|
6
6
|
## copyright(c) 2005 kuwata-lab.com all rights reserved.
|
7
|
-
## $Release: 0.
|
8
|
-
## $Rev:
|
7
|
+
## $Release: 0.2.0 $
|
8
|
+
## $Rev: 17 $
|
9
9
|
##
|
10
10
|
## template properties:
|
11
11
|
## (none)
|
@@ -17,7 +17,7 @@
|
|
17
17
|
#
|
18
18
|
tables = context['tables']
|
19
19
|
properties = context['properties']
|
20
|
-
raise "don't use '-m' option with 'ddl-
|
20
|
+
raise "don't use '-m' option with 'ddl-postgresql.eruby'." unless tables
|
21
21
|
|
22
22
|
|
23
23
|
#
|
@@ -4,12 +4,14 @@
|
|
4
4
|
## kwatable template file for Java DTO class
|
5
5
|
##
|
6
6
|
## copyright(c) 2005 kuwata-lab.com all rights reserved.
|
7
|
-
## $Release: 0.
|
8
|
-
## $Rev:
|
7
|
+
## $Release: 0.2.0 $
|
8
|
+
## $Rev: 17 $
|
9
9
|
##
|
10
10
|
## template properties:
|
11
|
-
## package
|
12
|
-
## parent
|
11
|
+
## --package=name : package name
|
12
|
+
## --parent=name : parent class
|
13
|
+
## --constructor : define constructor
|
14
|
+
## --populate : define populate method
|
13
15
|
##
|
14
16
|
|
15
17
|
|
@@ -116,7 +118,7 @@
|
|
116
118
|
|
117
119
|
*/
|
118
120
|
<% if klass[:package] %>
|
119
|
-
package <%= package %>;
|
121
|
+
package <%= klass[:package] %>;
|
120
122
|
<% end %>
|
121
123
|
<% for class_name in imports %>
|
122
124
|
import <%= class_name %>;
|
@@ -141,15 +143,79 @@ public class <%= klass[:name] %><%= extends %> implements java.io.Serializable {
|
|
141
143
|
|
142
144
|
<%
|
143
145
|
#
|
144
|
-
#
|
146
|
+
# constructor
|
145
147
|
#
|
148
|
+
argstr = variables.collect { |var| "#{var[:type]} #{_(var[:name])}" }.join(', ')
|
146
149
|
%>
|
147
|
-
|
148
|
-
|
150
|
+
<% if properties[:constructor] %>
|
151
|
+
public <%= klass[:name] %>(<%= argstr %>) {
|
152
|
+
<% for var in variables %>
|
153
|
+
set<%= camel_case(var[:name]) %>(<%= _(var[:name]) %>);
|
154
|
+
<% end %>
|
155
|
+
}
|
156
|
+
|
157
|
+
<% end %>
|
158
|
+
<%
|
159
|
+
#
|
160
|
+
# set all values with java.sql.ResultSet
|
161
|
+
#
|
162
|
+
%>
|
163
|
+
<% if properties[:populate] %>
|
164
|
+
public void populate(java.sql.ResultSet resultset) throws java.sql.SQLException {
|
165
|
+
<% n = 0 %>
|
166
|
+
<% for var in variables %>
|
167
|
+
<% if var[:type] == 'char' %>
|
168
|
+
<% if (n += 1) == 1 %>
|
169
|
+
String val;
|
170
|
+
<% end %>
|
171
|
+
val = resultset.getString("<%= var[:name] %>");
|
172
|
+
set<%= camel_case(var[:name]) %>(val != null && val.length() > 0 ? val.charAt(0) : 0);
|
173
|
+
<% else %>
|
149
174
|
set<%= camel_case(var[:name]) %>(resultset.get<%= var[:type].capitalize %>("<%= var[:name] %>"));
|
175
|
+
<% end %>
|
176
|
+
<% end %>
|
177
|
+
}
|
178
|
+
|
150
179
|
<% end %>
|
180
|
+
<%
|
181
|
+
#
|
182
|
+
# set all properties
|
183
|
+
#
|
184
|
+
%>
|
185
|
+
<% if properties[:populate] %>
|
186
|
+
public void populate(java.util.Map _map) {
|
187
|
+
String val = null;
|
188
|
+
<% for var in variables %>
|
189
|
+
if (_map.containsKey("<%= var[:name] %>")) {
|
190
|
+
val = (String)_map.get("<%= var[:name] %>");
|
191
|
+
<% case var[:type] %>
|
192
|
+
<% when 'String' %>
|
193
|
+
this.<%= _(var[:name]) %> = val;
|
194
|
+
<% when 'int' %>
|
195
|
+
this.<%= _(var[:name]) %> = Integer.parseInt(val);
|
196
|
+
<% when 'long' %>
|
197
|
+
this.<%= _(var[:name]) %> = Long.parseLong(val);
|
198
|
+
<% when 'float' %>
|
199
|
+
this.<%= _(var[:name]) %> = Float.parseFloat(val);
|
200
|
+
<% when 'double' %>
|
201
|
+
this.<%= _(var[:name]) %> = Double.parseDouble(val);
|
202
|
+
<% when 'char' %>
|
203
|
+
this.<%= _(var[:name]) %> = val.length() > 0 ? val.charAt(0) : 0;
|
204
|
+
<% when 'boolean' %>
|
205
|
+
this.<%= _(var[:name]) %> = val.length() > 0;
|
206
|
+
<% when 'Date' %>
|
207
|
+
try {
|
208
|
+
this.<%= _(var[:name]) %> = java.text.DateFormat.getDateInstance().parse(val);
|
209
|
+
} catch (java.text.ParseException ignore) {
|
210
|
+
}
|
211
|
+
<% else %>
|
212
|
+
<% raise "*** internal error: template='dto-java.eruby', var[:type]=#{var[:type].inspect}" %>
|
213
|
+
<% end %>
|
214
|
+
}
|
215
|
+
<% end %>
|
151
216
|
}
|
152
217
|
|
218
|
+
<% end %>
|
153
219
|
<%
|
154
220
|
#
|
155
221
|
# getter/setter
|
@@ -160,7 +226,7 @@ public class <%= klass[:name] %><%= extends %> implements java.io.Serializable {
|
|
160
226
|
getter = "#{vartype == 'boolean' ? 'is' : 'get'}#{camel_case(varname)}"
|
161
227
|
setter = "set#{camel_case(varname)}"
|
162
228
|
%>
|
163
|
-
public <%= vartype %> <%= getter %>() { return <%= _(varname)
|
229
|
+
public <%= vartype %> <%= getter %>() { return <%= _(varname) %>; }
|
164
230
|
public void <%= setter %>(<%= vartype %> <%= _(varname) %>) { this.<%= _(varname) %> = <%= _(varname) %>; }
|
165
231
|
|
166
232
|
<% end %>
|