mdarray-jcsv 0.6.3-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +23 -0
- data/README.md +2 -0
- data/Rakefile +46 -0
- data/config.rb +104 -0
- data/lib/constraints.rb +205 -0
- data/lib/date_filters.rb +252 -0
- data/lib/dimensions.rb +276 -0
- data/lib/filters.rb +332 -0
- data/lib/jcsv.rb +107 -0
- data/lib/list_reader.rb +200 -0
- data/lib/locale.rb +192 -0
- data/lib/map_reader.rb +192 -0
- data/lib/mdarray-jcsv.rb +24 -0
- data/lib/mdarray_reader.rb +110 -0
- data/lib/numeric_filters.rb +225 -0
- data/lib/reader.rb +547 -0
- data/lib/supercsv_interface.rb +231 -0
- data/test/test_complete.rb +37 -0
- data/test/test_critbit.rb +442 -0
- data/test/test_customer_list.rb +436 -0
- data/test/test_customer_map.rb +209 -0
- data/test/test_customer_nhlist.rb +161 -0
- data/test/test_deep_map.rb +264 -0
- data/test/test_del.rb +73 -0
- data/test/test_dimensions.rb +231 -0
- data/test/test_example.rb +79 -0
- data/test/test_filters.rb +374 -0
- data/test/test_list_dimensions.rb +110 -0
- data/test/test_mdarray.rb +227 -0
- data/test/test_missing_data.rb +57 -0
- data/vendor/commons-beanutils-1.8.3.jar +0 -0
- data/vendor/commons-lang3-3.1.jar +0 -0
- data/vendor/dozer-5.4.0.jar +0 -0
- data/vendor/jcl-over-slf4j-1.6.6.jar +0 -0
- data/vendor/joda-time-2.7.jar +0 -0
- data/vendor/slf4j-api-1.7.5.jar +0 -0
- data/vendor/snakeyaml-1.14.jar +0 -0
- data/vendor/super-csv-2.4.0.jar +0 -0
- data/vendor/super-csv-dozer-2.4.0.jar +0 -0
- data/vendor/super-csv-java8-2.4.0.jar +0 -0
- data/vendor/super-csv-joda-2.4.0.jar +0 -0
- data/version.rb +2 -0
- metadata +196 -0
data/lib/jcsv.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
##########################################################################################
|
4
|
+
# @author Rodrigo Botafogo
|
5
|
+
#
|
6
|
+
# Copyright © 2015 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
7
|
+
# and distribute this software and its documentation, without fee and without a signed
|
8
|
+
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
9
|
+
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
10
|
+
# distributions.
|
11
|
+
#
|
12
|
+
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
13
|
+
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
14
|
+
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
15
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
16
|
+
#
|
17
|
+
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
18
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
19
|
+
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
20
|
+
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
21
|
+
# OR MODIFICATIONS.
|
22
|
+
##########################################################################################
|
23
|
+
|
24
|
+
require_relative '../config'
|
25
|
+
require_relative 'filters'
|
26
|
+
require_relative 'reader'
|
27
|
+
|
28
|
+
# Ignoring surrounding spaces if they're not within quotes
|
29
|
+
# In accordance with RFC 4180, the default behaviour of Super CSV is to treat all spaces
|
30
|
+
# as important, including spaces surrounding the text in a cell.
|
31
|
+
#
|
32
|
+
# This means for reading, a cell with contents surrounded by spaces is read with
|
33
|
+
# surrounding spaces preserved. And for writing, the same String is written with surrounding
|
34
|
+
# spaces and no surrounding quotes (they're not required, as spaces are considered important).
|
35
|
+
#
|
36
|
+
# There are some scenarios where this restriction must be relaxed, in particular when the CSV
|
37
|
+
# file you're working with assumes that surrounding spaces must be surrounded by quotes,
|
38
|
+
# otherwise will be ignored. For this reason, Super CSV allows you to enable the
|
39
|
+
# surrounding_spaces_need_quotes preference.
|
40
|
+
#
|
41
|
+
# With surrounding_spaces_need_quotes enabled, it means that for reading, a cell with contents
|
42
|
+
# ' surrounded by spaces ' would be read as 'surrounded by spaces' (surrounding spaces
|
43
|
+
# are trimmed), unless the String has surrounding quotes, e.g. " surrounded by spaces ",
|
44
|
+
# in which case the spaces are preserved. And for writing, any String containing surrounding
|
45
|
+
# spaces will automatically be given surrounding quotes when written in order to preserve
|
46
|
+
# the spaces.
|
47
|
+
#
|
48
|
+
# You can enable this behaviour by calling surrounding_spaces_need_quotes(true) on the Builder.
|
49
|
+
# You can do this with your own custom preference, or customize an existing preference
|
50
|
+
|
51
|
+
# Skipping comments
|
52
|
+
# Although comments aren't part of RFC4180, some CSV files use them so it's useful to be able
|
53
|
+
# to skip these lines (or even skip lines because they contain invalid data). You can use one
|
54
|
+
# of the predefined comment matchers:
|
55
|
+
#
|
56
|
+
# CommentStartsWith - matches lines that start with a specified String
|
57
|
+
# CommentMatches - matches lines that match a specified regular expression
|
58
|
+
# Or if you like you can write your own by implementing the CommentMatcher interface.
|
59
|
+
|
60
|
+
class Jcsv
|
61
|
+
include_package "org.supercsv.cellprocessor.ift"
|
62
|
+
|
63
|
+
attr_reader :reader
|
64
|
+
|
65
|
+
#---------------------------------------------------------------------------------------
|
66
|
+
# @param end_of_line_symbols The end of line symbols to use when writing (Windows, Mac
|
67
|
+
# and Linux style line breaks are all supported when reading, so this preference won't be
|
68
|
+
# used at all for reading).
|
69
|
+
# @param encoder Use your own encoder when writing CSV. See the section on custom
|
70
|
+
# encoders below.
|
71
|
+
# quoteMode
|
72
|
+
# Allows you to enable surrounding quotes for writing (if a column wouldn't normally be
|
73
|
+
# quoted because it doesn't contain special characters).
|
74
|
+
#---------------------------------------------------------------------------------------
|
75
|
+
|
76
|
+
def self.write
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
#---------------------------------------------------------------------------------------
|
81
|
+
#
|
82
|
+
#---------------------------------------------------------------------------------------
|
83
|
+
|
84
|
+
def self.reader(*params)
|
85
|
+
|
86
|
+
format = params[1]? params[1][:format] : :list
|
87
|
+
|
88
|
+
case format
|
89
|
+
when :map, :critbit
|
90
|
+
@reader = Jcsv::MapReader.new(*params)
|
91
|
+
when :mdarray
|
92
|
+
@reader = Jcsv::MDArrayReader.new(*params)
|
93
|
+
else
|
94
|
+
@reader = Jcsv::ListReader.new(*params)
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
#---------------------------------------------------------------------------------------
|
100
|
+
#
|
101
|
+
#---------------------------------------------------------------------------------------
|
102
|
+
|
103
|
+
def filters=(filters)
|
104
|
+
@reader.filters=(filters)
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
data/lib/list_reader.rb
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
##########################################################################################
|
4
|
+
# @author Rodrigo Botafogo
|
5
|
+
#
|
6
|
+
# Copyright © 2015 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
7
|
+
# and distribute this software and its documentation, without fee and without a signed
|
8
|
+
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
9
|
+
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
10
|
+
# distributions.
|
11
|
+
#
|
12
|
+
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
13
|
+
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
14
|
+
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
15
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
16
|
+
#
|
17
|
+
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
18
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
19
|
+
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
20
|
+
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
21
|
+
# OR MODIFICATIONS.
|
22
|
+
##########################################################################################
|
23
|
+
|
24
|
+
require_relative "supercsv_interface"
|
25
|
+
|
26
|
+
class Jcsv
|
27
|
+
|
28
|
+
#========================================================================================
|
29
|
+
#
|
30
|
+
#========================================================================================
|
31
|
+
|
32
|
+
class ListReader < Reader
|
33
|
+
include_package "java.io"
|
34
|
+
|
35
|
+
#---------------------------------------------------------------------------------------
|
36
|
+
# read the file.
|
37
|
+
#---------------------------------------------------------------------------------------
|
38
|
+
|
39
|
+
def read(&block)
|
40
|
+
|
41
|
+
# When no block given, chunks read are stored in an array and returned to the user.
|
42
|
+
if (!block_given?)
|
43
|
+
rows = []
|
44
|
+
parse_with_block do |line_no, row_no, chunk|
|
45
|
+
rows << chunk
|
46
|
+
end
|
47
|
+
rows
|
48
|
+
else
|
49
|
+
parse_with_block(&block)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
#---------------------------------------------------------------------------------------
|
55
|
+
#
|
56
|
+
#---------------------------------------------------------------------------------------
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
#========================================================================================
|
61
|
+
# This module should be included if the ListReader has headers; otherwise, the
|
62
|
+
# HeaderLess module should be included.
|
63
|
+
#========================================================================================
|
64
|
+
|
65
|
+
module Header
|
66
|
+
|
67
|
+
#---------------------------------------------------------------------------------------
|
68
|
+
# When file has headers, mapping should be done through the use of a hash like data
|
69
|
+
# structure that responds to [] with a key. A mapping allows reordering of columns and
|
70
|
+
# also columns removal. A column will be removed if this columns mapping is false.
|
71
|
+
# When reading with dimensions, a mapping is automatically created and dimensions are
|
72
|
+
# mapped to true.
|
73
|
+
#---------------------------------------------------------------------------------------
|
74
|
+
|
75
|
+
def mapping=(column_mapping)
|
76
|
+
|
77
|
+
# should allow mapping even with dimensions, but we need to be careful since
|
78
|
+
# dimensions set a mapping and this needs to be preserved.
|
79
|
+
@column_mapping.mapping ||= Array.new
|
80
|
+
|
81
|
+
j = 0
|
82
|
+
@headers.each_with_index do |h, i|
|
83
|
+
if column_mapping[h].nil?
|
84
|
+
@column_mapping.mapping[i] ||= j
|
85
|
+
j += 1
|
86
|
+
else
|
87
|
+
raise "'true' is not allowed as a mapping: #{column_mapping}" if
|
88
|
+
column_mapping[h] == true
|
89
|
+
@column_mapping.mapping[i] ||= column_mapping[h]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
#========================================================================================
|
98
|
+
# Headerless ListReader
|
99
|
+
#========================================================================================
|
100
|
+
|
101
|
+
module HeaderLess
|
102
|
+
|
103
|
+
#---------------------------------------------------------------------------------------
|
104
|
+
# TODO: Needs to be reviewed. Headerless ListReader needs further testing and
|
105
|
+
# eventually a new set of features.
|
106
|
+
#---------------------------------------------------------------------------------------
|
107
|
+
|
108
|
+
def mapping=(map)
|
109
|
+
|
110
|
+
raise "Mapping with array is not allowed when 'dimensions' are defined" if @dim_set
|
111
|
+
|
112
|
+
raise "Filters parameters should either be a hash or an array of filters" if
|
113
|
+
!map.is_a? Array
|
114
|
+
|
115
|
+
@column_mapping.mapping ||= map
|
116
|
+
@dim_set = true if @dimensions
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
#========================================================================================
|
123
|
+
#
|
124
|
+
#========================================================================================
|
125
|
+
|
126
|
+
#---------------------------------------------------------------------------------------
|
127
|
+
# Should be called when the data has headers
|
128
|
+
#---------------------------------------------------------------------------------------
|
129
|
+
|
130
|
+
def prepare_headers
|
131
|
+
extend Header
|
132
|
+
super
|
133
|
+
end
|
134
|
+
|
135
|
+
#---------------------------------------------------------------------------------------
|
136
|
+
# Should be called for headerless data
|
137
|
+
#---------------------------------------------------------------------------------------
|
138
|
+
|
139
|
+
def headerless
|
140
|
+
extend HeaderLess
|
141
|
+
super
|
142
|
+
end
|
143
|
+
|
144
|
+
#---------------------------------------------------------------------------------------
|
145
|
+
#
|
146
|
+
#---------------------------------------------------------------------------------------
|
147
|
+
|
148
|
+
private
|
149
|
+
|
150
|
+
#---------------------------------------------------------------------------------------
|
151
|
+
# Creates a new CLR reader with the given set of preferences
|
152
|
+
#---------------------------------------------------------------------------------------
|
153
|
+
|
154
|
+
def new_reader(preferences)
|
155
|
+
|
156
|
+
begin
|
157
|
+
@reader = CLR.new(FileReader.new(@filename), preferences, @dimensions,
|
158
|
+
@suppress_warnings)
|
159
|
+
rescue java.io.IOException => e
|
160
|
+
puts e
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
#---------------------------------------------------------------------------------------
|
166
|
+
#
|
167
|
+
#---------------------------------------------------------------------------------------
|
168
|
+
|
169
|
+
def format(chunk)
|
170
|
+
chunk.to_a
|
171
|
+
end
|
172
|
+
|
173
|
+
#---------------------------------------------------------------------------------------
|
174
|
+
#
|
175
|
+
#---------------------------------------------------------------------------------------
|
176
|
+
|
177
|
+
def assign_mapping(column_mapping)
|
178
|
+
|
179
|
+
# should allow mapping even with dimensions, but we need to be careful since
|
180
|
+
# dimensions set a mapping and this needs to be preserved.
|
181
|
+
@column_mapping.mapping ||= Array.new
|
182
|
+
|
183
|
+
j = 0
|
184
|
+
@headers.each_with_index do |h, i|
|
185
|
+
if column_mapping[h].nil?
|
186
|
+
@column_mapping.mapping[i] ||= j
|
187
|
+
j += 1
|
188
|
+
else
|
189
|
+
@column_mapping.mapping[i] ||= column_mapping[h]
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
# p @column_mapping.mapping
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
|
data/lib/locale.rb
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
##########################################################################################
|
4
|
+
# @author Rodrigo Botafogo
|
5
|
+
#
|
6
|
+
# Copyright © 2015 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
7
|
+
# and distribute this software and its documentation, without fee and without a signed
|
8
|
+
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
9
|
+
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
10
|
+
# distributions.
|
11
|
+
#
|
12
|
+
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
13
|
+
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
14
|
+
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
15
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
16
|
+
#
|
17
|
+
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
18
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
19
|
+
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
20
|
+
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
21
|
+
# OR MODIFICATIONS.
|
22
|
+
##########################################################################################
|
23
|
+
|
24
|
+
class Jcsv
|
25
|
+
|
26
|
+
class Locale
|
27
|
+
|
28
|
+
attr_accessor :locale
|
29
|
+
|
30
|
+
class << self
|
31
|
+
attr_accessor :available_locs
|
32
|
+
end
|
33
|
+
|
34
|
+
Locale.available_locs = []
|
35
|
+
|
36
|
+
#---------------------------------------------------------------------------------------
|
37
|
+
#
|
38
|
+
#---------------------------------------------------------------------------------------
|
39
|
+
|
40
|
+
def self.available_locales
|
41
|
+
|
42
|
+
if (@available_locs.size == 0)
|
43
|
+
java.util.Locale.available_locales.each do |loc|
|
44
|
+
@available_locs << Locale.new(loc)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
@available_locs
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
#---------------------------------------------------------------------------------------
|
53
|
+
#
|
54
|
+
#---------------------------------------------------------------------------------------
|
55
|
+
|
56
|
+
def self.default
|
57
|
+
Locale.new(locale: java.util.Locale.default)
|
58
|
+
end
|
59
|
+
|
60
|
+
#---------------------------------------------------------------------------------------
|
61
|
+
#
|
62
|
+
#---------------------------------------------------------------------------------------
|
63
|
+
|
64
|
+
def self.default=(locale)
|
65
|
+
java.util.Locale.set_default(locale.locale)
|
66
|
+
end
|
67
|
+
|
68
|
+
#---------------------------------------------------------------------------------------
|
69
|
+
#
|
70
|
+
#---------------------------------------------------------------------------------------
|
71
|
+
|
72
|
+
def self.method_missing(symbol, *args)
|
73
|
+
java.util.Locale.send(symbol, *args)
|
74
|
+
end
|
75
|
+
|
76
|
+
#---------------------------------------------------------------------------------------
|
77
|
+
#
|
78
|
+
#---------------------------------------------------------------------------------------
|
79
|
+
|
80
|
+
def initialize(locale: nil, language: nil, country: nil, variant: nil)
|
81
|
+
|
82
|
+
args = [language, country, variant]
|
83
|
+
|
84
|
+
if (locale)
|
85
|
+
@locale = locale
|
86
|
+
else
|
87
|
+
@locale = java.util.Locale.new(*(args.compact))
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
#---------------------------------------------------------------------------------------
|
93
|
+
#
|
94
|
+
#---------------------------------------------------------------------------------------
|
95
|
+
|
96
|
+
def method_missing(symbol, *args)
|
97
|
+
@locale.send(symbol, *args)
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
#=========================================================================================
|
103
|
+
#
|
104
|
+
#=========================================================================================
|
105
|
+
|
106
|
+
class Locale
|
107
|
+
|
108
|
+
CANADA = Locale.new(locale: java.util.Locale::CANADA)
|
109
|
+
CANADA_FRENCH = Locale.new(locale: java.util.Locale::CANADA_FRENCH)
|
110
|
+
CHINA = Locale.new(locale: java.util.Locale::CHINA)
|
111
|
+
CHINESE = Locale.new(locale: java.util.Locale::CHINESE)
|
112
|
+
ENGLISH = Locale.new(locale: java.util.Locale::ENGLISH)
|
113
|
+
FRANCE = Locale.new(locale: java.util.Locale::FRANCE)
|
114
|
+
FRENCH = Locale.new(locale: java.util.Locale::FRENCH)
|
115
|
+
GERMAN = Locale.new(locale: java.util.Locale::GERMAN)
|
116
|
+
GERMANY = Locale.new(locale: java.util.Locale::GERMANY)
|
117
|
+
ITALIAN = Locale.new(locale: java.util.Locale::ITALIAN)
|
118
|
+
ITALY = Locale.new(locale: java.util.Locale::ITALY)
|
119
|
+
JAPAN = Locale.new(locale: java.util.Locale::JAPAN)
|
120
|
+
JAPANESE = Locale.new(locale: java.util.Locale::JAPANESE)
|
121
|
+
KOREA = Locale.new(locale: java.util.Locale::KOREA)
|
122
|
+
KOREAN = Locale.new(locale: java.util.Locale::KOREAN)
|
123
|
+
PRC = Locale.new(locale: java.util.Locale::PRC)
|
124
|
+
ROOT = Locale.new(locale: java.util.Locale::ROOT)
|
125
|
+
SIMPLIFIED_CHINESE = Locale.new(locale: java.util.Locale::SIMPLIFIED_CHINESE)
|
126
|
+
TAIWAN = Locale.new(locale: java.util.Locale::TAIWAN)
|
127
|
+
TRADITIONAL_CHINESE = Locale.new(locale: java.util.Locale::TRADITIONAL_CHINESE)
|
128
|
+
UK = Locale.new(locale: java.util.Locale::UK)
|
129
|
+
US = Locale.new(locale: java.util.Locale::US)
|
130
|
+
BRAZIL = Locale.new(language: "pt", country: "BR")
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
##########################################################################################
|
135
|
+
#
|
136
|
+
##########################################################################################
|
137
|
+
|
138
|
+
class DFSymbols
|
139
|
+
|
140
|
+
attr_accessor :decimal_format_symbols
|
141
|
+
|
142
|
+
class << self
|
143
|
+
attr_accessor :available_locs
|
144
|
+
end
|
145
|
+
|
146
|
+
DFSymbols.available_locs = []
|
147
|
+
|
148
|
+
#---------------------------------------------------------------------------------------
|
149
|
+
#
|
150
|
+
#---------------------------------------------------------------------------------------
|
151
|
+
|
152
|
+
def self.available_locales
|
153
|
+
|
154
|
+
if (@available_locs.size == 0)
|
155
|
+
java.text.DecimalFormatSymbols.available_locales.each do |loc|
|
156
|
+
@available_locs << Locale.new(loc)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
@available_locs
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
#---------------------------------------------------------------------------------------
|
165
|
+
#
|
166
|
+
#---------------------------------------------------------------------------------------
|
167
|
+
|
168
|
+
def self.method_missing(symbol, *args)
|
169
|
+
java.text.DecimalFormatSymbols.send(symbol, *args)
|
170
|
+
end
|
171
|
+
|
172
|
+
#---------------------------------------------------------------------------------------
|
173
|
+
#
|
174
|
+
#---------------------------------------------------------------------------------------
|
175
|
+
|
176
|
+
def initialize(locale = nil)
|
177
|
+
@decimal_format_symbols = (locale.nil?)? java.text.DecimalFormatSymbols.new() :
|
178
|
+
java.text.DecimalFormatSymbols.new(locale.locale)
|
179
|
+
end
|
180
|
+
|
181
|
+
#---------------------------------------------------------------------------------------
|
182
|
+
#
|
183
|
+
#---------------------------------------------------------------------------------------
|
184
|
+
|
185
|
+
def method_missing(symbol, *args)
|
186
|
+
@decimal_format_symbols.send(symbol, *args)
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
|