タイニー番組ナビゲータ本体
修订版 | 62f244949e194d47bbde4d8b69eb9d6fced6b24e (tree) |
---|---|
时间 | 2021-11-17 23:03:33 |
作者 | Masahiko Kimura <mkimura@u01....> |
Commiter | Masahiko Kimura |
Ver.1.13.5 (2021/11/17)
@@ -28,47 +28,47 @@ import tainavi.TVProgram.ProgOption; | ||
28 | 28 | |
29 | 29 | /** |
30 | 30 | * オブジェクトのフィールドを操作するユーティリティーメソッド群 |
31 | - * | |
31 | + * | |
32 | 32 | * @version 3.22.2b CommonUtils#FieldCopy()を{@link #deepCopy(Object, Object)}に移動<BR> |
33 | 33 | */ |
34 | 34 | public class FieldUtils { |
35 | 35 | |
36 | 36 | public void setDebug(boolean b) { debug = b; } |
37 | 37 | private static boolean debug = false; |
38 | - | |
38 | + | |
39 | 39 | private static boolean debuglv2 = false; |
40 | - | |
40 | + | |
41 | 41 | /******************************************************************************* |
42 | 42 | * 定数とか |
43 | 43 | ******************************************************************************/ |
44 | - | |
44 | + | |
45 | 45 | private static final String SPCH_LF = "$LF$"; |
46 | 46 | private static final String SPCH_NULL = "$NULL$"; |
47 | - | |
47 | + | |
48 | 48 | private static final String SPMK_CM = "#"; |
49 | 49 | private static final String SPMK_SEP = "="; |
50 | 50 | private static final String SPMK_LF = "\n"; |
51 | - | |
51 | + | |
52 | 52 | private static final String SPHD_MOD = SPMK_CM+" MODIFIED : "; |
53 | 53 | private static final String SPHD_VER = SPMK_CM+" VERSION : "; |
54 | 54 | private static final String SPHD_DEP = SPMK_CM+" DEPRECATED : "; |
55 | 55 | private static final String SPHD_UNS = SPMK_CM+" UNSUPPORTED : "; |
56 | 56 | private static final String SPHD_NOE = SPMK_CM+" NOELEMENT : "; |
57 | - | |
57 | + | |
58 | 58 | private static final String CMNT_AS = " AS "; |
59 | - | |
59 | + | |
60 | 60 | private static final String MSGID = "[設定保存] "; |
61 | 61 | private static final String ERRID = "[ERROR]"+MSGID; |
62 | - | |
62 | + | |
63 | 63 | /******************************************************************************* |
64 | 64 | * 保存 |
65 | 65 | ******************************************************************************/ |
66 | - | |
66 | + | |
67 | 67 | @SuppressWarnings({ "rawtypes", "unchecked" }) |
68 | 68 | public static boolean save(String envText, Object root) { |
69 | - | |
69 | + | |
70 | 70 | StringBuilder sb = new StringBuilder(); |
71 | - | |
71 | + | |
72 | 72 | sb.append(SPHD_MOD); |
73 | 73 | sb.append(CommonUtils.getDateTime(0)); |
74 | 74 | sb.append(SPMK_LF); |
@@ -76,7 +76,7 @@ public class FieldUtils { | ||
76 | 76 | sb.append(VersionInfo.getVersionNumber()); |
77 | 77 | sb.append(SPMK_LF); |
78 | 78 | sb.append(SPMK_LF); |
79 | - | |
79 | + | |
80 | 80 | Field[] fd = root.getClass().getDeclaredFields(); |
81 | 81 | for ( Field fx : fd ) { |
82 | 82 | fx.setAccessible(true); |
@@ -88,11 +88,11 @@ public class FieldUtils { | ||
88 | 88 | } |
89 | 89 | |
90 | 90 | try { |
91 | - | |
91 | + | |
92 | 92 | String key = fx.getName(); |
93 | 93 | Class cls = fx.getType(); |
94 | 94 | Object obj = fx.get(root); |
95 | - | |
95 | + | |
96 | 96 | if ( fx.getAnnotation(Deprecated.class) != null ) { |
97 | 97 | sb.append(SPHD_DEP); |
98 | 98 | sb.append(key); |
@@ -101,19 +101,19 @@ public class FieldUtils { | ||
101 | 101 | sb.append(SPMK_LF); |
102 | 102 | continue; |
103 | 103 | } |
104 | - | |
104 | + | |
105 | 105 | int n = -1; |
106 | 106 | ArrayList objlst = null; |
107 | 107 | Class ocls = null; |
108 | 108 | if ( cls == ArrayList.class ) { |
109 | 109 | objlst = (ArrayList) obj; |
110 | - | |
110 | + | |
111 | 111 | // nullの要素がある可能性がある |
112 | 112 | if ( objlst.size() > 0 ) { |
113 | 113 | ParameterizedType paramType = (ParameterizedType) fx.getGenericType(); |
114 | 114 | ocls = (Class) paramType.getActualTypeArguments()[0]; |
115 | 115 | } |
116 | - | |
116 | + | |
117 | 117 | n = 1; |
118 | 118 | } |
119 | 119 | else if ( cls == HashMap.class ) { |
@@ -121,7 +121,7 @@ public class FieldUtils { | ||
121 | 121 | HashMap map = (HashMap) obj; |
122 | 122 | for ( Object o : map.entrySet().toArray() ) { |
123 | 123 | objlst.add(o); |
124 | - | |
124 | + | |
125 | 125 | // これは必ずEntrySetだね |
126 | 126 | if ( ocls == null ) { |
127 | 127 | ocls = o.getClass(); |
@@ -132,17 +132,17 @@ public class FieldUtils { | ||
132 | 132 | else { |
133 | 133 | objlst = new ArrayList(); |
134 | 134 | objlst.add(obj); |
135 | - | |
135 | + | |
136 | 136 | // obj==nullの可能性がある |
137 | 137 | ocls = cls; |
138 | 138 | } |
139 | - | |
139 | + | |
140 | 140 | if ( ! objlst.isEmpty() ) { |
141 | 141 | for ( Object o : objlst ) { |
142 | - | |
142 | + | |
143 | 143 | //Class ocls = o.getClass(); |
144 | 144 | String val = obj2str(o,ocls); |
145 | - | |
145 | + | |
146 | 146 | if ( val != null ) { |
147 | 147 | sb.append(key); |
148 | 148 | if ( n >= 1 ) { |
@@ -181,53 +181,53 @@ public class FieldUtils { | ||
181 | 181 | catch (Exception e) { |
182 | 182 | e.printStackTrace(); |
183 | 183 | return false; |
184 | - } | |
184 | + } | |
185 | 185 | } |
186 | - | |
186 | + | |
187 | 187 | System.out.println(MSGID+"テキスト形式で保存します: "+envText); |
188 | 188 | if ( ! CommonUtils.write2file(envText, sb.toString()) ) { |
189 | 189 | System.err.println(ERRID+"保存に失敗しました"); |
190 | 190 | return false; |
191 | 191 | } |
192 | - | |
192 | + | |
193 | 193 | return true; |
194 | 194 | } |
195 | - | |
196 | - | |
195 | + | |
196 | + | |
197 | 197 | /******************************************************************************* |
198 | 198 | * 取得 |
199 | 199 | ******************************************************************************/ |
200 | - | |
200 | + | |
201 | 201 | @SuppressWarnings({ "rawtypes", "unchecked" }) |
202 | 202 | public static boolean load(String envText, Object root) { |
203 | - | |
203 | + | |
204 | 204 | if ( new File(envText).exists() ) { |
205 | 205 | System.out.println(MSGID+"テキスト形式で読み込みます: "+envText); |
206 | 206 | String buf = CommonUtils.read4file(envText, false); |
207 | 207 | if ( buf != null ) { |
208 | - | |
208 | + | |
209 | 209 | Field[] fd = root.getClass().getDeclaredFields(); |
210 | - | |
210 | + | |
211 | 211 | int lineno = 0 ; |
212 | 212 | for ( String str : buf.split(SPMK_LF) ) { |
213 | - | |
213 | + | |
214 | 214 | ++lineno; |
215 | - | |
215 | + | |
216 | 216 | if ( str.startsWith(SPHD_MOD) ) { |
217 | 217 | System.out.println(MSGID+str); |
218 | 218 | continue; |
219 | 219 | } |
220 | - | |
220 | + | |
221 | 221 | if ( str.startsWith(SPMK_CM) || str.matches("^\\s*$") ) { |
222 | 222 | continue; |
223 | 223 | } |
224 | - | |
224 | + | |
225 | 225 | String[] a = str.split(SPMK_SEP, 2); |
226 | 226 | if ( a.length != 2 ) { |
227 | 227 | System.err.println(ERRID+"不正な記述: "+envText+" at "+lineno+"行目 "+str); |
228 | 228 | break; |
229 | 229 | } |
230 | - | |
230 | + | |
231 | 231 | Field fx = null; |
232 | 232 | for ( Field f : fd ) { |
233 | 233 | if ( f.getName().equals(a[0].replaceFirst("\\[\\d+\\]$","")) ) { |
@@ -239,23 +239,23 @@ public class FieldUtils { | ||
239 | 239 | System.err.println(ERRID+"不正な記述: "+envText+" at "+lineno+"行目 "+str); |
240 | 240 | break; |
241 | 241 | } |
242 | - | |
242 | + | |
243 | 243 | fx.setAccessible(true); |
244 | - | |
244 | + | |
245 | 245 | if ( Modifier.isFinal(fx.getModifiers()) ) { |
246 | 246 | continue; |
247 | 247 | } |
248 | 248 | if ( Modifier.isStatic(fx.getModifiers()) ) { |
249 | 249 | continue; |
250 | 250 | } |
251 | - | |
251 | + | |
252 | 252 | if ( fx.getAnnotation(Deprecated.class) != null ) { |
253 | 253 | System.out.println(MSGID+SPHD_DEP+fx.getName()); |
254 | 254 | break; |
255 | 255 | } |
256 | - | |
256 | + | |
257 | 257 | Class cls = fx.getType(); |
258 | - | |
258 | + | |
259 | 259 | try { |
260 | 260 | if ( cls == ArrayList.class ) { |
261 | 261 | ArrayList list = (ArrayList) fx.get(root); |
@@ -263,7 +263,7 @@ public class FieldUtils { | ||
263 | 263 | System.out.println(ERRID+"初期化されていないフィールド: "+envText+" at "+lineno+"行目 ("+cls.getName()+") "+str); |
264 | 264 | break; |
265 | 265 | } |
266 | - | |
266 | + | |
267 | 267 | if ( a[0].endsWith("[0]") ) { |
268 | 268 | // no element. |
269 | 269 | list.clear(); |
@@ -285,12 +285,7 @@ public class FieldUtils { | ||
285 | 285 | System.out.println(ERRID+"初期化されていないフィールド: "+envText+" at "+lineno+"行目 ("+cls.getName()+") "+str); |
286 | 286 | break; |
287 | 287 | } |
288 | - String[] b = a[1].split(Pattern.quote(SPCH_LF),2); | |
289 | - if ( b.length != 2 ) { | |
290 | - System.err.println(ERRID+"不正な記述: "+envText+" at "+lineno+"行目 "+str); | |
291 | - break; | |
292 | - } | |
293 | - | |
288 | + | |
294 | 289 | if ( a[0].endsWith("[0]") ) { |
295 | 290 | // no element. |
296 | 291 | map.clear(); |
@@ -300,6 +295,13 @@ public class FieldUtils { | ||
300 | 295 | // newした時のデフォルト値が入っているからリセットじゃー |
301 | 296 | map.clear(); |
302 | 297 | } |
298 | + | |
299 | + String[] b = a[1].split(Pattern.quote(SPCH_LF),2); | |
300 | + if ( b.length != 2 ) { | |
301 | + System.err.println(ERRID+"不正な記述: "+envText+" at "+lineno+"行目 "+str); | |
302 | + continue; | |
303 | + } | |
304 | + | |
303 | 305 | ParameterizedType paramType = (ParameterizedType) fx.getGenericType(); |
304 | 306 | Class kcls = (Class) paramType.getActualTypeArguments()[0]; |
305 | 307 | Class vcls = (Class) paramType.getActualTypeArguments()[1]; |
@@ -323,18 +325,18 @@ public class FieldUtils { | ||
323 | 325 | } |
324 | 326 | } |
325 | 327 | } |
326 | - | |
328 | + | |
327 | 329 | return true; |
328 | 330 | } |
329 | - | |
331 | + | |
330 | 332 | return false; |
331 | 333 | } |
332 | - | |
333 | - | |
334 | + | |
335 | + | |
334 | 336 | /******************************************************************************* |
335 | 337 | * 保存(部品) |
336 | 338 | ******************************************************************************/ |
337 | - | |
339 | + | |
338 | 340 | @SuppressWarnings("rawtypes") |
339 | 341 | private static String obj2str(Object obj, Class cls) { |
340 | 342 | if ( cls == String.class ) { |
@@ -384,15 +386,15 @@ public class FieldUtils { | ||
384 | 386 | String v = obj2str(t.getValue(), t.getValue().getClass()); |
385 | 387 | return(obj == null ? SPCH_NULL : k+SPCH_LF+v); |
386 | 388 | } |
387 | - | |
389 | + | |
388 | 390 | return null; |
389 | 391 | } |
390 | - | |
391 | - | |
392 | + | |
393 | + | |
392 | 394 | /******************************************************************************* |
393 | 395 | * 取得(部品) |
394 | 396 | ******************************************************************************/ |
395 | - | |
397 | + | |
396 | 398 | @SuppressWarnings("rawtypes") |
397 | 399 | private static Object str2obj(String str, Class cls) throws UnsupportedOperationException { |
398 | 400 | if ( cls == String.class ) { |
@@ -505,16 +507,16 @@ public class FieldUtils { | ||
505 | 507 | } |
506 | 508 | throw new UnsupportedOperationException("変換できない"); |
507 | 509 | } |
508 | - | |
510 | + | |
509 | 511 | throw new UnsupportedOperationException("未対応の項目"); |
510 | 512 | } |
511 | 513 | |
512 | - | |
513 | - | |
514 | + | |
515 | + | |
514 | 516 | /******************************************************************************* |
515 | 517 | * ディープコピーする |
516 | 518 | ******************************************************************************/ |
517 | - | |
519 | + | |
518 | 520 | /** |
519 | 521 | * <P>オブジェクトからオブジェクトへフィールドのコピー(ディープコピー)を行います。 |
520 | 522 | * <P>新しく作ったインスタンスに入れ替えたいけど、ポインタを変えたくないので中身だけコピーできないか?という時に使います。 |
@@ -534,10 +536,10 @@ public class FieldUtils { | ||
534 | 536 | } |
535 | 537 | return false; |
536 | 538 | } |
537 | - | |
539 | + | |
538 | 540 | @SuppressWarnings("rawtypes") |
539 | 541 | private static boolean FieldCopy(final Object to, final Object from, final Field fn) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ConcurrentModificationException, InstantiationException { |
540 | - | |
542 | + | |
541 | 543 | // 継承しているクラスのリストを作成する |
542 | 544 | ArrayList<Class> fromCL = new ArrayList<Class>(); |
543 | 545 | ArrayList<Class> toCL = new ArrayList<Class>(); |
@@ -559,28 +561,28 @@ public class FieldUtils { | ||
559 | 561 | if (debuglv2) System.out.println("[DEBUG] removed TO "+toCL.get(0).getName()); |
560 | 562 | toCL.remove(0); |
561 | 563 | } |
562 | - | |
564 | + | |
563 | 565 | int i=0; |
564 | 566 | for ( Class c : fromCL ) { |
565 | - | |
567 | + | |
566 | 568 | i++; |
567 | - | |
569 | + | |
568 | 570 | String ctype = (i>1)?(" (super class)"):(""); |
569 | 571 | String cname = c.getName(); |
570 | 572 | String fname = (fn!=null)?(" name="+fn.getName()):(""); |
571 | - | |
573 | + | |
572 | 574 | if ( isHashMap(to,from,c,fn) ) { |
573 | 575 | if (debuglv2) System.err.println("[DEBUG] FieldCopy("+cname+") *** TERM *** deep copy"+ctype+fname); |
574 | 576 | return true; |
575 | 577 | } |
576 | - | |
578 | + | |
577 | 579 | if ( isLeaf(to,from,c,fn) ) { |
578 | 580 | if (debuglv2) System.err.println("[DEBUG] FieldCopy("+cname+") *** TERM *** leaf"+ctype+fname); |
579 | 581 | return true; |
580 | 582 | } |
581 | - | |
583 | + | |
582 | 584 | Field[] fd = c.getDeclaredFields(); |
583 | - | |
585 | + | |
584 | 586 | // フィールドなんかねーよ |
585 | 587 | if ( fd.length == 0 ) { |
586 | 588 | if ( fn == null ) { |
@@ -588,20 +590,20 @@ public class FieldUtils { | ||
588 | 590 | if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") no field"+ctype+fname); |
589 | 591 | continue; |
590 | 592 | } |
591 | - | |
593 | + | |
592 | 594 | if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") *** TERM *** no field"+ctype+fname); |
593 | 595 | return isCopyable(to,from,c,fn); // 終端 |
594 | 596 | } |
595 | - | |
597 | + | |
596 | 598 | // (フィールド)たんけんぼくのまち。チョーさん生きてるよ! |
597 | 599 | for ( Field f : fd ) { |
598 | 600 | f.setAccessible(true); |
599 | - | |
601 | + | |
600 | 602 | String xcname = f.getType().getName(); |
601 | 603 | String xfname = " name="+f.getName(); |
602 | - | |
604 | + | |
603 | 605 | int mod = f.getModifiers(); |
604 | - | |
606 | + | |
605 | 607 | if ( Modifier.isFinal(mod) ) { |
606 | 608 | if (debuglv2) System.err.println("[DEBUG] FieldCopy("+xcname+") : FINAL field "+ctype+xfname); |
607 | 609 | continue; |
@@ -610,55 +612,55 @@ public class FieldUtils { | ||
610 | 612 | if (debug) System.err.println("[DEBUG] FieldCopy("+xcname+") : STATIC field "+ctype+xfname); |
611 | 613 | continue; |
612 | 614 | } |
613 | - | |
614 | - | |
615 | + | |
616 | + | |
615 | 617 | Object o = f.get(from); |
616 | 618 | if ( o == null ) { |
617 | 619 | if (debug) System.err.println("[DEBUG] FieldCopy("+xcname+") *** TERM *** null value FROM"+ctype+xfname); |
618 | 620 | f.set(to, null); |
619 | 621 | continue; // 終端 |
620 | 622 | } |
621 | - | |
623 | + | |
622 | 624 | Class xc = o.getClass(); |
623 | 625 | xcname = xc.getName(); |
624 | - | |
626 | + | |
625 | 627 | if ( isHashMap(to,o,xc,f) ) { |
626 | 628 | if (debuglv2) System.err.println("[DEBUG] FieldCopy("+xcname+") *** TERM *** deep copy"+ctype+xfname); |
627 | 629 | continue; |
628 | 630 | } |
629 | - | |
631 | + | |
630 | 632 | if ( isLeaf(to,o,xc,f) ) { |
631 | 633 | if (debuglv2) System.err.println("[DEBUG] FieldCopy("+xcname+") *** TERM *** leaf"+ctype+xfname); |
632 | 634 | continue; |
633 | 635 | } |
634 | - | |
636 | + | |
635 | 637 | isCopyable(to,o,xc,f); // 終端 |
636 | 638 | } |
637 | 639 | } |
638 | - | |
640 | + | |
639 | 641 | return true; |
640 | 642 | } |
641 | - | |
643 | + | |
642 | 644 | // HashMapとか、コピーする |
643 | 645 | @SuppressWarnings({ "unchecked", "rawtypes" }) |
644 | 646 | private static boolean isHashMap(Object to, Object from, Class c, Field f) throws InstantiationException, IllegalAccessException, ConcurrentModificationException { |
645 | - | |
647 | + | |
646 | 648 | String cname = c.getName(); |
647 | 649 | String fname = " name="+((f==null)?("<TOP>"):(f.getName())); |
648 | - | |
650 | + | |
649 | 651 | for ( Class cx : unCloneables ) { |
650 | 652 | if ( cx.equals(c) ) { |
651 | 653 | if ( HashMap.class.equals(c) || ArrayList.class.equals(c) ) { |
652 | - | |
654 | + | |
653 | 655 | final Object px = (f==null)?(to):(f.get(to)); |
654 | 656 | if ( px == null ) { |
655 | 657 | // コピー先にインスタンスが存在している必要がある |
656 | 658 | if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isCloneable() : must have been initialized"+fname); |
657 | 659 | return true; |
658 | 660 | } |
659 | - | |
661 | + | |
660 | 662 | // 個別(キャスト!) |
661 | - | |
663 | + | |
662 | 664 | if ( HashMap.class.equals(c) ) { |
663 | 665 | HashMap<Object, Object> o = (HashMap<Object, Object>) from; |
664 | 666 | HashMap<Object, Object> p; |
@@ -670,14 +672,14 @@ public class FieldUtils { | ||
670 | 672 | // 自身(orスーパークラス)なら別物だろうからキャストで大丈夫だろう |
671 | 673 | p = (HashMap<Object, Object>) to; |
672 | 674 | } |
673 | - | |
675 | + | |
674 | 676 | p.clear(); // とりあえず消す |
675 | 677 | if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isHashMap() : HashMap "+cname+fname+" size="+o.size()); |
676 | 678 | for ( Entry<Object, Object> entry: o.entrySet() ) { |
677 | 679 | if (debuglv2) System.err.println("[DEBUG] FieldCopy("+cname+") / isHashMap() : copy"+fname+" key="+entry.getKey()+" value="+entry.getValue()); |
678 | 680 | p.put(entry.getKey(), entry.getValue()); |
679 | 681 | } |
680 | - | |
682 | + | |
681 | 683 | if ( f != null ) { |
682 | 684 | f.set(to, p); |
683 | 685 | } |
@@ -691,14 +693,14 @@ public class FieldUtils { | ||
691 | 693 | else { |
692 | 694 | p = (ArrayList<Object>) to; |
693 | 695 | } |
694 | - | |
696 | + | |
695 | 697 | p.clear(); // とりあえず消す |
696 | 698 | if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isHashMap() : ArrayList "+cname+fname+" size="+o.size()); |
697 | 699 | for ( Object entry: o ) { |
698 | 700 | if (debuglv2) System.err.println("[DEBUG] FieldCopy("+cname+") / isHashMap() : copy"+fname+" value="+entry); |
699 | 701 | p.add(entry); |
700 | 702 | } |
701 | - | |
703 | + | |
702 | 704 | if ( f != null ) { |
703 | 705 | f.set(to, p); |
704 | 706 | } |
@@ -708,44 +710,44 @@ public class FieldUtils { | ||
708 | 710 | if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isHashMap() : unsupported"+fname); |
709 | 711 | } |
710 | 712 | return true; |
711 | - } | |
713 | + } | |
712 | 714 | } |
713 | 715 | return false; |
714 | 716 | } |
715 | - | |
717 | + | |
716 | 718 | @SuppressWarnings("rawtypes") |
717 | 719 | private static final Class[] unCloneables = { HashMap.class, AbstractMap.class, ArrayList.class, AbstractList.class }; |
718 | - | |
720 | + | |
719 | 721 | // Integerとか、コピーする |
720 | 722 | @SuppressWarnings("rawtypes") |
721 | 723 | private static boolean isLeaf(Object to, Object from, Class c, Field f) throws IllegalArgumentException, IllegalAccessException { |
722 | - | |
724 | + | |
723 | 725 | String cname = c.getName(); |
724 | 726 | //String fname = " name="+((f==null)?("<TOP>"):(f.getName())); |
725 | - | |
727 | + | |
726 | 728 | if ( from instanceof String || from instanceof Boolean || from instanceof Number || from instanceof Color || from instanceof Enum || from instanceof Component ) { |
727 | 729 | if ( f == null ) { |
728 | 730 | if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isLeaf() : <Top> is not allowed"); |
729 | 731 | return true; |
730 | 732 | } |
731 | - | |
733 | + | |
732 | 734 | //if (debuglv2) System.err.println("[DEBUG] FieldCopy("+cname+") / isLeaf() : leaf field"+fname); |
733 | 735 | f.set(to, from); |
734 | 736 | return true; |
735 | 737 | } |
736 | - | |
738 | + | |
737 | 739 | return false; |
738 | 740 | } |
739 | - | |
741 | + | |
740 | 742 | // |
741 | 743 | @SuppressWarnings("rawtypes") |
742 | 744 | private static boolean isCopyable(Object to, Object from, Class c, Field f) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException { |
743 | - | |
745 | + | |
744 | 746 | String cname = c.getName(); |
745 | 747 | String fname = " name="+((f==null)?("<TOP>"):(f.getName())); |
746 | - | |
748 | + | |
747 | 749 | // コピーに失敗して例外の発生したフィールドについては無視します |
748 | - | |
750 | + | |
749 | 751 | if ( c.isPrimitive() ) { |
750 | 752 | if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isCopyable() : primitive"+fname); |
751 | 753 | f.set(to, from); |
@@ -761,7 +763,7 @@ public class FieldUtils { | ||
761 | 763 | if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isCopyable() : array of "+comp.getName()+fname+" lenth="+Array.getLength(from)); |
762 | 764 | Object[] o = (Object[]) from; |
763 | 765 | Object[] p = (Object[]) Array.newInstance(comp, Array.getLength(from)); |
764 | - | |
766 | + | |
765 | 767 | for ( int i=o.length-1; i>=0; i-- ) { |
766 | 768 | if (debuglv2) System.err.println("[DEBUG] FieldCopy("+comp.getName()+") / isCopyable() : copy"+fname+" value="+o[i]); |
767 | 769 | p[i] = o[i]; |
@@ -772,17 +774,17 @@ public class FieldUtils { | ||
772 | 774 | // そのほかは可能な限りcloneする |
773 | 775 | invokeClone(to,from,c,f); |
774 | 776 | } |
775 | - | |
777 | + | |
776 | 778 | return true; |
777 | 779 | } |
778 | - | |
780 | + | |
779 | 781 | // |
780 | 782 | @SuppressWarnings("rawtypes") |
781 | 783 | private static boolean invokeClone(Object to, Object from, Class c, Field f) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { |
782 | - | |
784 | + | |
783 | 785 | final String cname = c.getName(); |
784 | 786 | final String fname = " name="+((f==null)?("<TOP>"):(f.getName())); // よく考えたらここにf==nullで入ってくることはない |
785 | - | |
787 | + | |
786 | 788 | try { |
787 | 789 | @SuppressWarnings("unchecked") |
788 | 790 | Method m = c.getMethod("clone"); |
@@ -5,7 +5,7 @@ import java.util.regex.Pattern; | ||
5 | 5 | |
6 | 6 | |
7 | 7 | public class VersionInfo { |
8 | - private static final String Version = "タイニー番組ナビゲータ for DBR-T2007 3.22.18β+1.13.4"; | |
8 | + private static final String Version = "タイニー番組ナビゲータ for DBR-T2007 3.22.18β+1.13.5"; | |
9 | 9 | |
10 | 10 | private static final String OSname = System.getProperty("os.name"); |
11 | 11 | private static final String OSvers = System.getProperty("os.version"); |