545ee44bd54c71519e3564e37557344dd42e6680
[jalviewjs.git] / site / swingjs / j2s / javax / swing / RowFilter.js
1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["java.lang.Enum"], "javax.swing.RowFilter", ["java.lang.IllegalArgumentException", "$.Number", "java.util.ArrayList", "$.Date", "java.util.regex.Pattern"], function () {
3 c$ = Clazz.declareType (javax.swing, "RowFilter");
4 c$.checkIndices = Clazz.defineMethod (c$, "checkIndices", 
5  function (columns) {
6 for (var i = columns.length - 1; i >= 0; i--) {
7 if (columns[i] < 0) {
8 throw  new IllegalArgumentException ("Index must be >= 0");
9 }}
10 }, "~A");
11 c$.regexFilter = Clazz.defineMethod (c$, "regexFilter", 
12 function (regex, indices) {
13 return  new javax.swing.RowFilter.RegexFilter (java.util.regex.Pattern.compile (regex), indices);
14 }, "~S,~A");
15 c$.dateFilter = Clazz.defineMethod (c$, "dateFilter", 
16 function (type, date, indices) {
17 return  new javax.swing.RowFilter.DateFilter (type, date.getTime (), indices);
18 }, "javax.swing.RowFilter.ComparisonType,java.util.Date,~A");
19 c$.numberFilter = Clazz.defineMethod (c$, "numberFilter", 
20 function (type, number, indices) {
21 return  new javax.swing.RowFilter.NumberFilter (type, number, indices);
22 }, "javax.swing.RowFilter.ComparisonType,Number,~A");
23 c$.orFilter = Clazz.defineMethod (c$, "orFilter", 
24 function (filters) {
25 return  new javax.swing.RowFilter.OrFilter (filters);
26 }, "Iterable");
27 c$.andFilter = Clazz.defineMethod (c$, "andFilter", 
28 function (filters) {
29 return  new javax.swing.RowFilter.AndFilter (filters);
30 }, "Iterable");
31 c$.notFilter = Clazz.defineMethod (c$, "notFilter", 
32 function (filter) {
33 return  new javax.swing.RowFilter.NotFilter (filter);
34 }, "javax.swing.RowFilter");
35 Clazz.pu$h(self.c$);
36 c$ = Clazz.declareType (javax.swing.RowFilter, "ComparisonType", Enum);
37 Clazz.defineEnumConstant (c$, "BEFORE", 0, []);
38 Clazz.defineEnumConstant (c$, "AFTER", 1, []);
39 Clazz.defineEnumConstant (c$, "EQUAL", 2, []);
40 Clazz.defineEnumConstant (c$, "NOT_EQUAL", 3, []);
41 c$ = Clazz.p0p ();
42 Clazz.pu$h(self.c$);
43 c$ = Clazz.declareType (javax.swing.RowFilter, "Entry");
44 Clazz.makeConstructor (c$, 
45 function () {
46 });
47 Clazz.defineMethod (c$, "getStringValue", 
48 function (a) {
49 var b = this.getValue (a);
50 return (b == null) ? "" : b.toString ();
51 }, "~N");
52 c$ = Clazz.p0p ();
53 Clazz.pu$h(self.c$);
54 c$ = Clazz.decorateAsClass (function () {
55 this.columns = null;
56 Clazz.instantialize (this, arguments);
57 }, javax.swing.RowFilter, "GeneralFilter", javax.swing.RowFilter);
58 Clazz.makeConstructor (c$, 
59 function (a) {
60 Clazz.superConstructor (this, javax.swing.RowFilter.GeneralFilter, []);
61 javax.swing.RowFilter.checkIndices (a);
62 this.columns = a;
63 }, "~A");
64 Clazz.defineMethod (c$, "include", 
65 function (a) {
66 var b = a.getValueCount ();
67 if (this.columns.length > 0) {
68 for (var c = this.columns.length - 1; c >= 0; c--) {
69 var d = this.columns[c];
70 if (d < b) {
71 if (this.include (a, d)) {
72 return true;
73 }}}
74 } else {
75 while (--b >= 0) {
76 if (this.include (a, b)) {
77 return true;
78 }}
79 }return false;
80 }, "javax.swing.RowFilter.Entry");
81 c$ = Clazz.p0p ();
82 Clazz.pu$h(self.c$);
83 c$ = Clazz.decorateAsClass (function () {
84 this.matcher = null;
85 Clazz.instantialize (this, arguments);
86 }, javax.swing.RowFilter, "RegexFilter", javax.swing.RowFilter.GeneralFilter);
87 Clazz.makeConstructor (c$, 
88 function (a, b) {
89 Clazz.superConstructor (this, javax.swing.RowFilter.RegexFilter, [b]);
90 if (a == null) {
91 throw  new IllegalArgumentException ("Pattern must be non-null");
92 }this.matcher = a.matcher ("");
93 }, "java.util.regex.Pattern,~A");
94 Clazz.defineMethod (c$, "include", 
95 function (a, b) {
96 this.matcher.reset (a.getStringValue (b));
97 return this.matcher.find ();
98 }, "javax.swing.RowFilter.Entry,~N");
99 c$ = Clazz.p0p ();
100 Clazz.pu$h(self.c$);
101 c$ = Clazz.decorateAsClass (function () {
102 this.date = 0;
103 this.type = null;
104 Clazz.instantialize (this, arguments);
105 }, javax.swing.RowFilter, "DateFilter", javax.swing.RowFilter.GeneralFilter);
106 Clazz.makeConstructor (c$, 
107 function (a, b, c) {
108 Clazz.superConstructor (this, javax.swing.RowFilter.DateFilter, [c]);
109 if (a == null) {
110 throw  new IllegalArgumentException ("type must be non-null");
111 }this.type = a;
112 this.date = b;
113 }, "javax.swing.RowFilter.ComparisonType,~N,~A");
114 Clazz.defineMethod (c$, "include", 
115 function (a, b) {
116 var c = a.getValue (b);
117 if (Clazz.instanceOf (c, java.util.Date)) {
118 var d = (c).getTime ();
119 switch (this.type) {
120 case javax.swing.RowFilter.ComparisonType.BEFORE:
121 return (d < this.date);
122 case javax.swing.RowFilter.ComparisonType.AFTER:
123 return (d > this.date);
124 case javax.swing.RowFilter.ComparisonType.EQUAL:
125 return (d == this.date);
126 case javax.swing.RowFilter.ComparisonType.NOT_EQUAL:
127 return (d != this.date);
128 default:
129 break;
130 }
131 }return false;
132 }, "javax.swing.RowFilter.Entry,~N");
133 c$ = Clazz.p0p ();
134 Clazz.pu$h(self.c$);
135 c$ = Clazz.decorateAsClass (function () {
136 this.isComparable = false;
137 this.number = null;
138 this.type = null;
139 Clazz.instantialize (this, arguments);
140 }, javax.swing.RowFilter, "NumberFilter", javax.swing.RowFilter.GeneralFilter);
141 Clazz.makeConstructor (c$, 
142 function (a, b, c) {
143 Clazz.superConstructor (this, javax.swing.RowFilter.NumberFilter, [c]);
144 if (a == null || b == null) {
145 throw  new IllegalArgumentException ("type and number must be non-null");
146 }this.type = a;
147 this.number = b;
148 this.isComparable = (Clazz.instanceOf (b, Comparable));
149 }, "javax.swing.RowFilter.ComparisonType,Number,~A");
150 Clazz.defineMethod (c$, "include", 
151 function (a, b) {
152 var c = a.getValue (b);
153 if (Clazz.instanceOf (c, Number)) {
154 var d = true;
155 var e;
156 var f = c.getClass ();
157 if (this.number.getClass () === f && this.isComparable) {
158 e = (this.number).compareTo (c);
159 } else {
160 e = this.longCompare (c);
161 }switch (this.type) {
162 case javax.swing.RowFilter.ComparisonType.BEFORE:
163 return (e > 0);
164 case javax.swing.RowFilter.ComparisonType.AFTER:
165 return (e < 0);
166 case javax.swing.RowFilter.ComparisonType.EQUAL:
167 return (e == 0);
168 case javax.swing.RowFilter.ComparisonType.NOT_EQUAL:
169 return (e != 0);
170 default:
171 break;
172 }
173 }return false;
174 }, "javax.swing.RowFilter.Entry,~N");
175 c$ = Clazz.p0p ();
176 Clazz.pu$h(self.c$);
177 c$ = Clazz.decorateAsClass (function () {
178 this.filters = null;
179 Clazz.instantialize (this, arguments);
180 }, javax.swing.RowFilter, "OrFilter", javax.swing.RowFilter);
181 Clazz.makeConstructor (c$, 
182 function (a) {
183 Clazz.superConstructor (this, javax.swing.RowFilter.OrFilter, []);
184 this.filters =  new java.util.ArrayList ();
185 for (var filter, $filter = a.iterator (); $filter.hasNext () && ((filter = $filter.next ()) || true);) {
186 if (filter == null) {
187 throw  new IllegalArgumentException ("Filter must be non-null");
188 }this.filters.add (filter);
189 }
190 }, "Iterable");
191 Clazz.defineMethod (c$, "include", 
192 function (a) {
193 for (var filter, $filter = this.filters.iterator (); $filter.hasNext () && ((filter = $filter.next ()) || true);) {
194 if (filter.include (a)) {
195 return true;
196 }}
197 return false;
198 }, "javax.swing.RowFilter.Entry");
199 c$ = Clazz.p0p ();
200 Clazz.pu$h(self.c$);
201 c$ = Clazz.declareType (javax.swing.RowFilter, "AndFilter", javax.swing.RowFilter.OrFilter);
202 Clazz.overrideMethod (c$, "include", 
203 function (a) {
204 for (var filter, $filter = this.filters.iterator (); $filter.hasNext () && ((filter = $filter.next ()) || true);) {
205 if (!filter.include (a)) {
206 return false;
207 }}
208 return true;
209 }, "javax.swing.RowFilter.Entry");
210 c$ = Clazz.p0p ();
211 Clazz.pu$h(self.c$);
212 c$ = Clazz.decorateAsClass (function () {
213 this.filter = null;
214 Clazz.instantialize (this, arguments);
215 }, javax.swing.RowFilter, "NotFilter", javax.swing.RowFilter);
216 Clazz.makeConstructor (c$, 
217 function (a) {
218 Clazz.superConstructor (this, javax.swing.RowFilter.NotFilter, []);
219 if (a == null) {
220 throw  new IllegalArgumentException ("filter must be non-null");
221 }this.filter = a;
222 }, "javax.swing.RowFilter");
223 Clazz.defineMethod (c$, "include", 
224 function (a) {
225 return !this.filter.include (a);
226 }, "javax.swing.RowFilter.Entry");
227 c$ = Clazz.p0p ();
228 });