• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

タイニー番組ナビゲータ本体


Commit MetaInfo

Revisión62f244949e194d47bbde4d8b69eb9d6fced6b24e (tree)
Tiempo2021-11-17 23:03:33
AutorMasahiko Kimura <mkimura@u01....>
CommiterMasahiko Kimura

Log Message

Ver.1.13.5 (2021/11/17)

  1. [全般]「各種設定」画面で更新を確定しないで再起動すると、番組表がデフォルトのDimoraになってしまう問題の対応

Cambiar Resumen

Diferencia incremental

--- a/TinyBannavi/src/tainavi/FieldUtils.java
+++ b/TinyBannavi/src/tainavi/FieldUtils.java
@@ -28,47 +28,47 @@ import tainavi.TVProgram.ProgOption;
2828
2929 /**
3030 * オブジェクトのフィールドを操作するユーティリティーメソッド群
31- *
31+ *
3232 * @version 3.22.2b CommonUtils#FieldCopy()を{@link #deepCopy(Object, Object)}に移動<BR>
3333 */
3434 public class FieldUtils {
3535
3636 public void setDebug(boolean b) { debug = b; }
3737 private static boolean debug = false;
38-
38+
3939 private static boolean debuglv2 = false;
40-
40+
4141 /*******************************************************************************
4242 * 定数とか
4343 ******************************************************************************/
44-
44+
4545 private static final String SPCH_LF = "$LF$";
4646 private static final String SPCH_NULL = "$NULL$";
47-
47+
4848 private static final String SPMK_CM = "#";
4949 private static final String SPMK_SEP = "=";
5050 private static final String SPMK_LF = "\n";
51-
51+
5252 private static final String SPHD_MOD = SPMK_CM+" MODIFIED : ";
5353 private static final String SPHD_VER = SPMK_CM+" VERSION : ";
5454 private static final String SPHD_DEP = SPMK_CM+" DEPRECATED : ";
5555 private static final String SPHD_UNS = SPMK_CM+" UNSUPPORTED : ";
5656 private static final String SPHD_NOE = SPMK_CM+" NOELEMENT : ";
57-
57+
5858 private static final String CMNT_AS = " AS ";
59-
59+
6060 private static final String MSGID = "[設定保存] ";
6161 private static final String ERRID = "[ERROR]"+MSGID;
62-
62+
6363 /*******************************************************************************
6464 * 保存
6565 ******************************************************************************/
66-
66+
6767 @SuppressWarnings({ "rawtypes", "unchecked" })
6868 public static boolean save(String envText, Object root) {
69-
69+
7070 StringBuilder sb = new StringBuilder();
71-
71+
7272 sb.append(SPHD_MOD);
7373 sb.append(CommonUtils.getDateTime(0));
7474 sb.append(SPMK_LF);
@@ -76,7 +76,7 @@ public class FieldUtils {
7676 sb.append(VersionInfo.getVersionNumber());
7777 sb.append(SPMK_LF);
7878 sb.append(SPMK_LF);
79-
79+
8080 Field[] fd = root.getClass().getDeclaredFields();
8181 for ( Field fx : fd ) {
8282 fx.setAccessible(true);
@@ -88,11 +88,11 @@ public class FieldUtils {
8888 }
8989
9090 try {
91-
91+
9292 String key = fx.getName();
9393 Class cls = fx.getType();
9494 Object obj = fx.get(root);
95-
95+
9696 if ( fx.getAnnotation(Deprecated.class) != null ) {
9797 sb.append(SPHD_DEP);
9898 sb.append(key);
@@ -101,19 +101,19 @@ public class FieldUtils {
101101 sb.append(SPMK_LF);
102102 continue;
103103 }
104-
104+
105105 int n = -1;
106106 ArrayList objlst = null;
107107 Class ocls = null;
108108 if ( cls == ArrayList.class ) {
109109 objlst = (ArrayList) obj;
110-
110+
111111 // nullの要素がある可能性がある
112112 if ( objlst.size() > 0 ) {
113113 ParameterizedType paramType = (ParameterizedType) fx.getGenericType();
114114 ocls = (Class) paramType.getActualTypeArguments()[0];
115115 }
116-
116+
117117 n = 1;
118118 }
119119 else if ( cls == HashMap.class ) {
@@ -121,7 +121,7 @@ public class FieldUtils {
121121 HashMap map = (HashMap) obj;
122122 for ( Object o : map.entrySet().toArray() ) {
123123 objlst.add(o);
124-
124+
125125 // これは必ずEntrySetだね
126126 if ( ocls == null ) {
127127 ocls = o.getClass();
@@ -132,17 +132,17 @@ public class FieldUtils {
132132 else {
133133 objlst = new ArrayList();
134134 objlst.add(obj);
135-
135+
136136 // obj==nullの可能性がある
137137 ocls = cls;
138138 }
139-
139+
140140 if ( ! objlst.isEmpty() ) {
141141 for ( Object o : objlst ) {
142-
142+
143143 //Class ocls = o.getClass();
144144 String val = obj2str(o,ocls);
145-
145+
146146 if ( val != null ) {
147147 sb.append(key);
148148 if ( n >= 1 ) {
@@ -181,53 +181,53 @@ public class FieldUtils {
181181 catch (Exception e) {
182182 e.printStackTrace();
183183 return false;
184- }
184+ }
185185 }
186-
186+
187187 System.out.println(MSGID+"テキスト形式で保存します: "+envText);
188188 if ( ! CommonUtils.write2file(envText, sb.toString()) ) {
189189 System.err.println(ERRID+"保存に失敗しました");
190190 return false;
191191 }
192-
192+
193193 return true;
194194 }
195-
196-
195+
196+
197197 /*******************************************************************************
198198 * 取得
199199 ******************************************************************************/
200-
200+
201201 @SuppressWarnings({ "rawtypes", "unchecked" })
202202 public static boolean load(String envText, Object root) {
203-
203+
204204 if ( new File(envText).exists() ) {
205205 System.out.println(MSGID+"テキスト形式で読み込みます: "+envText);
206206 String buf = CommonUtils.read4file(envText, false);
207207 if ( buf != null ) {
208-
208+
209209 Field[] fd = root.getClass().getDeclaredFields();
210-
210+
211211 int lineno = 0 ;
212212 for ( String str : buf.split(SPMK_LF) ) {
213-
213+
214214 ++lineno;
215-
215+
216216 if ( str.startsWith(SPHD_MOD) ) {
217217 System.out.println(MSGID+str);
218218 continue;
219219 }
220-
220+
221221 if ( str.startsWith(SPMK_CM) || str.matches("^\\s*$") ) {
222222 continue;
223223 }
224-
224+
225225 String[] a = str.split(SPMK_SEP, 2);
226226 if ( a.length != 2 ) {
227227 System.err.println(ERRID+"不正な記述: "+envText+" at "+lineno+"行目 "+str);
228228 break;
229229 }
230-
230+
231231 Field fx = null;
232232 for ( Field f : fd ) {
233233 if ( f.getName().equals(a[0].replaceFirst("\\[\\d+\\]$","")) ) {
@@ -239,23 +239,23 @@ public class FieldUtils {
239239 System.err.println(ERRID+"不正な記述: "+envText+" at "+lineno+"行目 "+str);
240240 break;
241241 }
242-
242+
243243 fx.setAccessible(true);
244-
244+
245245 if ( Modifier.isFinal(fx.getModifiers()) ) {
246246 continue;
247247 }
248248 if ( Modifier.isStatic(fx.getModifiers()) ) {
249249 continue;
250250 }
251-
251+
252252 if ( fx.getAnnotation(Deprecated.class) != null ) {
253253 System.out.println(MSGID+SPHD_DEP+fx.getName());
254254 break;
255255 }
256-
256+
257257 Class cls = fx.getType();
258-
258+
259259 try {
260260 if ( cls == ArrayList.class ) {
261261 ArrayList list = (ArrayList) fx.get(root);
@@ -263,7 +263,7 @@ public class FieldUtils {
263263 System.out.println(ERRID+"初期化されていないフィールド: "+envText+" at "+lineno+"行目 ("+cls.getName()+") "+str);
264264 break;
265265 }
266-
266+
267267 if ( a[0].endsWith("[0]") ) {
268268 // no element.
269269 list.clear();
@@ -285,12 +285,7 @@ public class FieldUtils {
285285 System.out.println(ERRID+"初期化されていないフィールド: "+envText+" at "+lineno+"行目 ("+cls.getName()+") "+str);
286286 break;
287287 }
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+
294289 if ( a[0].endsWith("[0]") ) {
295290 // no element.
296291 map.clear();
@@ -300,6 +295,13 @@ public class FieldUtils {
300295 // newした時のデフォルト値が入っているからリセットじゃー
301296 map.clear();
302297 }
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+
303305 ParameterizedType paramType = (ParameterizedType) fx.getGenericType();
304306 Class kcls = (Class) paramType.getActualTypeArguments()[0];
305307 Class vcls = (Class) paramType.getActualTypeArguments()[1];
@@ -323,18 +325,18 @@ public class FieldUtils {
323325 }
324326 }
325327 }
326-
328+
327329 return true;
328330 }
329-
331+
330332 return false;
331333 }
332-
333-
334+
335+
334336 /*******************************************************************************
335337 * 保存(部品)
336338 ******************************************************************************/
337-
339+
338340 @SuppressWarnings("rawtypes")
339341 private static String obj2str(Object obj, Class cls) {
340342 if ( cls == String.class ) {
@@ -384,15 +386,15 @@ public class FieldUtils {
384386 String v = obj2str(t.getValue(), t.getValue().getClass());
385387 return(obj == null ? SPCH_NULL : k+SPCH_LF+v);
386388 }
387-
389+
388390 return null;
389391 }
390-
391-
392+
393+
392394 /*******************************************************************************
393395 * 取得(部品)
394396 ******************************************************************************/
395-
397+
396398 @SuppressWarnings("rawtypes")
397399 private static Object str2obj(String str, Class cls) throws UnsupportedOperationException {
398400 if ( cls == String.class ) {
@@ -505,16 +507,16 @@ public class FieldUtils {
505507 }
506508 throw new UnsupportedOperationException("変換できない");
507509 }
508-
510+
509511 throw new UnsupportedOperationException("未対応の項目");
510512 }
511513
512-
513-
514+
515+
514516 /*******************************************************************************
515517 * ディープコピーする
516518 ******************************************************************************/
517-
519+
518520 /**
519521 * <P>オブジェクトからオブジェクトへフィールドのコピー(ディープコピー)を行います。
520522 * <P>新しく作ったインスタンスに入れ替えたいけど、ポインタを変えたくないので中身だけコピーできないか?という時に使います。
@@ -534,10 +536,10 @@ public class FieldUtils {
534536 }
535537 return false;
536538 }
537-
539+
538540 @SuppressWarnings("rawtypes")
539541 private static boolean FieldCopy(final Object to, final Object from, final Field fn) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ConcurrentModificationException, InstantiationException {
540-
542+
541543 // 継承しているクラスのリストを作成する
542544 ArrayList<Class> fromCL = new ArrayList<Class>();
543545 ArrayList<Class> toCL = new ArrayList<Class>();
@@ -559,28 +561,28 @@ public class FieldUtils {
559561 if (debuglv2) System.out.println("[DEBUG] removed TO "+toCL.get(0).getName());
560562 toCL.remove(0);
561563 }
562-
564+
563565 int i=0;
564566 for ( Class c : fromCL ) {
565-
567+
566568 i++;
567-
569+
568570 String ctype = (i>1)?(" (super class)"):("");
569571 String cname = c.getName();
570572 String fname = (fn!=null)?(" name="+fn.getName()):("");
571-
573+
572574 if ( isHashMap(to,from,c,fn) ) {
573575 if (debuglv2) System.err.println("[DEBUG] FieldCopy("+cname+") *** TERM *** deep copy"+ctype+fname);
574576 return true;
575577 }
576-
578+
577579 if ( isLeaf(to,from,c,fn) ) {
578580 if (debuglv2) System.err.println("[DEBUG] FieldCopy("+cname+") *** TERM *** leaf"+ctype+fname);
579581 return true;
580582 }
581-
583+
582584 Field[] fd = c.getDeclaredFields();
583-
585+
584586 // フィールドなんかねーよ
585587 if ( fd.length == 0 ) {
586588 if ( fn == null ) {
@@ -588,20 +590,20 @@ public class FieldUtils {
588590 if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") no field"+ctype+fname);
589591 continue;
590592 }
591-
593+
592594 if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") *** TERM *** no field"+ctype+fname);
593595 return isCopyable(to,from,c,fn); // 終端
594596 }
595-
597+
596598 // (フィールド)たんけんぼくのまち。チョーさん生きてるよ!
597599 for ( Field f : fd ) {
598600 f.setAccessible(true);
599-
601+
600602 String xcname = f.getType().getName();
601603 String xfname = " name="+f.getName();
602-
604+
603605 int mod = f.getModifiers();
604-
606+
605607 if ( Modifier.isFinal(mod) ) {
606608 if (debuglv2) System.err.println("[DEBUG] FieldCopy("+xcname+") : FINAL field "+ctype+xfname);
607609 continue;
@@ -610,55 +612,55 @@ public class FieldUtils {
610612 if (debug) System.err.println("[DEBUG] FieldCopy("+xcname+") : STATIC field "+ctype+xfname);
611613 continue;
612614 }
613-
614-
615+
616+
615617 Object o = f.get(from);
616618 if ( o == null ) {
617619 if (debug) System.err.println("[DEBUG] FieldCopy("+xcname+") *** TERM *** null value FROM"+ctype+xfname);
618620 f.set(to, null);
619621 continue; // 終端
620622 }
621-
623+
622624 Class xc = o.getClass();
623625 xcname = xc.getName();
624-
626+
625627 if ( isHashMap(to,o,xc,f) ) {
626628 if (debuglv2) System.err.println("[DEBUG] FieldCopy("+xcname+") *** TERM *** deep copy"+ctype+xfname);
627629 continue;
628630 }
629-
631+
630632 if ( isLeaf(to,o,xc,f) ) {
631633 if (debuglv2) System.err.println("[DEBUG] FieldCopy("+xcname+") *** TERM *** leaf"+ctype+xfname);
632634 continue;
633635 }
634-
636+
635637 isCopyable(to,o,xc,f); // 終端
636638 }
637639 }
638-
640+
639641 return true;
640642 }
641-
643+
642644 // HashMapとか、コピーする
643645 @SuppressWarnings({ "unchecked", "rawtypes" })
644646 private static boolean isHashMap(Object to, Object from, Class c, Field f) throws InstantiationException, IllegalAccessException, ConcurrentModificationException {
645-
647+
646648 String cname = c.getName();
647649 String fname = " name="+((f==null)?("<TOP>"):(f.getName()));
648-
650+
649651 for ( Class cx : unCloneables ) {
650652 if ( cx.equals(c) ) {
651653 if ( HashMap.class.equals(c) || ArrayList.class.equals(c) ) {
652-
654+
653655 final Object px = (f==null)?(to):(f.get(to));
654656 if ( px == null ) {
655657 // コピー先にインスタンスが存在している必要がある
656658 if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isCloneable() : must have been initialized"+fname);
657659 return true;
658660 }
659-
661+
660662 // 個別(キャスト!)
661-
663+
662664 if ( HashMap.class.equals(c) ) {
663665 HashMap<Object, Object> o = (HashMap<Object, Object>) from;
664666 HashMap<Object, Object> p;
@@ -670,14 +672,14 @@ public class FieldUtils {
670672 // 自身(orスーパークラス)なら別物だろうからキャストで大丈夫だろう
671673 p = (HashMap<Object, Object>) to;
672674 }
673-
675+
674676 p.clear(); // とりあえず消す
675677 if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isHashMap() : HashMap "+cname+fname+" size="+o.size());
676678 for ( Entry<Object, Object> entry: o.entrySet() ) {
677679 if (debuglv2) System.err.println("[DEBUG] FieldCopy("+cname+") / isHashMap() : copy"+fname+" key="+entry.getKey()+" value="+entry.getValue());
678680 p.put(entry.getKey(), entry.getValue());
679681 }
680-
682+
681683 if ( f != null ) {
682684 f.set(to, p);
683685 }
@@ -691,14 +693,14 @@ public class FieldUtils {
691693 else {
692694 p = (ArrayList<Object>) to;
693695 }
694-
696+
695697 p.clear(); // とりあえず消す
696698 if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isHashMap() : ArrayList "+cname+fname+" size="+o.size());
697699 for ( Object entry: o ) {
698700 if (debuglv2) System.err.println("[DEBUG] FieldCopy("+cname+") / isHashMap() : copy"+fname+" value="+entry);
699701 p.add(entry);
700702 }
701-
703+
702704 if ( f != null ) {
703705 f.set(to, p);
704706 }
@@ -708,44 +710,44 @@ public class FieldUtils {
708710 if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isHashMap() : unsupported"+fname);
709711 }
710712 return true;
711- }
713+ }
712714 }
713715 return false;
714716 }
715-
717+
716718 @SuppressWarnings("rawtypes")
717719 private static final Class[] unCloneables = { HashMap.class, AbstractMap.class, ArrayList.class, AbstractList.class };
718-
720+
719721 // Integerとか、コピーする
720722 @SuppressWarnings("rawtypes")
721723 private static boolean isLeaf(Object to, Object from, Class c, Field f) throws IllegalArgumentException, IllegalAccessException {
722-
724+
723725 String cname = c.getName();
724726 //String fname = " name="+((f==null)?("<TOP>"):(f.getName()));
725-
727+
726728 if ( from instanceof String || from instanceof Boolean || from instanceof Number || from instanceof Color || from instanceof Enum || from instanceof Component ) {
727729 if ( f == null ) {
728730 if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isLeaf() : <Top> is not allowed");
729731 return true;
730732 }
731-
733+
732734 //if (debuglv2) System.err.println("[DEBUG] FieldCopy("+cname+") / isLeaf() : leaf field"+fname);
733735 f.set(to, from);
734736 return true;
735737 }
736-
738+
737739 return false;
738740 }
739-
741+
740742 //
741743 @SuppressWarnings("rawtypes")
742744 private static boolean isCopyable(Object to, Object from, Class c, Field f) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException {
743-
745+
744746 String cname = c.getName();
745747 String fname = " name="+((f==null)?("<TOP>"):(f.getName()));
746-
748+
747749 // コピーに失敗して例外の発生したフィールドについては無視します
748-
750+
749751 if ( c.isPrimitive() ) {
750752 if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isCopyable() : primitive"+fname);
751753 f.set(to, from);
@@ -761,7 +763,7 @@ public class FieldUtils {
761763 if (debug) System.err.println("[DEBUG] FieldCopy("+cname+") / isCopyable() : array of "+comp.getName()+fname+" lenth="+Array.getLength(from));
762764 Object[] o = (Object[]) from;
763765 Object[] p = (Object[]) Array.newInstance(comp, Array.getLength(from));
764-
766+
765767 for ( int i=o.length-1; i>=0; i-- ) {
766768 if (debuglv2) System.err.println("[DEBUG] FieldCopy("+comp.getName()+") / isCopyable() : copy"+fname+" value="+o[i]);
767769 p[i] = o[i];
@@ -772,17 +774,17 @@ public class FieldUtils {
772774 // そのほかは可能な限りcloneする
773775 invokeClone(to,from,c,f);
774776 }
775-
777+
776778 return true;
777779 }
778-
780+
779781 //
780782 @SuppressWarnings("rawtypes")
781783 private static boolean invokeClone(Object to, Object from, Class c, Field f) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
782-
784+
783785 final String cname = c.getName();
784786 final String fname = " name="+((f==null)?("<TOP>"):(f.getName())); // よく考えたらここにf==nullで入ってくることはない
785-
787+
786788 try {
787789 @SuppressWarnings("unchecked")
788790 Method m = c.getMethod("clone");
--- a/TinyBannavi/src/tainavi/VersionInfo.java
+++ b/TinyBannavi/src/tainavi/VersionInfo.java
@@ -5,7 +5,7 @@ import java.util.regex.Pattern;
55
66
77 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";
99
1010 private static final String OSname = System.getProperty("os.name");
1111 private static final String OSvers = System.getProperty("os.version");