|
70 | 70 | * These are the internal keywords. |
71 | 71 | */ |
72 | 72 | @ActivityObject |
73 | | -@Version(12.8f) |
| 73 | +@Version(13.20f) |
74 | 74 | public class Common { |
75 | 75 | static { |
76 | 76 | System.out.println("common created."); |
@@ -745,6 +745,59 @@ public static void ProgressDialogShow2(BA ba, CharSequence Text, boolean Cancela |
745 | 745 | public static void ProgressDialogHide() { |
746 | 746 | Msgbox.dismissProgressDialog(); |
747 | 747 | } |
| 748 | + |
| 749 | + /** |
| 750 | + * Tests whether the given object is not null and initialized (if it has such method or field). |
| 751 | + *If there is no such method or field then only null is tested. |
| 752 | + */ |
| 753 | + public static boolean Initialized (Object Object) { |
| 754 | + return !NotInitialized(Object); |
| 755 | + } |
| 756 | + private static final java.util.Map<Class<?>, Integer> testedClassesForIsInitialized = new HashMap<Class<?>, Integer>(); |
| 757 | + /** |
| 758 | + * Tests whether the given object is null or is not initialized (if it has such method or field). |
| 759 | + *If there is no such method or field then only null is tested. |
| 760 | + */ |
| 761 | + public static boolean NotInitialized (Object Object) { |
| 762 | + if (Object == null) |
| 763 | + return true; |
| 764 | + if (Object instanceof ObjectWrapper) { |
| 765 | + return ((ObjectWrapper<?>)Object).getObjectOrNull() == null; |
| 766 | + } else if (Object instanceof B4AClass) { |
| 767 | + return !((B4AClass)Object).IsInitialized(); |
| 768 | + } else { |
| 769 | + Class<?> cls = Object.getClass(); |
| 770 | + Integer b = testedClassesForIsInitialized.get(cls); |
| 771 | + if (b == null || b.intValue() > 0) { |
| 772 | + Object o = null; |
| 773 | + if (b == null || b.intValue() == 1) { |
| 774 | + try { |
| 775 | + o = cls.getMethod("IsInitialized").invoke(Object); |
| 776 | + if (b == null && o instanceof Boolean) |
| 777 | + testedClassesForIsInitialized.put(cls, 1); |
| 778 | + } catch (Exception e) { |
| 779 | + //ignore |
| 780 | + } |
| 781 | + } |
| 782 | + if (o == null && (b == null || b.intValue() == 2)) { |
| 783 | + try { |
| 784 | + o = cls.getField("IsInitialized").get(Object); |
| 785 | + if (b == null && o instanceof Boolean) |
| 786 | + testedClassesForIsInitialized.put(cls, 2); |
| 787 | + }catch (Exception e) { |
| 788 | + //ignore |
| 789 | + } |
| 790 | + } |
| 791 | + if (b == null && (o == null || (o instanceof Boolean) == false)) |
| 792 | + testedClassesForIsInitialized.put(cls, 0); |
| 793 | + else |
| 794 | + return !((Boolean)o).booleanValue(); |
| 795 | + } |
| 796 | + } |
| 797 | + return false; |
| 798 | + } |
| 799 | + |
| 800 | + |
748 | 801 | /** |
749 | 802 | * Returns a string representing the object's java type. |
750 | 803 | */ |
@@ -1714,7 +1767,7 @@ public static void Sleep(int Milliseconds) { |
1714 | 1767 |
|
1715 | 1768 | } |
1716 | 1769 | /** |
1717 | | - * Inline If - returns TrueValue if Condition is True and False otherwise. Only the relevant expression is evaluated. |
| 1770 | + * Inline If - returns TrueValue if Condition is True and FalseValue otherwise. Only the relevant expression is evaluated. |
1718 | 1771 | */ |
1719 | 1772 | public static Object IIf (boolean Condition, Object TrueValue, Object FalseValue) { |
1720 | 1773 | return null; |
|
0 commit comments