|
| 1 | +create or replace type body ut_be_empty as |
| 2 | + /* |
| 3 | + utPLSQL - Version X.X.X.X |
| 4 | + Copyright 2016 - 2017 utPLSQL Project |
| 5 | + |
| 6 | + Licensed under the Apache License, Version 2.0 (the "License"): |
| 7 | + you may not use this file except in compliance with the License. |
| 8 | + You may obtain a copy of the License at |
| 9 | + |
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + |
| 12 | + Unless required by applicable law or agreed to in writing, software |
| 13 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + See the License for the specific language governing permissions and |
| 16 | + limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | + member procedure init(self in out nocopy ut_be_empty) is |
| 20 | + begin |
| 21 | + self.name := 'be_empty'; |
| 22 | + end; |
| 23 | + |
| 24 | + constructor function ut_be_empty(self in out nocopy ut_be_empty) return self as result is |
| 25 | + begin |
| 26 | + init(); |
| 27 | + return; |
| 28 | + end; |
| 29 | + |
| 30 | + overriding member function run_matcher(self in out nocopy ut_be_empty, a_actual ut_data_value) return boolean is |
| 31 | + l_result boolean; |
| 32 | + begin |
| 33 | + if a_actual is of(ut_data_value_refcursor) then |
| 34 | + declare |
| 35 | + l_actual ut_data_value_refcursor := treat(a_actual as ut_data_value_refcursor); |
| 36 | + begin |
| 37 | + if l_actual.data_value is not null then |
| 38 | + l_result := l_actual.is_empty; |
| 39 | + else |
| 40 | + l_result := false; |
| 41 | + end if; |
| 42 | + end; |
| 43 | + elsif a_actual is of(ut_data_value_anydata) then |
| 44 | + declare |
| 45 | + l_actual ut_data_value_anydata := treat(a_actual as ut_data_value_anydata); |
| 46 | + l_type_name varchar2(61); |
| 47 | + l_type anytype; |
| 48 | + begin |
| 49 | + if l_actual.data_value.gettype(l_type) in |
| 50 | + (dbms_types.typecode_varray, dbms_types.typecode_table, dbms_types.typecode_namedcollection) then |
| 51 | + if a_actual.is_null() then |
| 52 | + l_result := false; |
| 53 | + else |
| 54 | + ut_assert_processor.set_xml_nls_params(); |
| 55 | + l_type_name := l_actual.data_value.gettypename(); |
| 56 | + l_type_name := substr(l_type_name, instr(l_type_name, '.') + 1); |
| 57 | + l_result := xmltype(l_actual.data_value).getclobval() = '<' || l_type_name || '/>'; |
| 58 | + ut_assert_processor.reset_nls_params(); |
| 59 | + end if; |
| 60 | + else |
| 61 | + ut_utils.debug_log('Failure - ut_be_empty.run_matcher can only be used with collections and cursors'); |
| 62 | + self.error_message := 'The matcher can only be used with collections and cursors'; |
| 63 | + l_result := null; |
| 64 | + end if; |
| 65 | + end; |
| 66 | + else |
| 67 | + l_result := (self as ut_matcher).run_matcher(a_actual); |
| 68 | + end if; |
| 69 | + return l_result; |
| 70 | + end; |
| 71 | + |
| 72 | +end; |
| 73 | +/ |
0 commit comments